1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:27:35 +00:00

LibJS: Support multiple arguments in Array.prototype.push()

This commit is contained in:
Linus Groh 2020-04-13 16:45:59 +01:00 committed by Andreas Kling
parent 9fab52a390
commit 5da1a40ccf
3 changed files with 35 additions and 6 deletions

View file

@ -0,0 +1,30 @@
load("test-common.js");
try {
assert(Array.prototype.push.length === 1);
var a = ["hello"];
var length = a.push();
assert(length === 1);
assert(a.length === 1);
assert(a[0] === "hello");
length = a.push("friends");
assert(length === 2);
assert(a.length === 2);
assert(a[0] === "hello");
assert(a[1] === "friends");
length = a.push(1, 2, 3);
assert(length === 5);
assert(a.length === 5);
assert(a[0] === "hello");
assert(a[1] === "friends");
assert(a[2] === 1);
assert(a[3] === 2);
assert(a[4] === 3);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}