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:
+14
-14
@@ -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 non-true argument.
|
||||
IO.write(false && 1) // expect: false
|
||||
IO.write(true && 1) // expect: 1
|
||||
IO.write(1 && 2 && false) // expect: false
|
||||
IO.print(false && 1) // expect: false
|
||||
IO.print(true && 1) // expect: 1
|
||||
IO.print(1 && 2 && false) // expect: false
|
||||
|
||||
// Return the last argument if all are true.
|
||||
IO.write(1 && true) // expect: true
|
||||
IO.write(1 && 2 && 3) // expect: 3
|
||||
IO.print(1 && true) // expect: true
|
||||
IO.print(1 && 2 && 3) // expect: 3
|
||||
|
||||
// Short-circuit at the first false argument.
|
||||
IO.write(true) && // expect: true
|
||||
IO.write(false) && // expect: false
|
||||
IO.write(false) // should not print
|
||||
IO.print(true) && // expect: true
|
||||
IO.print(false) && // expect: false
|
||||
IO.print(false) // 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: true
|
||||
IO.write(null && true) // expect: true
|
||||
IO.write("" && true) // expect: true
|
||||
IO.write(false && true) // expect: false
|
||||
IO.print(0 && true) // expect: true
|
||||
IO.print(null && true) // expect: true
|
||||
IO.print("" && true) // expect: true
|
||||
IO.print(false && true) // expect: false
|
||||
|
||||
Reference in New Issue
Block a user