mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:47:44 +00:00
LibJS: Skip undefined and null in join_array_with_separator()
This it being used in Array.prototype.{join,toString}() - and now adhering to the spec: [undefined, null].join() === ","
This commit is contained in:
parent
86810a4b02
commit
6d6cd64689
3 changed files with 10 additions and 2 deletions
|
@ -5,6 +5,11 @@ try {
|
|||
|
||||
assert(["hello", "friends"].join() === "hello,friends");
|
||||
assert(["hello", "friends"].join(" ") === "hello friends");
|
||||
assert([].join() === "");
|
||||
assert([null].join() === "");
|
||||
assert([undefined].join() === "");
|
||||
assert([undefined, null, ""].join() === ",,");
|
||||
assert([1, null, 2, undefined, 3].join() === "1,,2,,3");
|
||||
assert(Array(3).join() === ",,");
|
||||
|
||||
console.log("PASS");
|
||||
|
|
|
@ -8,6 +8,8 @@ try {
|
|||
|
||||
assert("rgb(" + [10, 11, 12] + ")" === "rgb(10,11,12)");
|
||||
|
||||
assert([undefined, null].toString() === ",");
|
||||
|
||||
a = new Array(5);
|
||||
assert(a.toString() === ",,,,");
|
||||
a[2] = "foo";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue