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
+17 -17
View File
@@ -19,20 +19,20 @@ class Foo {
}
var foo = new Foo
IO.write(foo.method) // expect: 0
IO.write(foo.method(1)) // expect: 1
IO.write(foo.method(1, 2)) // expect: 3
IO.write(foo.method(1, 2, 3)) // expect: 6
IO.write(foo.method(1, 2, 3, 4)) // expect: 10
IO.write(foo.method(1, 2, 3, 4, 5)) // expect: 15
IO.write(foo.method(1, 2, 3, 4, 5, 6)) // expect: 21
IO.write(foo.method(1, 2, 3, 4, 5, 6, 7)) // expect: 28
IO.write(foo.method(1, 2, 3, 4, 5, 6, 7, 8)) // expect: 36
IO.write(foo.method(1, 2, 3, 4, 5, 6, 7, 8, 9)) // expect: 45
IO.write(foo.method(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) // expect: 55
IO.write(foo.method(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)) // expect: 66
IO.write(foo.method(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)) // expect: 78
IO.write(foo.method(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)) // expect: 91
IO.write(foo.method(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)) // expect: 105
IO.write(foo.method(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)) // expect: 120
IO.write(foo.method(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)) // expect: 136
IO.print(foo.method) // expect: 0
IO.print(foo.method(1)) // expect: 1
IO.print(foo.method(1, 2)) // expect: 3
IO.print(foo.method(1, 2, 3)) // expect: 6
IO.print(foo.method(1, 2, 3, 4)) // expect: 10
IO.print(foo.method(1, 2, 3, 4, 5)) // expect: 15
IO.print(foo.method(1, 2, 3, 4, 5, 6)) // expect: 21
IO.print(foo.method(1, 2, 3, 4, 5, 6, 7)) // expect: 28
IO.print(foo.method(1, 2, 3, 4, 5, 6, 7, 8)) // expect: 36
IO.print(foo.method(1, 2, 3, 4, 5, 6, 7, 8, 9)) // expect: 45
IO.print(foo.method(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) // expect: 55
IO.print(foo.method(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)) // expect: 66
IO.print(foo.method(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)) // expect: 78
IO.print(foo.method(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)) // expect: 91
IO.print(foo.method(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)) // expect: 105
IO.print(foo.method(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)) // expect: 120
IO.print(foo.method(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)) // expect: 136
+1 -1
View File
@@ -2,4 +2,4 @@ class Foo {
bar {}
}
IO.write((new Foo).bar) // expect: null
IO.print((new Foo).bar) // expect: null
+1 -1
View File
@@ -4,4 +4,4 @@ class Foo {
}
}
IO.write((new Foo).thisHasAMethodNameThatIsExactly64CharactersLongWhichIsTheMaximum) // expect: result
IO.print((new Foo).thisHasAMethodNameThatIsExactly64CharactersLongWhichIsTheMaximum) // expect: result
+1 -1
View File
@@ -2021,4 +2021,4 @@ result = result + foo.method996
result = result + foo.method997
result = result + foo.method998
result = result + foo.method999
IO.write(result) // expect: 1000
IO.print(result) // expect: 1000
+13 -13
View File
@@ -16,16 +16,16 @@ class Foo {
}
var foo = new Foo
IO.write(foo + "a") // expect: infix + a
IO.write(foo - "a") // expect: infix - a
IO.write(foo * "a") // expect: infix * a
IO.write(foo / "a") // expect: infix / a
IO.write(foo % "a") // expect: infix % a
IO.write(foo < "a") // expect: infix < a
IO.write(foo > "a") // expect: infix > a
IO.write(foo <= "a") // expect: infix <= a
IO.write(foo >= "a") // expect: infix >= a
IO.write(foo == "a") // expect: infix == a
IO.write(foo != "a") // expect: infix != a
IO.write(!foo) // expect: prefix !
IO.write(-foo) // expect: prefix -
IO.print(foo + "a") // expect: infix + a
IO.print(foo - "a") // expect: infix - a
IO.print(foo * "a") // expect: infix * a
IO.print(foo / "a") // expect: infix / a
IO.print(foo % "a") // expect: infix % a
IO.print(foo < "a") // expect: infix < a
IO.print(foo > "a") // expect: infix > a
IO.print(foo <= "a") // expect: infix <= a
IO.print(foo >= "a") // expect: infix >= a
IO.print(foo == "a") // expect: infix == a
IO.print(foo != "a") // expect: infix != a
IO.print(!foo) // expect: prefix !
IO.print(-foo) // expect: prefix -
+4 -4
View File
@@ -6,7 +6,7 @@ class Foo {
static bar(arg) { return "on metaclass " + arg }
}
IO.write((new Foo).bar) // expect: on instance
IO.write(Foo.bar) // expect: on metaclass
IO.write((new Foo).bar("arg")) // expect: on instance arg
IO.write(Foo.bar("arg")) // expect: on metaclass arg
IO.print((new Foo).bar) // expect: on instance
IO.print(Foo.bar) // expect: on metaclass
IO.print((new Foo).bar("arg")) // expect: on instance arg
IO.print(Foo.bar("arg")) // expect: on metaclass arg
+1 -1
View File
@@ -1 +1 @@
IO.write(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17) // expect error
IO.print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17) // expect error