1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 18:27:39 +00:00

LibJS: Add Array.prototype.toLocaleString()

This commit is contained in:
Linus Groh 2020-05-28 19:42:21 +01:00 committed by Andreas Kling
parent 70d2add22f
commit 1dd44210b7
3 changed files with 57 additions and 0 deletions

View file

@ -0,0 +1,24 @@
load("test-common.js");
try {
assert(Array.prototype.toLocaleString.length === 0);
assert([].toLocaleString() === "");
assert(["foo"].toLocaleString() === "foo");
assert(["foo", "bar"].toLocaleString() === "foo,bar");
assert(["foo", undefined, "bar", null, "baz"].toLocaleString() === "foo,,bar,,baz");
var toStringCalled = 0;
var o = {
toString: () => {
toStringCalled++;
return "o";
}
};
assert([o, undefined, o, null, o].toLocaleString() === "o,,o,,o");
assert(toStringCalled === 3);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}