diff options
Diffstat (limited to 'test-suite/tests/chars.test')
-rw-r--r-- | test-suite/tests/chars.test | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/test-suite/tests/chars.test b/test-suite/tests/chars.test index cd1572feb..90114992f 100644 --- a/test-suite/tests/chars.test +++ b/test-suite/tests/chars.test @@ -295,3 +295,65 @@ (with-output-to-string (lambda () (write #\soh))) "#\\soh")))) +(with-test-prefix "r6rs char handling" + + (read-enable 'strict-r6rs-strings) + + (pass-if "#\\a" + (eqv? (read (open-input-string "#\\a")) (integer->char #x61))) + + (pass-if "#\\A" + (eqv? (with-input-from-string "#\\A" read) (integer->char #x41))) + + (pass-if "#\\(" + (eqv? (with-input-from-string "#\\(" read) (integer->char #x28))) + + (pass-if "#\\(space)" + (eqv? (with-input-from-string "#\\ " read) (integer->char #x20))) + + (pass-if "R6RS character names" + (and + (eqv? (with-input-from-string "#\\nul" read) (integer->char #x00)) + (eqv? (with-input-from-string "#\\alarm" read) (integer->char #x07)) + (eqv? (with-input-from-string "#\\backspace" read) (integer->char #x08)) + (eqv? (with-input-from-string "#\\tab" read) (integer->char #x09)) + (eqv? (with-input-from-string "#\\linefeed" read) (integer->char #x0A)) + (eqv? (with-input-from-string "#\\newline" read) (integer->char #x0A)) + (eqv? (with-input-from-string "#\\vtab" read) (integer->char #x0B)) + (eqv? (with-input-from-string "#\\page" read) (integer->char #x0C)) + (eqv? (with-input-from-string "#\\return" read) (integer->char #x0D)) + (eqv? (with-input-from-string "#\\esc" read) (integer->char #x1B)) + (eqv? (with-input-from-string "#\\space" read) (integer->char #x20)) + (eqv? (with-input-from-string "#\\delete" read) (integer->char #x7F)))) + + (pass-if-exception "R6RS bad charname" exception:unknown-character-name + (with-input-from-string "#\\blammo" read)) + + (pass-if-exception "R6RS charnames are case sensitive" + exception:unknown-character-name + (with-input-from-string "#\\Backspace" read)) + + (pass-if "one-digit hex escape" + (eqv? (with-input-from-string "#\\xA" read) (integer->char #x0A))) + + (pass-if "two-digit hex escape" + (eqv? (with-input-from-string "#\\xFF" read) (integer->char #xFF))) + + (pass-if "four-digit hex escape" + (eqv? (with-input-from-string "#\\x0001" read) (integer->char #x01))) + + (pass-if "eight-digit hex escape" + (eqv? (with-input-from-string "#\\x00006587" read) (integer->char #x6587))) + + (pass-if "write R6RS character names" + (string=? + (with-output-to-string (lambda () (write (integer->char #x07)))) + "#\\alarm")) + + (pass-if "write R6RS escapes" + (string=? + (with-output-to-string (lambda () (write (integer->char #x80)))) + "#\\x80")) + + (read-disable 'strict-r6rs-strings)) + |