mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:28:11 +00:00
LibJS: Add basic Array constructor
We only support Array() with 0 or 1 parameters so far.
This commit is contained in:
parent
eabdbe0ee9
commit
d155491122
6 changed files with 132 additions and 0 deletions
16
Libraries/LibJS/Tests/Array.js
Normal file
16
Libraries/LibJS/Tests/Array.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
assert(Array.length === 1);
|
||||
assert(Array.prototype.length === 0);
|
||||
assert(typeof Array() === "object");
|
||||
assert(typeof new Array() === "object");
|
||||
|
||||
x = new Array(5);
|
||||
|
||||
assert(x.length === 5);
|
||||
|
||||
console.log("PASS");
|
||||
} catch (e) {
|
||||
console.log("FAIL: " + e.message);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue