2007-05-20 13:11:33 -04:00
|
|
|
(library (tests reader)
|
2007-11-07 11:24:18 -05:00
|
|
|
(export test-reader test-char-syntax)
|
2007-05-20 13:11:33 -04:00
|
|
|
(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?)))))
|
2007-05-20 13:11:33 -04:00
|
|
|
|
|
|
|
(define-syntax reader-tests
|
|
|
|
(syntax-rules ()
|
|
|
|
[(_ name str* ...)
|
|
|
|
(define-tests name
|
|
|
|
[(t str*) (string->number str*)] ...)]))
|
|
|
|
|
|
|
|
(reader-tests test-reader
|
2007-05-20 22:16:57 -04:00
|
|
|
"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"
|
2007-11-07 11:24:18 -05:00
|
|
|
"#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"))]
|
2007-11-07 11:24:18 -05:00
|
|
|
[(lambda (x) (= (char->integer x) #x7))
|
2007-12-10 09:28:48 -05:00
|
|
|
(read (open-string-input-port "#\\alarm"))]
|
2007-11-07 11:24:18 -05:00
|
|
|
[(lambda (x) (= (char->integer x) #x8))
|
2007-12-10 09:28:48 -05:00
|
|
|
(read (open-string-input-port "#\\backspace"))]
|
2007-11-07 11:24:18 -05:00
|
|
|
[(lambda (x) (= (char->integer x) #x9))
|
2007-12-10 09:28:48 -05:00
|
|
|
(read (open-string-input-port "#\\tab"))]
|
2007-11-07 11:24:18 -05:00
|
|
|
[(lambda (x) (= (char->integer x) #xA))
|
2007-12-10 09:28:48 -05:00
|
|
|
(read (open-string-input-port "#\\linefeed"))]
|
2007-11-07 11:24:18 -05:00
|
|
|
[(lambda (x) (= (char->integer x) #xA))
|
2007-12-10 09:28:48 -05:00
|
|
|
(read (open-string-input-port "#\\newline"))]
|
2007-11-07 11:24:18 -05:00
|
|
|
[(lambda (x) (= (char->integer x) #xB))
|
2007-12-10 09:28:48 -05:00
|
|
|
(read (open-string-input-port "#\\vtab"))]
|
2007-11-07 11:24:18 -05:00
|
|
|
[(lambda (x) (= (char->integer x) #xC))
|
2007-12-10 09:28:48 -05:00
|
|
|
(read (open-string-input-port "#\\page"))]
|
2007-11-07 11:24:18 -05:00
|
|
|
[(lambda (x) (= (char->integer x) #xD))
|
2007-12-10 09:28:48 -05:00
|
|
|
(read (open-string-input-port "#\\return"))]
|
2007-11-07 11:24:18 -05:00
|
|
|
[(lambda (x) (= (char->integer x) #x1B))
|
2007-12-10 09:28:48 -05:00
|
|
|
(read (open-string-input-port "#\\esc"))]
|
2007-11-07 11:24:18 -05:00
|
|
|
[(lambda (x) (= (char->integer x) #x20))
|
2007-12-10 09:28:48 -05:00
|
|
|
(read (open-string-input-port "#\\space"))]
|
2007-11-07 11:24:18 -05:00
|
|
|
[(lambda (x) (= (char->integer x) #x7F))
|
2007-12-10 09:28:48 -05:00
|
|
|
(read (open-string-input-port "#\\delete"))])
|
2007-05-20 22:16:57 -04:00
|
|
|
|
2007-11-07 11:24:18 -05:00
|
|
|
)
|
2007-05-20 13:11:33 -04:00
|
|
|
|