mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-06 15:40:29 +02:00
* read.c (scm_input_error): new function: give meaningful error messages, and throw read-error * gc-malloc.c (scm_calloc): add scm_calloc. * scheme-memory.texi (Memory Blocks): add scm_calloc, scm_gc_calloc. correct typos.
42 lines
1.3 KiB
Scheme
42 lines
1.3 KiB
Scheme
;;;; reader.test --- test the Guile parser -*- scheme -*-
|
|
;;;; Jim Blandy <jimb@red-bean.com> --- September 1999
|
|
|
|
(define exception:eof
|
|
(cons 'read-error "end of file$"))
|
|
|
|
(define exception:unexpected-rparen
|
|
(cons 'read-error "unexpected \")\"$"))
|
|
|
|
(define (read-string s)
|
|
(with-input-from-string s (lambda () (read))))
|
|
|
|
(with-test-prefix "reading"
|
|
(pass-if "0"
|
|
(equal? (read-string "0") 0))
|
|
(pass-if "1++i"
|
|
(equal? (read-string "1++i") '1++i))
|
|
(pass-if "1+i+i"
|
|
(equal? (read-string "1+i+i") '1+i+i))
|
|
(pass-if "1+e10000i"
|
|
(equal? (read-string "1+e10000i") '1+e10000i)))
|
|
|
|
(pass-if-exception "radix passed to number->string can't be zero"
|
|
exception:out-of-range
|
|
(number->string 10 0))
|
|
(pass-if-exception "radix passed to number->string can't be one either"
|
|
exception:out-of-range
|
|
(number->string 10 1))
|
|
|
|
(with-test-prefix "mismatching parentheses"
|
|
(pass-if-exception "opening parenthesis"
|
|
exception:eof
|
|
(read-string "("))
|
|
(pass-if-exception "closing parenthesis following mismatched opening"
|
|
exception:unexpected-rparen
|
|
(read-string ")"))
|
|
(pass-if-exception "opening vector parenthesis"
|
|
exception:eof
|
|
(read-string "#("))
|
|
(pass-if-exception "closing parenthesis following mismatched vector opening"
|
|
exception:unexpected-rparen
|
|
(read-string ")")))
|