feat: replace IO class with System class and remove separate IO module

- Delete wren_io.c, wren_io.h, and io.wren source files
- Remove multi-arity print overloads and IO.read/IO.time methods
- Add System class with print, printAll, write, writeAll methods to core.wren
- Update all documentation examples and README to use System.print instead of IO.print
This commit is contained in:
Bob Nystrom
2015-09-15 14:46:09 +00:00
parent f12581a674
commit aa72900a9e
491 changed files with 3285 additions and 3544 deletions
+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