feat: make IO.write call toString on argument and add corelib with List.toString
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
// Handle empty list.
|
||||
IO.write([].toString) // expect: []
|
||||
|
||||
// Does not quote strings.
|
||||
IO.write([1, "2", true].toString) // expect: [1, 2, true]
|
||||
|
||||
// Nested lists.
|
||||
IO.write([1, [2, [3], 4], 5]) // expect: [1, [2, [3], 4], 5]
|
||||
|
||||
// Calls toString on elements.
|
||||
class Foo {
|
||||
toString { return "Foo.toString" }
|
||||
}
|
||||
|
||||
IO.write([1, new Foo, 2]) // expect: [1, Foo.toString, 2]
|
||||
|
||||
// TODO: Handle lists that contain themselves.
|
||||
Reference in New Issue
Block a user