mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:27:35 +00:00
LibJS: Add Array.prototype.unshift()
This commit is contained in:
parent
5da1a40ccf
commit
29253bf932
3 changed files with 42 additions and 0 deletions
30
Libraries/LibJS/Tests/Array.prototype.unshift.js
Normal file
30
Libraries/LibJS/Tests/Array.prototype.unshift.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
load("test-common.js");
|
||||
|
||||
try {
|
||||
assert(Array.prototype.unshift.length === 1);
|
||||
|
||||
var a = ["hello"];
|
||||
var length = a.unshift();
|
||||
assert(length === 1);
|
||||
assert(a.length === 1);
|
||||
assert(a[0] === "hello");
|
||||
|
||||
length = a.unshift("friends");
|
||||
assert(length === 2);
|
||||
assert(a.length === 2);
|
||||
assert(a[0] === "friends");
|
||||
assert(a[1] === "hello");
|
||||
|
||||
length = a.unshift(1, 2, 3);
|
||||
assert(length === 5);
|
||||
assert(a.length === 5);
|
||||
assert(a[0] === 1);
|
||||
assert(a[1] === 2);
|
||||
assert(a[2] === 3);
|
||||
assert(a[3] === "friends");
|
||||
assert(a[4] === "hello");
|
||||
|
||||
console.log("PASS");
|
||||
} catch (e) {
|
||||
console.log("FAIL: " + e);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue