mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 01:27:34 +00:00
LibJS: Make Array.prototype.unshift generic
This commit is contained in:
parent
7c1e2adf8a
commit
d723c01af7
2 changed files with 65 additions and 5 deletions
|
@ -110,6 +110,26 @@ describe("ability to work with generic non-array objects", () => {
|
|||
expect(o).toEqual({ length: 4, 0: "b", 2: "c" });
|
||||
});
|
||||
|
||||
test("unshift", () => {
|
||||
{
|
||||
const o = { length: 5, 0: "a", 1: "b", 3: "c" };
|
||||
const front = "z";
|
||||
Array.prototype.unshift.call(o, front);
|
||||
expect(o[0]).toEqual(front);
|
||||
expect(o[1]).toEqual("a");
|
||||
expect(o.length).toEqual(6);
|
||||
}
|
||||
{
|
||||
const o = { length: 5, 0: "a", 1: "b", 3: "c" };
|
||||
const front = "z";
|
||||
Array.prototype.unshift.call(o, front, front);
|
||||
expect(o[0]).toEqual(front);
|
||||
expect(o[1]).toEqual(front);
|
||||
expect(o[2]).toEqual("a");
|
||||
expect(o.length).toEqual(7);
|
||||
}
|
||||
});
|
||||
|
||||
const o = { length: 5, 0: "foo", 1: "bar", 3: "baz" };
|
||||
|
||||
test("every", () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue