mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-05 01:42:54 +00:00
test-js: Use prettier and format all files
This commit is contained in:
parent
e532888242
commit
6d58c48c2f
Notes:
sideshowbarker
2024-07-19 05:04:03 +09:00
Author: https://github.com/mattco98
Commit: 6d58c48c2f
Pull-request: https://github.com/SerenityOS/serenity/pull/2689
Reviewed-by: https://github.com/linusg
248 changed files with 8291 additions and 7725 deletions
|
@ -1,48 +1,55 @@
|
|||
load("test-common.js");
|
||||
|
||||
try {
|
||||
assert(Array.length === 1);
|
||||
assert(Array.name === "Array");
|
||||
assert(Array.prototype.length === 0);
|
||||
assert(Array.length === 1);
|
||||
assert(Array.name === "Array");
|
||||
assert(Array.prototype.length === 0);
|
||||
|
||||
assert(typeof Array() === "object");
|
||||
assert(typeof new Array() === "object");
|
||||
assert(typeof Array() === "object");
|
||||
assert(typeof new Array() === "object");
|
||||
|
||||
var a;
|
||||
var a;
|
||||
|
||||
a = new Array(5);
|
||||
assert(a.length === 5);
|
||||
a = new Array(5);
|
||||
assert(a.length === 5);
|
||||
|
||||
a = new Array("5");
|
||||
assert(a.length === 1);
|
||||
assert(a[0] === "5");
|
||||
a = new Array("5");
|
||||
assert(a.length === 1);
|
||||
assert(a[0] === "5");
|
||||
|
||||
a = new Array(1, 2, 3);
|
||||
assert(a.length === 3);
|
||||
assert(a[0] === 1);
|
||||
assert(a[1] === 2);
|
||||
assert(a[2] === 3);
|
||||
a = new Array(1, 2, 3);
|
||||
assert(a.length === 3);
|
||||
assert(a[0] === 1);
|
||||
assert(a[1] === 2);
|
||||
assert(a[2] === 3);
|
||||
|
||||
a = new Array([1, 2, 3]);
|
||||
assert(a.length === 1);
|
||||
assert(a[0][0] === 1);
|
||||
assert(a[0][1] === 2);
|
||||
assert(a[0][2] === 3);
|
||||
a = new Array([1, 2, 3]);
|
||||
assert(a.length === 1);
|
||||
assert(a[0][0] === 1);
|
||||
assert(a[0][1] === 2);
|
||||
assert(a[0][2] === 3);
|
||||
|
||||
a = new Array(1, 2, 3);
|
||||
Object.defineProperty(a, 3, { get() { return 10; } });
|
||||
assert(a.toString() === "1,2,3,10");
|
||||
a = new Array(1, 2, 3);
|
||||
Object.defineProperty(a, 3, {
|
||||
get() {
|
||||
return 10;
|
||||
},
|
||||
});
|
||||
assert(a.toString() === "1,2,3,10");
|
||||
|
||||
[-1, -100, -0.1, 0.1, 1.23, Infinity, -Infinity, NaN].forEach(value => {
|
||||
assertThrowsError(() => {
|
||||
new Array(value);
|
||||
}, {
|
||||
error: TypeError,
|
||||
message: "Invalid array length"
|
||||
});
|
||||
});
|
||||
[-1, -100, -0.1, 0.1, 1.23, Infinity, -Infinity, NaN].forEach(value => {
|
||||
assertThrowsError(
|
||||
() => {
|
||||
new Array(value);
|
||||
},
|
||||
{
|
||||
error: TypeError,
|
||||
message: "Invalid array length",
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
console.log("PASS");
|
||||
console.log("PASS");
|
||||
} catch (e) {
|
||||
console.log("FAIL: " + e);
|
||||
console.log("FAIL: " + e);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue