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:
@@ -1,6 +1,6 @@
|
||||
IO.write("".contains("")) // expect: true
|
||||
IO.write("anything".contains("")) // expect: true
|
||||
IO.write("something".contains("meth")) // expect: true
|
||||
IO.write("something".contains("some")) // expect: true
|
||||
IO.write("something".contains("ing")) // expect: true
|
||||
IO.write("something".contains("math")) // expect: false
|
||||
IO.print("".contains("")) // expect: true
|
||||
IO.print("anything".contains("")) // expect: true
|
||||
IO.print("something".contains("meth")) // expect: true
|
||||
IO.print("something".contains("some")) // expect: true
|
||||
IO.print("something".contains("ing")) // expect: true
|
||||
IO.print("something".contains("math")) // expect: false
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
IO.write("".count) // expect: 0
|
||||
IO.write("a string".count) // expect: 8
|
||||
IO.print("".count) // expect: 0
|
||||
IO.print("a string".count) // expect: 8
|
||||
|
||||
+14
-14
@@ -1,19 +1,19 @@
|
||||
IO.write("" == "") // expect: true
|
||||
IO.write("abcd" == "abcd") // expect: true
|
||||
IO.write("abcd" == "d") // expect: false
|
||||
IO.write("e" == "abcd") // expect: false
|
||||
IO.write("" == "abcd") // expect: false
|
||||
IO.print("" == "") // expect: true
|
||||
IO.print("abcd" == "abcd") // expect: true
|
||||
IO.print("abcd" == "d") // expect: false
|
||||
IO.print("e" == "abcd") // expect: false
|
||||
IO.print("" == "abcd") // expect: false
|
||||
|
||||
// Not equal to other types.
|
||||
IO.write("1" == 1) // expect: false
|
||||
IO.write("true" == true) // expect: false
|
||||
IO.print("1" == 1) // expect: false
|
||||
IO.print("true" == true) // expect: false
|
||||
|
||||
IO.write("" != "") // expect: false
|
||||
IO.write("abcd" != "abcd") // expect: false
|
||||
IO.write("abcd" != "d") // expect: true
|
||||
IO.write("e" != "abcd") // expect: true
|
||||
IO.write("" != "abcd") // expect: true
|
||||
IO.print("" != "") // expect: false
|
||||
IO.print("abcd" != "abcd") // expect: false
|
||||
IO.print("abcd" != "d") // expect: true
|
||||
IO.print("e" != "abcd") // expect: true
|
||||
IO.print("" != "abcd") // expect: true
|
||||
|
||||
// Not equal to other types.
|
||||
IO.write("1" != 1) // expect: true
|
||||
IO.write("true" != true) // expect: true
|
||||
IO.print("1" != 1) // expect: true
|
||||
IO.print("true" != true) // expect: true
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
// Escape characters.
|
||||
IO.write("\"") // expect: "
|
||||
IO.write("\\") // expect: \
|
||||
IO.write("(\n)") // expect: (
|
||||
IO.print("\"") // expect: "
|
||||
IO.print("\\") // expect: \
|
||||
IO.print("(\n)") // expect: (
|
||||
// expect: )
|
||||
|
||||
// TODO: Non-printing escapes like \t.
|
||||
// TODO: Unicode escape sequences.
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
IO.write("".count) // expect: 0
|
||||
IO.write("a string") // expect: a string
|
||||
IO.print("".count) // expect: 0
|
||||
IO.print("a string") // expect: a string
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
// Returns characters (as strings).
|
||||
IO.write("abcd"[0]) // expect: a
|
||||
IO.write("abcd"[1]) // expect: b
|
||||
IO.write("abcd"[2]) // expect: c
|
||||
IO.write("abcd"[3]) // expect: d
|
||||
IO.print("abcd"[0]) // expect: a
|
||||
IO.print("abcd"[1]) // expect: b
|
||||
IO.print("abcd"[2]) // expect: c
|
||||
IO.print("abcd"[3]) // expect: d
|
||||
|
||||
// Allows indexing backwards from the end.
|
||||
IO.write("abcd"[-4]) // expect: a
|
||||
IO.write("abcd"[-3]) // expect: b
|
||||
IO.write("abcd"[-2]) // expect: c
|
||||
IO.write("abcd"[-1]) // expect: d
|
||||
IO.print("abcd"[-4]) // expect: a
|
||||
IO.print("abcd"[-3]) // expect: b
|
||||
IO.print("abcd"[-2]) // expect: c
|
||||
IO.print("abcd"[-1]) // expect: d
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
IO.write("".toString == "") // expect: true
|
||||
IO.write("blah".toString == "blah") // expect: true
|
||||
IO.print("".toString == "") // expect: true
|
||||
IO.print("blah".toString == "blah") // expect: true
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
IO.write("s" is String) // expect: true
|
||||
IO.write("s" is Object) // expect: true
|
||||
IO.write("s" is Num) // expect: false
|
||||
IO.write("s".type == String) // expect: true
|
||||
IO.print("s" is String) // expect: true
|
||||
IO.print("s" is Object) // expect: true
|
||||
IO.print("s" is Num) // expect: false
|
||||
IO.print("s".type == String) // expect: true
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
// One byte UTF-8 Sequences.
|
||||
IO.print("\u0041") // expect: A
|
||||
IO.print("\u007e") // expect: ~
|
||||
|
||||
// Two byte sequences.
|
||||
IO.print("\u00b6") // expect: ¶
|
||||
IO.print("\u00de") // expect: Þ
|
||||
|
||||
// Three byte sequences.
|
||||
IO.print("\u0950") // expect: ॐ
|
||||
IO.print("\u0b83") // expect: ஃ
|
||||
|
||||
// Capitalized hex.
|
||||
IO.print("\u00B6") // expect: ¶
|
||||
IO.print("\u00DE") // expect: Þ
|
||||
|
||||
// TODO: Missing digits in escape.
|
||||
// TODO: Syntax for Unicode escapes > 0xffff?
|
||||
Reference in New Issue
Block a user