mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 01:07:36 +00:00
LibJS: Add Array.prototype.lastIndexOf
This commit is contained in:
parent
09138d542d
commit
b2305cb67d
3 changed files with 58 additions and 0 deletions
22
Libraries/LibJS/Tests/Array.prototype.lastIndexOf.js
Normal file
22
Libraries/LibJS/Tests/Array.prototype.lastIndexOf.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
load("test-common.js");
|
||||
|
||||
try {
|
||||
assert(Array.prototype.lastIndexOf.length === 1);
|
||||
|
||||
var array = [1, 2, 3, 1, "hello"];
|
||||
|
||||
assert(array.lastIndexOf("hello") === 4);
|
||||
assert(array.lastIndexOf(1) === 3);
|
||||
assert(array.lastIndexOf(1, -1) === -1);
|
||||
assert(array.lastIndexOf(1, -2) === 3);
|
||||
assert(array.lastIndexOf(2) === 1);
|
||||
assert(array.lastIndexOf(2, -3) === -1);
|
||||
assert(array.lastIndexOf(2, -4) === 1);
|
||||
assert([].lastIndexOf('hello') === -1);
|
||||
assert([].lastIndexOf('hello', 10) === -1);
|
||||
assert([].lastIndexOf('hello', -10) === -1);
|
||||
|
||||
console.log("PASS");
|
||||
} catch (e) {
|
||||
console.log("FAIL: " + e);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue