mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:07:34 +00:00
LibJS: Append first sparse element to packed elements in take_first()
Otherwise we continuously lose the first sparse element (at index SPARSE_ARRAY_THRESHOLD) without noticing, as we overwrite all indices with the value at index+1. Fixes #5884.
This commit is contained in:
parent
611b3c2c49
commit
ae95ed5ddd
2 changed files with 20 additions and 3 deletions
|
@ -21,3 +21,15 @@ describe("normal behavior", () => {
|
|||
expect(a).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
test("Issue #5884, GenericIndexedPropertyStorage::take_first() loses elements", () => {
|
||||
const a = [];
|
||||
for (let i = 0; i < 300; i++) {
|
||||
a.push(i);
|
||||
}
|
||||
expect(a.length).toBe(300);
|
||||
for (let i = 0; i < 300; i++) {
|
||||
a.shift();
|
||||
}
|
||||
expect(a.length).toBe(0);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue