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
+2 -2
View File
@@ -4,5 +4,5 @@ class Foo {
// Classes inherit the argument-less "new" one by default.
var foo = new Foo
IO.write(foo is Foo) // expect: true
IO.write(foo.toString) // expect: Foo
IO.print(foo is Foo) // expect: true
IO.print(foo.toString) // expect: Foo
+1 -1
View File
@@ -2,6 +2,6 @@ class Foo {
+ other { return "Foo " + other }
}
IO.write(new Foo + "value") // expect: Foo value
IO.print(new Foo + "value") // expect: Foo value
// TODO: Other expressions following a constructor, like new Foo.bar("arg").
+5 -5
View File
@@ -1,7 +1,7 @@
class Foo {
new { IO.write("zero") }
new(a) { IO.write(a) }
new(a, b) { IO.write(a + b) }
new { IO.print("zero") }
new(a) { IO.print(a) }
new(a, b) { IO.print(a + b) }
toString { return "Foo" }
}
@@ -13,5 +13,5 @@ new Foo("one", "two") // expect: onetwo
// Returns the new instance.
var foo = new Foo // expect: zero
IO.write(foo is Foo) // expect: true
IO.write(foo.toString) // expect: Foo
IO.print(foo is Foo) // expect: true
IO.print(foo.toString) // expect: Foo
+9 -9
View File
@@ -1,6 +1,6 @@
class A {
new(arg) {
IO.write("new A " + arg)
IO.print("new A " + arg)
_field = arg
}
@@ -10,7 +10,7 @@ class A {
class B is A {
new(arg1, arg2) {
super(arg2)
IO.write("new B " + arg1)
IO.print("new B " + arg1)
_field = arg1
}
@@ -20,7 +20,7 @@ class B is A {
class C is B {
new {
super("one", "two")
IO.write("new C")
IO.print("new C")
_field = "c"
}
@@ -31,10 +31,10 @@ var c = new C
// expect: new A two
// expect: new B one
// expect: new C
IO.write(c is A) // expect: true
IO.write(c is B) // expect: true
IO.write(c is C) // expect: true
IO.print(c is A) // expect: true
IO.print(c is B) // expect: true
IO.print(c is C) // expect: true
IO.write(c.aField) // expect: two
IO.write(c.bField) // expect: one
IO.write(c.cField) // expect: c
IO.print(c.aField) // expect: two
IO.print(c.bField) // expect: one
IO.print(c.cField) // expect: c