mirror of
https://github.com/wren-lang/wren.git
synced 2026-01-16 20:28:04 +01:00
24 lines
605 B
Plaintext
24 lines
605 B
Plaintext
// Handle empty list.
|
|
IO.print([].join(",") == "") // expect: true
|
|
|
|
// Handle a simple list with an empty delimeter.
|
|
IO.print([1, 2, 3].join("")) // expect: 123
|
|
|
|
// Handle a simple list with no separator.
|
|
IO.print([1, 2, 3].join) // expect: 123
|
|
|
|
// Does not quote strings.
|
|
IO.print([1, "2", true].join(",")) // expect: 1,2,true
|
|
|
|
// Nested lists.
|
|
IO.print([1, [2, [3], 4], 5].join(",")) // expect: 1,[2, [3], 4],5
|
|
|
|
// Calls toString on elements.
|
|
class Foo {
|
|
toString { "Foo.toString" }
|
|
}
|
|
|
|
IO.print([1, new Foo, 2].join(", ")) // expect: 1, Foo.toString, 2
|
|
|
|
// TODO: Handle lists that contain themselves.
|