1
0
forked from Mirror/wren
Files
wren/test/list/to_string.wren
Bob Nystrom da4cadf16b Unify body handling.
Blocks, functions, and methods now have the same code for handling
their bodies.

This means that single-line methods work like single-line functions:
they return the result of their expression.
2014-04-03 07:48:19 -07:00

18 lines
418 B
Plaintext

// Handle empty list.
IO.print([].toString) // expect: []
// Does not quote strings.
IO.print([1, "2", true].toString) // expect: [1, 2, true]
// Nested lists.
IO.print([1, [2, [3], 4], 5]) // expect: [1, [2, [3], 4], 5]
// Calls toString on elements.
class Foo {
toString { "Foo.toString" }
}
IO.print([1, new Foo, 2]) // expect: [1, Foo.toString, 2]
// TODO: Handle lists that contain themselves.