1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:17:45 +00:00

LibJS: Use array-like size for IndexedProperties::is_empty()

Some things, like (the non-generic version of) Array.prototype.pop(),
check is_empty() to determine whether an action, like removing elements,
can be performed. We need to know the array-like size for that, not the
size of the underlying storage, which can be different - and is not
something IndexedProperties should expose so I removed its size().

Fixes #3948.
This commit is contained in:
Linus Groh 2020-11-05 18:39:02 +00:00 committed by Andreas Kling
parent 0bb66890c8
commit dec6c0a207
2 changed files with 7 additions and 2 deletions

View file

@ -7,6 +7,12 @@ describe("normal behavior", () => {
var a = [1, 2, 3];
expect(a.pop()).toBe(3);
expect(a).toEqual([1, 2]);
expect(a.pop()).toBe(2);
expect(a).toEqual([1]);
expect(a.pop()).toBe(1);
expect(a).toEqual([]);
expect(a.pop()).toBeUndefined();
expect(a).toEqual([]);
});
test("empty array", () => {