mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 11:49:44 +00:00
LibJS: Reorganize tests into subfolders
This commit is contained in:
parent
21064a1883
commit
4c48c9d69d
Notes:
sideshowbarker
2024-07-19 05:13:22 +09:00
Author: https://github.com/mattco98
Commit: 4c48c9d69d
Pull-request: https://github.com/SerenityOS/serenity/pull/2681
Reviewed-by: https://github.com/linusg
213 changed files with 10 additions and 2 deletions
48
Libraries/LibJS/Tests/builtins/Array/array-length-setter.js
Normal file
48
Libraries/LibJS/Tests/builtins/Array/array-length-setter.js
Normal file
|
@ -0,0 +1,48 @@
|
|||
load("test-common.js");
|
||||
|
||||
try {
|
||||
var a = [1, 2, 3];
|
||||
|
||||
assert(a.length === 3);
|
||||
assert(a[0] === 1);
|
||||
assert(a[1] === 2);
|
||||
assert(a[2] === 3);
|
||||
|
||||
a.length = 5;
|
||||
assert(a.length === 5);
|
||||
assert(a[0] === 1);
|
||||
assert(a[1] === 2);
|
||||
assert(a[2] === 3);
|
||||
assert(a[3] === undefined);
|
||||
assert(a[4] === undefined);
|
||||
|
||||
a.length = 1;
|
||||
assert(a.length === 1);
|
||||
assert(a[0] === 1);
|
||||
|
||||
a.length = 0;
|
||||
assert(a.length === 0);
|
||||
|
||||
a.length = "42";
|
||||
assert(a.length === 42);
|
||||
|
||||
a.length = [];
|
||||
assert(a.length === 0);
|
||||
|
||||
a.length = true;
|
||||
assert(a.length === 1);
|
||||
|
||||
[undefined, "foo", -1, Infinity, -Infinity, NaN].forEach(value => {
|
||||
assertThrowsError(() => {
|
||||
a.length = value;
|
||||
}, {
|
||||
error: RangeError,
|
||||
message: "Invalid array length"
|
||||
});
|
||||
assert(a.length === 1);
|
||||
});
|
||||
|
||||
console.log("PASS");
|
||||
} catch (e) {
|
||||
console.log("FAIL: " + e);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue