;;;; reader.test --- test the Guile parser -*- scheme -*- ;;;; Jim Blandy --- September 1999 (define exception:eof (cons 'misc-error "^end of file")) (define exception:unexpected-rparen (cons 'misc-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 ")")))