diff options
author | Linus Groh <mail@linusgroh.de> | 2020-11-05 18:39:02 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-11-05 20:01:30 +0100 |
commit | dec6c0a20746d7b0ec43c80755d3e77e7741f180 (patch) | |
tree | b4dc360bab54d5f189d4bb01d8a6fa17ab055360 /Libraries/LibJS/Tests | |
parent | 0bb66890c8881118b86a0b77c0541676594142e6 (diff) | |
download | serenity-dec6c0a20746d7b0ec43c80755d3e77e7741f180.zip |
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.
Diffstat (limited to 'Libraries/LibJS/Tests')
-rw-r--r-- | Libraries/LibJS/Tests/builtins/Array/Array.prototype.pop.js | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Libraries/LibJS/Tests/builtins/Array/Array.prototype.pop.js b/Libraries/LibJS/Tests/builtins/Array/Array.prototype.pop.js index 2763159b3f..d1c34ad60e 100644 --- a/Libraries/LibJS/Tests/builtins/Array/Array.prototype.pop.js +++ b/Libraries/LibJS/Tests/builtins/Array/Array.prototype.pop.js @@ -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", () => { |