1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:47:45 +00:00

LibJS: Make Array.prototype.lastIndexOf() generic

This commit is contained in:
Linus Groh 2020-05-22 18:24:18 +01:00 committed by Andreas Kling
parent 9b9b6a4cff
commit e78bc2f6fd
2 changed files with 22 additions and 12 deletions

View file

@ -52,6 +52,16 @@ try {
assert(Array.prototype.indexOf.call({ length: 5, 2: "foo", 4: "foo" }, "foo", 3) === 4);
}
{
assert(Array.prototype.lastIndexOf.call({}) === -1);
assert(Array.prototype.lastIndexOf.call({ 0: undefined }) === -1);
assert(Array.prototype.lastIndexOf.call({ length: 1, 0: undefined }) === 0);
assert(Array.prototype.lastIndexOf.call({ length: 1, 2: "foo" }, "foo") === -1);
assert(Array.prototype.lastIndexOf.call({ length: 5, 2: "foo" }, "foo") === 2);
assert(Array.prototype.lastIndexOf.call({ length: 5, 2: "foo", 4: "foo" }, "foo") === 4);
assert(Array.prototype.lastIndexOf.call({ length: 5, 2: "foo", 4: "foo" }, "foo", -2) === 2);
}
const o = { length: 5, 0: "foo", 1: "bar", 3: "baz" };
{