Clean up text handling a bit:

- Rename IO.write -> IO.print.
- Make IO.write not print a newline.
- Support \u Unicode escapes in strings.
This commit is contained in:
Bob Nystrom
2014-01-05 12:27:12 -08:00
parent 870f3b8b93
commit b979272305
159 changed files with 1690 additions and 1599 deletions
+4 -4
View File
@@ -1,17 +1,17 @@
// Handle empty list.
IO.write([].toString) // expect: []
IO.print([].toString) // expect: []
// Does not quote strings.
IO.write([1, "2", true].toString) // expect: [1, 2, true]
IO.print([1, "2", true].toString) // expect: [1, 2, true]
// Nested lists.
IO.write([1, [2, [3], 4], 5]) // expect: [1, [2, [3], 4], 5]
IO.print([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]
IO.print([1, new Foo, 2]) // expect: [1, Foo.toString, 2]
// TODO: Handle lists that contain themselves.