mirror of
https://github.com/wren-lang/wren.git
synced 2026-01-15 08:08:03 +01:00
"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:
@ -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.
|
||||
|
||||
Reference in New Issue
Block a user