mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 06:28:13 +00:00
LibJS: Make Array.prototype.shift generic
This commit is contained in:
parent
690eb3bb8a
commit
7c1e2adf8a
2 changed files with 51 additions and 6 deletions
|
@ -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", () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue