mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:47:34 +00:00
LibJS: Add Array.prototype.indexOf
This commit is contained in:
parent
d3e3f5b421
commit
579975fd1e
3 changed files with 59 additions and 1 deletions
24
Libraries/LibJS/Tests/Array.prototype.indexOf.js
Normal file
24
Libraries/LibJS/Tests/Array.prototype.indexOf.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
load("test-common.js");
|
||||
|
||||
try {
|
||||
assert(Array.prototype.indexOf.length === 1);
|
||||
|
||||
var array = ['hello', 'friends', 1, 2, false];
|
||||
|
||||
assert(array.indexOf('hello') === 0);
|
||||
assert(array.indexOf('friends') === 1);
|
||||
assert(array.indexOf(false) === 4);
|
||||
assert(array.indexOf(false, 2) === 4);
|
||||
assert(array.indexOf(false, -2) === 4);
|
||||
assert(array.indexOf(1) === 2);
|
||||
assert(array.indexOf(1, 1000) === -1);
|
||||
assert(array.indexOf(1, -1000) === 2);
|
||||
assert(array.indexOf('serenity') === -1);
|
||||
assert([].indexOf('serenity') === -1);
|
||||
assert([].indexOf('serenity', 10) === -1);
|
||||
assert([].indexOf('serenity', -10) === -1);
|
||||
|
||||
console.log("PASS");
|
||||
} catch (e) {
|
||||
console.log("FAIL: " + e);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue