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:
parent
70d2add22f
commit
1dd44210b7
3 changed files with 57 additions and 0 deletions
24
Libraries/LibJS/Tests/Array.prototype.toLocaleString.js
Normal file
24
Libraries/LibJS/Tests/Array.prototype.toLocaleString.js
Normal 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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue