summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Tests
diff options
context:
space:
mode:
authordavidot <david.tuin@gmail.com>2021-06-12 19:23:33 +0200
committerLinus Groh <mail@linusgroh.de>2021-06-14 09:57:06 +0100
commit7c1e2adf8a1fe2667378f734f0cf22ec625ab55c (patch)
treec2b7bb30dc03751a69c87ad0113673c4081c214c /Userland/Libraries/LibJS/Tests
parent690eb3bb8a538e9773024f40e8b4676336c8f849 (diff)
downloadserenity-7c1e2adf8a1fe2667378f734f0cf22ec625ab55c.zip
LibJS: Make Array.prototype.shift generic
Diffstat (limited to 'Userland/Libraries/LibJS/Tests')
-rw-r--r--Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype-generic-functions.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype-generic-functions.js b/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype-generic-functions.js
index 85ac3bf9e5..b86cc0d4c5 100644
--- a/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype-generic-functions.js
+++ b/Userland/Libraries/LibJS/Tests/builtins/Array/Array.prototype-generic-functions.js
@@ -100,6 +100,16 @@ describe("ability to work with generic non-array objects", () => {
expect(Array.prototype.includes.call({ length: 5, 2: "foo" }, "foo")).toBeTrue();
});
+ test("shift", () => {
+ expect(Array.prototype.shift.call({})).toBeUndefined();
+ expect(Array.prototype.shift.call({ length: 0 })).toBeUndefined();
+
+ const o = { length: 5, 0: "a", 1: "b", 3: "c" };
+ const front = Array.prototype.shift.call(o);
+ expect(front).toEqual("a");
+ expect(o).toEqual({ length: 4, 0: "b", 2: "c" });
+ });
+
const o = { length: 5, 0: "foo", 1: "bar", 3: "baz" };
test("every", () => {