Fix SortedList.values iteration and general dec lifecycle fixes

Fixes #4652
This commit is contained in:
Daniel Imms
2023-08-13 10:42:45 -07:00
parent 5890029f71
commit 70f6fa2bc9
6 changed files with 26 additions and 25 deletions
+14
View File
@@ -104,4 +104,18 @@ describe('SortedList', () => {
{ key: 10 }
]);
});
describe('values', () => {
it('should iterate correctly when list items change during iteration', () => {
list.insert(1);
list.insert(2);
list.insert(3);
list.insert(4);
const visited: number[] = [];
for (const item of list.values()) {
visited.push(item);
list.delete(item);
}
deepStrictEqual(visited, [1, 2, 3, 4]);
});
});
});