1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 06:17:35 +00:00

LibJS: Make Array.prototype.indexOf() generic

This commit is contained in:
Linus Groh 2020-05-22 17:42:20 +01:00 committed by Andreas Kling
parent 174ac5d348
commit 9b9b6a4cff
2 changed files with 22 additions and 16 deletions

View file

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