ikarus/scheme/tests/reader.ss

110 lines
2.9 KiB
Scheme
Raw Normal View History

(library (tests reader)
2008-10-18 13:03:17 -04:00
(export run-tests)
(import (ikarus) (tests framework))
(define t
(lambda (str)
(lambda (n?)
(and (number? n?)
2007-12-10 09:28:48 -05:00
(= (read (open-string-input-port str)) n?)))))
(define-syntax reader-tests
(syntax-rules ()
[(_ name str* ...)
(define-tests name
[(t str*) (string->number str*)] ...)]))
(reader-tests test-reader
"12"
"+12"
"3427384783264876238746784234"
"0"
"+0"
"-12"
"-3498738947983748939478347834"
"-0"
"#x-238973897AAAAAFFFFbb00bbdddcc"
"#x238973897AAAAA000FFFFbbbbdddcc"
"#x+07edf387"
"#x+0"
"#x-0"
"#x0"
"#b01010101010000000111111111110000"
"#b-01010101010000000111111111110000"
"#b+01010101010000000111111111110000"
"#b+0"
"#b-0"
"#b0"
"#d2398128321308912830912830912839"
"#d-2398128321308912830912830912839"
"#d+2398128321308912830912830912839"
"#d+0"
"#d-0"
"#d0"
"#o237612036721631263126371263712"
"#o-2376120036721631263126371263712"
"#o+23761236721631263126371263712"
"#o+0"
"#o-0"
"#o0"
"#X-238973897AAAAAFFFFbb00bbdddcc"
"#X238973897AAAAA000FFFFbbbbdddcc"
"#X+07edf387"
"#X+0"
"#X-0"
"#X0"
"#B01010101010000000111111111110000"
"#B-01010101010000000111111111110000"
"#B+01010101010000000111111111110000"
"#B+0"
"#B-0"
"#B0"
"#D2398128321308912830912830912839"
"#D-2398128321308912830912830912839"
"#D+2398128321308912830912830912839"
"#D+0"
"#D-0"
"#D0"
"#O237612036721631263126371263712"
"#O-2376120036721631263126371263712"
"#O+23761236721631263126371263712"
"#O+0"
"#O-0"
"#O0")
(define-tests test-char-syntax
[(lambda (x) (= (char->integer x) #x0))
2007-12-10 09:28:48 -05:00
(read (open-string-input-port "#\\nul"))]
[(lambda (x) (= (char->integer x) #x7))
2007-12-10 09:28:48 -05:00
(read (open-string-input-port "#\\alarm"))]
[(lambda (x) (= (char->integer x) #x8))
2007-12-10 09:28:48 -05:00
(read (open-string-input-port "#\\backspace"))]
[(lambda (x) (= (char->integer x) #x9))
2007-12-10 09:28:48 -05:00
(read (open-string-input-port "#\\tab"))]
[(lambda (x) (= (char->integer x) #xA))
2007-12-10 09:28:48 -05:00
(read (open-string-input-port "#\\linefeed"))]
[(lambda (x) (= (char->integer x) #xA))
2007-12-10 09:28:48 -05:00
(read (open-string-input-port "#\\newline"))]
[(lambda (x) (= (char->integer x) #xB))
2007-12-10 09:28:48 -05:00
(read (open-string-input-port "#\\vtab"))]
[(lambda (x) (= (char->integer x) #xC))
2007-12-10 09:28:48 -05:00
(read (open-string-input-port "#\\page"))]
[(lambda (x) (= (char->integer x) #xD))
2007-12-10 09:28:48 -05:00
(read (open-string-input-port "#\\return"))]
[(lambda (x) (= (char->integer x) #x1B))
2007-12-10 09:28:48 -05:00
(read (open-string-input-port "#\\esc"))]
[(lambda (x) (= (char->integer x) #x20))
2007-12-10 09:28:48 -05:00
(read (open-string-input-port "#\\space"))]
[(lambda (x) (= (char->integer x) #x7F))
2007-12-10 09:28:48 -05:00
(read (open-string-input-port "#\\delete"))])
2008-10-18 13:03:17 -04:00
(define (run-tests)
(test-char-syntax)
(test-reader))
)