"IO" -> "System".

Get rid of the separate opt-in IO class and replace it with a core
System class.

- Remove wren_io.c, wren_io.h, and io.wren.
- Remove the flags that disable it.
- Remove the overloads for print() with different arity. (It was an
  experiment, but I don't think it's that useful.)
- Remove IO.read(). That will reappear using libuv in the CLI at some
  point.
- Remove IO.time. Doesn't seem to have been used.
- Update all of the tests, docs, etc.

I'm sorry for all the breakage this causes, but I think "System" is a
better name for this class (it makes it natural to add things like
"System.gc()") and frees up "IO" for referring to the CLI's IO module.
This commit is contained in:
Bob Nystrom
2015-09-15 07:46:09 -07:00
parent 66b89a493f
commit 58e4d26648
491 changed files with 3285 additions and 3544 deletions
+1 -1
View File
@@ -3,4 +3,4 @@
// Chars: sø mé ஃ thî ng
var s = "søméஃthîng"
IO.print(s.bytes is StringByteSequence) // expect: true
System.print(s.bytes is StringByteSequence) // expect: true
+2 -2
View File
@@ -1,4 +1,4 @@
IO.print("a" + "b") // expect: ab
System.print("a" + "b") // expect: ab
// 8-bit clean.
IO.print(("a\0b" + "\0c") == "a\0b\0c") // expect: true
System.print(("a\0b" + "\0c") == "a\0b\0c") // expect: true
@@ -1 +1 @@
IO.print("a" + 123) // expect runtime error: Right operand must be a string.
System.print("a" + 123) // expect runtime error: Right operand must be a string.
+12 -12
View File
@@ -1,16 +1,16 @@
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
System.print("".contains("")) // expect: true
System.print("anything".contains("")) // expect: true
System.print("something".contains("meth")) // expect: true
System.print("something".contains("some")) // expect: true
System.print("something".contains("ing")) // expect: true
System.print("something".contains("math")) // expect: false
// Non-ASCII.
IO.print("søméthîng".contains("méth")) // expect: true
IO.print("søméthîng".contains("meth")) // expect: false
System.print("søméthîng".contains("méth")) // expect: true
System.print("søméthîng".contains("meth")) // expect: false
// 8-bit clean.
IO.print("a\0b\0c".contains("\0")) // expect: true
IO.print("a\0b\0c".contains("b")) // expect: true
IO.print("a\0b\0c".contains("b\0c")) // expect: true
IO.print("a\0b\0c".contains("bc")) // expect: false
System.print("a\0b\0c".contains("\0")) // expect: true
System.print("a\0b\0c".contains("b")) // expect: true
System.print("a\0b\0c".contains("b\0c")) // expect: true
System.print("a\0b\0c".contains("bc")) // expect: false
+8 -8
View File
@@ -1,18 +1,18 @@
IO.print("".count) // expect: 0
IO.print("a string".count) // expect: 8
System.print("".count) // expect: 0
System.print("a string".count) // expect: 8
// 8-bit clean.
IO.print("\0".count) // expect: 1
IO.print("a\0b".count) // expect: 3
IO.print("\0c".count) // expect: 2
IO.print(("a\0b" + "\0c").count) // expect: 5
System.print("\0".count) // expect: 1
System.print("a\0b".count) // expect: 3
System.print("\0c".count) // expect: 2
System.print(("a\0b" + "\0c").count) // expect: 5
// Treats a UTF-8 sequence as a single item.
//
// Bytes: 11111
// 012345678901234
// Chars: sø mé ஃ thî ng
IO.print("søméஃthîng".count) // expect: 10
System.print("søméஃthîng".count) // expect: 10
// Counts invalid UTF-8 one byte at a time.
IO.print("\xefok\xf7".count) // expect: 4
System.print("\xefok\xf7".count) // expect: 4
+11 -11
View File
@@ -1,15 +1,15 @@
IO.print("abcd".endsWith("cd")) // expect: true
IO.print("abcd".endsWith("abcde")) // expect: false
IO.print("abcd".endsWith("abcd")) // expect: true
IO.print("abcd".endsWith("f")) // expect: false
IO.print("abcd".endsWith("")) // expect: true
System.print("abcd".endsWith("cd")) // expect: true
System.print("abcd".endsWith("abcde")) // expect: false
System.print("abcd".endsWith("abcd")) // expect: true
System.print("abcd".endsWith("f")) // expect: false
System.print("abcd".endsWith("")) // expect: true
// Non-ASCII.
IO.print("søméthîng".endsWith("thîng")) // expect: true
IO.print("søméthîng".endsWith("thing")) // expect: false
System.print("søméthîng".endsWith("thîng")) // expect: true
System.print("søméthîng".endsWith("thing")) // expect: false
// 8-bit clean.
IO.print("a\0b\0c".endsWith("\0")) // expect: false
IO.print("a\0b\0c".endsWith("c")) // expect: true
IO.print("a\0b\0c".endsWith("\0c")) // expect: true
IO.print("a\0b\0c".endsWith("\0b")) // expect: false
System.print("a\0b\0c".endsWith("\0")) // expect: false
System.print("a\0b\0c".endsWith("c")) // expect: true
System.print("a\0b\0c".endsWith("\0c")) // expect: true
System.print("a\0b\0c".endsWith("\0b")) // expect: false
+1 -1
View File
@@ -1 +1 @@
IO.print("abcd".endsWith(null)) // expect runtime error: Argument must be a string.
System.print("abcd".endsWith(null)) // expect runtime error: Argument must be a string.
+19 -19
View File
@@ -1,28 +1,28 @@
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
System.print("" == "") // expect: true
System.print("abcd" == "abcd") // expect: true
System.print("abcd" == "d") // expect: false
System.print("e" == "abcd") // expect: false
System.print("" == "abcd") // expect: false
// Not equal to other types.
IO.print("1" == 1) // expect: false
IO.print("true" == true) // expect: false
System.print("1" == 1) // expect: false
System.print("true" == true) // expect: false
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
System.print("" != "") // expect: false
System.print("abcd" != "abcd") // expect: false
System.print("abcd" != "d") // expect: true
System.print("e" != "abcd") // expect: true
System.print("" != "abcd") // expect: true
// Not equal to other types.
IO.print("1" != 1) // expect: true
IO.print("true" != true) // expect: true
System.print("1" != 1) // expect: true
System.print("true" != true) // expect: true
// Non-ASCII.
IO.print("vålue" == "value") // expect: false
IO.print("vålue" == "vålue") // expect: true
System.print("vålue" == "value") // expect: false
System.print("vålue" == "vålue") // expect: true
// 8-bit clean.
IO.print("a\0b\0c" == "a") // expect: false
IO.print("a\0b\0c" == "abc") // expect: false
IO.print("a\0b\0c" == "a\0b\0c") // expect: true
System.print("a\0b\0c" == "a") // expect: false
System.print("a\0b\0c" == "abc") // expect: false
System.print("a\0b\0c" == "a\0b\0c") // expect: true
+5 -5
View File
@@ -1,5 +1,5 @@
IO.print(String.fromCodePoint(65)) // expect: A
IO.print(String.fromCodePoint(164)) // expect: ¤
IO.print(String.fromCodePoint(398)) // expect: Ǝ
IO.print(String.fromCodePoint(8225)) // expect: ‡
IO.print(String.fromCodePoint(0x254b)) // expect: ╋
System.print(String.fromCodePoint(65)) // expect: A
System.print(String.fromCodePoint(164)) // expect: ¤
System.print(String.fromCodePoint(398)) // expect: Ǝ
System.print(String.fromCodePoint(8225)) // expect: ‡
System.print(String.fromCodePoint(0x254b)) // expect: ╋
@@ -1 +1 @@
IO.print(String.fromCodePoint(12.34)) // expect runtime error: Code point must be an integer.
System.print(String.fromCodePoint(12.34)) // expect runtime error: Code point must be an integer.
@@ -1 +1 @@
IO.print(String.fromCodePoint("not num")) // expect runtime error: Code point must be a number.
System.print(String.fromCodePoint("not num")) // expect runtime error: Code point must be a number.
@@ -1,3 +1,3 @@
// UTF-8 mandates that only values up to 10ffff can be encoded.
// See: http://tools.ietf.org/html/rfc3629
IO.print(String.fromCodePoint(0x10ffff + 1)) // expect runtime error: Code point cannot be greater than 0x10ffff.
System.print(String.fromCodePoint(0x10ffff + 1)) // expect runtime error: Code point cannot be greater than 0x10ffff.
@@ -1 +1 @@
IO.print(String.fromCodePoint(-1)) // expect runtime error: Code point cannot be negative.
System.print(String.fromCodePoint(-1)) // expect runtime error: Code point cannot be negative.
+18 -18
View File
@@ -1,24 +1,24 @@
IO.print("abcd".indexOf("")) // expect: 0
IO.print("abcd".indexOf("cd")) // expect: 2
IO.print("abcd".indexOf("a")) // expect: 0
IO.print("abcd".indexOf("abcd")) // expect: 0
IO.print("abcd".indexOf("abcde")) // expect: -1
IO.print("abab".indexOf("ab")) // expect: 0
System.print("abcd".indexOf("")) // expect: 0
System.print("abcd".indexOf("cd")) // expect: 2
System.print("abcd".indexOf("a")) // expect: 0
System.print("abcd".indexOf("abcd")) // expect: 0
System.print("abcd".indexOf("abcde")) // expect: -1
System.print("abab".indexOf("ab")) // expect: 0
// More complex cases.
IO.print("abcdefabcdefg".indexOf("defg")) // expect: 9
IO.print("abcdabcdabcd".indexOf("dab")) // expect: 3
IO.print("abcdabcdabcdabcd".indexOf("dabcdabc")) // expect: 3
IO.print("abcdefg".indexOf("abcdef!")) // expect: -1
System.print("abcdefabcdefg".indexOf("defg")) // expect: 9
System.print("abcdabcdabcd".indexOf("dab")) // expect: 3
System.print("abcdabcdabcdabcd".indexOf("dabcdabc")) // expect: 3
System.print("abcdefg".indexOf("abcdef!")) // expect: -1
// Non-ASCII. Note that it returns byte indices, not code points.
IO.print("søméஃthîng".indexOf("e")) // expect: -1
IO.print("søméஃthîng".indexOf("m")) // expect: 3
IO.print("søméஃthîng".indexOf("thî")) // expect: 9
System.print("søméஃthîng".indexOf("e")) // expect: -1
System.print("søméஃthîng".indexOf("m")) // expect: 3
System.print("søméஃthîng".indexOf("thî")) // expect: 9
// 8-bit clean.
IO.print("a\0b\0c".indexOf("\0")) // expect: 1
IO.print("a\0b\0c".indexOf("a")) // expect: 0
IO.print("a\0b\0c".indexOf("b\0c")) // expect: 2
IO.print("a\0b\0c".indexOf("a\0b\0c\0d")) // expect: -1
IO.print("a\0b\0a\0b".indexOf("a\0b")) // expect: 0
System.print("a\0b\0c".indexOf("\0")) // expect: 1
System.print("a\0b\0c".indexOf("a")) // expect: 0
System.print("a\0b\0c".indexOf("b\0c")) // expect: 2
System.print("a\0b\0c".indexOf("a\0b\0c\0d")) // expect: -1
System.print("a\0b\0a\0b".indexOf("a\0b")) // expect: 0
+1 -1
View File
@@ -1 +1 @@
IO.print("abcd".indexOf(null)) // expect runtime error: Argument must be a string.
System.print("abcd".indexOf(null)) // expect runtime error: Argument must be a string.
+18 -18
View File
@@ -1,29 +1,29 @@
var s = "abçd"
IO.print(s.iterate(null)) // expect: 0
IO.print(s.iterate(0)) // expect: 1
IO.print(s.iterate(1)) // expect: 2
System.print(s.iterate(null)) // expect: 0
System.print(s.iterate(0)) // expect: 1
System.print(s.iterate(1)) // expect: 2
// Skip 3 because that's the middle of the ç sequence.
IO.print(s.iterate(2)) // expect: 4
System.print(s.iterate(2)) // expect: 4
// Iterating from the middle of a UTF-8 sequence goes to the next one.
IO.print(s.iterate(3)) // expect: 4
IO.print(s.iterate(4)) // expect: false
System.print(s.iterate(3)) // expect: 4
System.print(s.iterate(4)) // expect: false
// Out of bounds.
IO.print(s.iterate(123)) // expect: false
IO.print(s.iterate(-1)) // expect: false
System.print(s.iterate(123)) // expect: false
System.print(s.iterate(-1)) // expect: false
// Nothing to iterate in an empty string.
IO.print("".iterate(null)) // expect: false
System.print("".iterate(null)) // expect: false
// 8-bit clean.
IO.print("a\0b\0c".iterate(null)) // expect: 0
IO.print("a\0b\0c".iterate(0)) // expect: 1
IO.print("a\0b\0c".iterate(1)) // expect: 2
IO.print("a\0b\0c".iterate(2)) // expect: 3
IO.print("a\0b\0c".iterate(3)) // expect: 4
IO.print("a\0b\0c".iterate(4)) // expect: false
System.print("a\0b\0c".iterate(null)) // expect: 0
System.print("a\0b\0c".iterate(0)) // expect: 1
System.print("a\0b\0c".iterate(1)) // expect: 2
System.print("a\0b\0c".iterate(2)) // expect: 3
System.print("a\0b\0c".iterate(3)) // expect: 4
System.print("a\0b\0c".iterate(4)) // expect: false
// Iterates over invalid UTF-8 one byte at a time.
IO.print("\xef\xf7".iterate(null)) // expect: 0
IO.print("\xef\xf7".iterate(0)) // expect: 1
IO.print("\xef\xf7".iterate(1)) // expect: false
System.print("\xef\xf7".iterate(null)) // expect: 0
System.print("\xef\xf7".iterate(0)) // expect: 1
System.print("\xef\xf7".iterate(1)) // expect: false
+12 -12
View File
@@ -1,19 +1,19 @@
var s = "abçd"
IO.print(s.iteratorValue(0)) // expect: a
IO.print(s.iteratorValue(1)) // expect: b
IO.print(s.iteratorValue(2)) // expect: ç
System.print(s.iteratorValue(0)) // expect: a
System.print(s.iteratorValue(1)) // expect: b
System.print(s.iteratorValue(2)) // expect: ç
// Iterator value in middle of UTF sequence is the unencoded byte.
IO.print(s.iteratorValue(3) == "\xa7") // expect: true
IO.print(s.iteratorValue(4)) // expect: d
System.print(s.iteratorValue(3) == "\xa7") // expect: true
System.print(s.iteratorValue(4)) // expect: d
// 8-bit clean.
var t = "a\0b\0c"
IO.print(t.iteratorValue(0) == "a") // expect: true
IO.print(t.iteratorValue(1) == "\0") // expect: true
IO.print(t.iteratorValue(2) == "b") // expect: true
IO.print(t.iteratorValue(3) == "\0") // expect: true
IO.print(t.iteratorValue(4) == "c") // expect: true
System.print(t.iteratorValue(0) == "a") // expect: true
System.print(t.iteratorValue(1) == "\0") // expect: true
System.print(t.iteratorValue(2) == "b") // expect: true
System.print(t.iteratorValue(3) == "\0") // expect: true
System.print(t.iteratorValue(4) == "c") // expect: true
// Returns single byte strings for invalid UTF-8 sequences.
IO.print("\xef\xf7".iteratorValue(0) == "\xef") // expect: true
IO.print("\xef\xf7".iteratorValue(1) == "\xf7") // expect: true
System.print("\xef\xf7".iteratorValue(0) == "\xef") // expect: true
System.print("\xef\xf7".iteratorValue(1) == "\xf7") // expect: true
+4 -4
View File
@@ -1,10 +1,10 @@
var str = "string"
IO.print(str.join("") == str) // expect: true
System.print(str.join("") == str) // expect: true
IO.print(str.join(", ")) // expect: s, t, r, i, n, g
System.print(str.join(", ")) // expect: s, t, r, i, n, g
// 8-bit clean.
var ing = "a\0b\0c"
IO.print(ing.join("") == ing) // expect: true
IO.print(ing.join(", ") == "a, \0, b, \0, c") // expect: true
System.print(ing.join("") == ing) // expect: true
System.print(ing.join(", ") == "a, \0, b, \0, c") // expect: true
+2 -2
View File
@@ -1,2 +1,2 @@
IO.print(!"s") // expect: false
IO.print(!"") // expect: false
System.print(!"s") // expect: false
System.print(!"") // expect: false
+10 -10
View File
@@ -1,14 +1,14 @@
IO.print("abcd".startsWith("cd")) // expect: false
IO.print("abcd".startsWith("a")) // expect: true
IO.print("abcd".startsWith("abcd")) // expect: true
IO.print("abcd".startsWith("abcde")) // expect: false
IO.print("abcd".startsWith("")) // expect: true
System.print("abcd".startsWith("cd")) // expect: false
System.print("abcd".startsWith("a")) // expect: true
System.print("abcd".startsWith("abcd")) // expect: true
System.print("abcd".startsWith("abcde")) // expect: false
System.print("abcd".startsWith("")) // expect: true
// Non-ASCII.
IO.print("søméthîng".startsWith("sømé")) // expect: true
IO.print("søméthîng".startsWith("some")) // expect: false
System.print("søméthîng".startsWith("sømé")) // expect: true
System.print("søméthîng".startsWith("some")) // expect: false
// 8-bit clean.
IO.print("a\0b\0c".startsWith("a")) // expect: true
IO.print("a\0b\0c".startsWith("a\0")) // expect: true
IO.print("a\0b\0c".startsWith("b\0")) // expect: false
System.print("a\0b\0c".startsWith("a")) // expect: true
System.print("a\0b\0c".startsWith("a\0")) // expect: true
System.print("a\0b\0c".startsWith("b\0")) // expect: false
@@ -1 +1 @@
IO.print("abcd".startsWith(null)) // expect runtime error: Argument must be a string.
System.print("abcd".startsWith(null)) // expect runtime error: Argument must be a string.
+29 -29
View File
@@ -1,46 +1,46 @@
// Returns characters (as strings).
IO.print("abcd"[0]) // expect: a
IO.print("abcd"[1]) // expect: b
IO.print("abcd"[2]) // expect: c
IO.print("abcd"[3]) // expect: d
System.print("abcd"[0]) // expect: a
System.print("abcd"[1]) // expect: b
System.print("abcd"[2]) // expect: c
System.print("abcd"[3]) // expect: d
// Allows indexing backwards from the end.
IO.print("abcd"[-4]) // expect: a
IO.print("abcd"[-3]) // expect: b
IO.print("abcd"[-2]) // expect: c
IO.print("abcd"[-1]) // expect: d
System.print("abcd"[-4]) // expect: a
System.print("abcd"[-3]) // expect: b
System.print("abcd"[-2]) // expect: c
System.print("abcd"[-1]) // expect: d
// Regression: Make sure the string's internal buffer size is correct.
IO.print("abcd"[1] == "b") // expect: true
System.print("abcd"[1] == "b") // expect: true
// Indexes by byte, not code point.
//
// Bytes: 11111
// 012345678901234
// Chars: sø mé ஃ thî ng
IO.print("søméஃthîng"[0]) // expect: s
IO.print("søméஃthîng"[1]) // expect: ø
IO.print("søméஃthîng"[3]) // expect: m
IO.print("søméஃthîng"[6]) // expect: ஃ
IO.print("søméஃthîng"[10]) // expect: h
IO.print("søméஃthîng"[-1]) // expect: g
IO.print("søméஃthîng"[-2]) // expect: n
IO.print("søméஃthîng"[-4]) // expect: î
System.print("søméஃthîng"[0]) // expect: s
System.print("søméஃthîng"[1]) // expect: ø
System.print("søméஃthîng"[3]) // expect: m
System.print("søméஃthîng"[6]) // expect: ஃ
System.print("søméஃthîng"[10]) // expect: h
System.print("søméஃthîng"[-1]) // expect: g
System.print("søméஃthîng"[-2]) // expect: n
System.print("søméஃthîng"[-4]) // expect: î
// If the subscript is in the middle of a UTF-8 sequence, return the raw byte.
IO.print("søméஃthîng"[2] == "\xb8") // expect: true
IO.print("søméஃthîng"[7] == "\xae") // expect: true
IO.print("søméஃthîng"[8] == "\x83") // expect: true
IO.print("søméஃ"[-1] == "\x83") // expect: true
IO.print("søméஃ"[-2] == "\xae") // expect: true
System.print("søméஃthîng"[2] == "\xb8") // expect: true
System.print("søméஃthîng"[7] == "\xae") // expect: true
System.print("søméஃthîng"[8] == "\x83") // expect: true
System.print("søméஃ"[-1] == "\x83") // expect: true
System.print("søméஃ"[-2] == "\xae") // expect: true
// 8-bit clean.
IO.print("a\0b\0c"[0] == "a") // expect: true
IO.print("a\0b\0c"[1] == "\0") // expect: true
IO.print("a\0b\0c"[2] == "b") // expect: true
IO.print("a\0b\0c"[3] == "\0") // expect: true
IO.print("a\0b\0c"[4] == "c") // expect: true
System.print("a\0b\0c"[0] == "a") // expect: true
System.print("a\0b\0c"[1] == "\0") // expect: true
System.print("a\0b\0c"[2] == "b") // expect: true
System.print("a\0b\0c"[3] == "\0") // expect: true
System.print("a\0b\0c"[4] == "c") // expect: true
// Returns single byte strings for invalid UTF-8 sequences.
IO.print("\xef\xf7"[0] == "\xef") // expect: true
IO.print("\xef\xf7"[1] == "\xf7") // expect: true
System.print("\xef\xf7"[0] == "\xef") // expect: true
System.print("\xef\xf7"[1] == "\xf7") // expect: true
+28 -28
View File
@@ -1,49 +1,49 @@
var string = "abcde"
IO.print(string[0..0]) // expect: a
IO.print(string[1...1] == "") // expect: true
IO.print(string[1..2]) // expect: bc
IO.print(string[1...2]) // expect: b
IO.print(string[2..4]) // expect: cde
IO.print(string[2...5]) // expect: cde
System.print(string[0..0]) // expect: a
System.print(string[1...1] == "") // expect: true
System.print(string[1..2]) // expect: bc
System.print(string[1...2]) // expect: b
System.print(string[2..4]) // expect: cde
System.print(string[2...5]) // expect: cde
// A backwards range reverses.
IO.print(string[3..1]) // expect: dcb
IO.print(string[3...1]) // expect: dc
IO.print(string[3...3] == "") // expect: true
System.print(string[3..1]) // expect: dcb
System.print(string[3...1]) // expect: dc
System.print(string[3...3] == "") // expect: true
// Negative ranges index from the end.
IO.print(string[-5..-2]) // expect: abcd
IO.print(string[-5...-2]) // expect: abc
IO.print(string[-3..-5]) // expect: cba
IO.print(string[-3...-6]) // expect: cba
System.print(string[-5..-2]) // expect: abcd
System.print(string[-5...-2]) // expect: abc
System.print(string[-3..-5]) // expect: cba
System.print(string[-3...-6]) // expect: cba
// Half-negative ranges are treated like the negative value is fixed before
// walking the range.
IO.print(string[-5..3]) // expect: abcd
IO.print(string[-3...5]) // expect: cde
IO.print(string[-2..1]) // expect: dcb
IO.print(string[-2...0]) // expect: dcb
System.print(string[-5..3]) // expect: abcd
System.print(string[-3...5]) // expect: cde
System.print(string[-2..1]) // expect: dcb
System.print(string[-2...0]) // expect: dcb
IO.print(string[1..-2]) // expect: bcd
IO.print(string[2...-1]) // expect: cd
IO.print(string[4..-5]) // expect: edcba
IO.print(string[3...-6]) // expect: dcba
System.print(string[1..-2]) // expect: bcd
System.print(string[2...-1]) // expect: cd
System.print(string[4..-5]) // expect: edcba
System.print(string[3...-6]) // expect: dcba
// An empty range at zero is allowed on an empty string.
IO.print(""[0...0] == "") // expect: true
IO.print(""[0..-1] == "") // expect: true
System.print(""[0...0] == "") // expect: true
System.print(""[0..-1] == "") // expect: true
// Indexes by byte, not code point.
//
// Bytes: 11111
// 012345678901234
// Chars: sø mé ஃ thî ng
IO.print("søméஃthîng"[0..3]) // expect: søm
IO.print("søméஃthîng"[3...10]) // expect: méஃt
System.print("søméஃthîng"[0..3]) // expect: søm
System.print("søméஃthîng"[3...10]) // expect: méஃt
// Only includes sequences whose first byte is in the range.
IO.print("søméஃthîng"[2..6]) // expect: méஃ
IO.print("søméஃthîng"[2...6]) // expect: mé
IO.print("søméஃthîng"[2...7]) // expect: méஃ
System.print("søméஃthîng"[2..6]) // expect: méஃ
System.print("søméஃthîng"[2...6]) // expect: mé
System.print("søméஃthîng"[2...7]) // expect: méஃ
// TODO: Strings including invalid UTF-8.
+5 -5
View File
@@ -1,7 +1,7 @@
IO.print("".toString == "") // expect: true
IO.print("blah".toString == "blah") // expect: true
System.print("".toString == "") // expect: true
System.print("blah".toString == "blah") // expect: true
// 8-bit clean.
IO.print("a\0b\0c".toString == "a\0b\0c") // expect: true
IO.print("a\0b\0c".toString == "a") // expect: false
IO.print("a\0b\0c".toString) // expect: a
System.print("a\0b\0c".toString == "a\0b\0c") // expect: true
System.print("a\0b\0c".toString == "a") // expect: false
System.print("a\0b\0c".toString) // expect: a
+4 -4
View File
@@ -1,4 +1,4 @@
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
System.print("s" is String) // expect: true
System.print("s" is Object) // expect: true
System.print("s" is Num) // expect: false
System.print("s".type == String) // expect: true