Make IO.write() call toString on its argument.

This commit is contained in:
Bob Nystrom
2013-12-22 11:50:00 -08:00
parent 2ec01c558f
commit 7868287f89
6 changed files with 130 additions and 12 deletions
+17
View File
@@ -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.