mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 01:17:35 +00:00
LibJS: Handle empty values in Array.prototype.toString()
This commit is contained in:
parent
5c90cfa90f
commit
531335f57c
2 changed files with 8 additions and 1 deletions
|
@ -100,7 +100,8 @@ Value ArrayPrototype::to_string(Interpreter& interpreter)
|
|||
for (size_t i = 0; i < array->elements().size(); ++i) {
|
||||
if (i != 0)
|
||||
builder.append(',');
|
||||
builder.append(array->elements()[i].to_string());
|
||||
if (!array->elements()[i].is_empty())
|
||||
builder.append(array->elements()[i].to_string());
|
||||
}
|
||||
return js_string(interpreter, builder.to_string());
|
||||
}
|
||||
|
|
|
@ -6,6 +6,12 @@ try {
|
|||
|
||||
assert("rgb(" + [10, 11, 12] + ")" === "rgb(10,11,12)");
|
||||
|
||||
a = new Array(5);
|
||||
assert(a.toString() === ",,,,");
|
||||
a[2] = "foo";
|
||||
a[4] = "bar";
|
||||
assert(a.toString() === ",,foo,,bar");
|
||||
|
||||
console.log("PASS");
|
||||
} catch (e) {
|
||||
console.log("FAIL: " + e);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue