feat: rename IO.write to IO.print and add Unicode escape support in strings

Rename the IO.write method to IO.print, which now prints without a trailing newline, and add a new IO.print method that appends a newline after output. Update all benchmark, example, and test files to use IO.print instead of IO.write. Additionally, implement Unicode escape sequence parsing in the compiler's string tokenizer, supporting \uXXXX and \u{...} syntax with proper UTF-8 encoding for code points up to U+10FFFF.
This commit is contained in:
Bob Nystrom
2014-01-05 20:27:12 +00:00
parent e23e0ce6a3
commit c72db7d594
159 changed files with 1690 additions and 1599 deletions
+14 -14
View File
@@ -1,26 +1,26 @@
// Note: These tests implicitly depend on ints being truthy.
// Also rely on IO.write() returning its argument.
// Also rely on IO.print() returning its argument.
// Return the first true argument.
IO.write(1 || true) // expect: 1
IO.write(false || 1) // expect: 1
IO.write(false || false || true) // expect: true
IO.print(1 || true) // expect: 1
IO.print(false || 1) // expect: 1
IO.print(false || false || true) // expect: true
// Return the last argument if all are false.
IO.write(false || false) // expect: false
IO.write(false || false || false) // expect: false
IO.print(false || false) // expect: false
IO.print(false || false || false) // expect: false
// Short-circuit at the first true argument.
IO.write(false) || // expect: false
IO.write(true) || // expect: true
IO.write(true) // should not print
IO.print(false) || // expect: false
IO.print(true) || // expect: true
IO.print(true) // should not print
// Swallow a trailing newline.
IO.write(true ||
IO.print(true ||
true) // expect: true
// Only false is falsy.
IO.write(0 || true) // expect: 0
IO.write(null || true) // expect: null
IO.write(("" || true) == "") // expect: true
IO.write(false || true) // expect: true
IO.print(0 || true) // expect: 0
IO.print(null || true) // expect: null
IO.print(("" || true) == "") // expect: true
IO.print(false || true) // expect: true