1
;;;; reader.test --- test the Guile parser -*- scheme -*-
2
;;;; Jim Blandy <jimb@red-bean.com> --- September 1999
5
(cons 'read-error "end of file$"))
7
(define exception:unexpected-rparen
8
(cons 'read-error "unexpected \")\"$"))
10
(define (read-string s)
11
(with-input-from-string s (lambda () (read))))
13
(with-test-prefix "reading"
15
(equal? (read-string "0") 0))
17
(equal? (read-string "1++i") '1++i))
19
(equal? (read-string "1+i+i") '1+i+i))
21
(equal? (read-string "1+e10000i") '1+e10000i))
23
;; At one time the arg list for "Unknown # object: ~S" didn't make it out
24
;; of read.c. Check that `format' can be applied to this error.
25
(pass-if "error message on bad #"
29
;; oops, this # is supposed to be unrecognised
31
(lambda (key subr message args rest)
32
(apply format #f message args)
33
;; message and args are ok
36
(pass-if-exception "radix passed to number->string can't be zero"
37
exception:out-of-range
38
(number->string 10 0))
39
(pass-if-exception "radix passed to number->string can't be one either"
40
exception:out-of-range
41
(number->string 10 1))
43
(with-test-prefix "mismatching parentheses"
44
(pass-if-exception "opening parenthesis"
47
(pass-if-exception "closing parenthesis following mismatched opening"
48
exception:unexpected-rparen
50
(pass-if-exception "opening vector parenthesis"
53
(pass-if-exception "closing parenthesis following mismatched vector opening"
54
exception:unexpected-rparen