unlock reader test

This commit is contained in:
Yuichi Nishiwaki 2014-06-28 20:02:06 +09:00
parent aae4bba98d
commit 8f5a4e8980
1 changed files with 45 additions and 45 deletions

View File

@ -32,7 +32,7 @@
; (scheme complex)
(scheme time)
(scheme file)
; (scheme read)
(scheme read)
(scheme write)
; (scheme eval)
(scheme process-context)
@ -1962,56 +1962,56 @@
(test-begin "Read syntax")
;; check reading boolean followed by eof
;; (test #t (read (open-input-string "#t")))
;; (test #t (read (open-input-string "#true")))
;; (test #f (read (open-input-string "#f")))
;; (test #f (read (open-input-string "#false")))
;; (define (read2 port)
;; (let* ((o1 (read port)) (o2 (read port)))
;; (cons o1 o2)))
;; ;; check reading boolean followed by delimiter
;; (test '(#t . (5)) (read2 (open-input-string "#t(5)")))
;; (test '(#t . 6) (read2 (open-input-string "#true 6 ")))
;; (test '(#f . 7) (read2 (open-input-string "#f 7")))
;; (test '(#f . "8") (read2 (open-input-string "#false\"8\"")))
(test #t (read (open-input-string "#t")))
(test #t (read (open-input-string "#true")))
(test #f (read (open-input-string "#f")))
(test #f (read (open-input-string "#false")))
(define (read2 port)
(let* ((o1 (read port)) (o2 (read port)))
(cons o1 o2)))
;; check reading boolean followed by delimiter
(test '(#t . (5)) (read2 (open-input-string "#t(5)")))
(test '(#t . 6) (read2 (open-input-string "#true 6 ")))
(test '(#f . 7) (read2 (open-input-string "#f 7")))
(test '(#f . "8") (read2 (open-input-string "#false\"8\"")))
;; (test '() (read (open-input-string "()")))
;; (test '(1 2) (read (open-input-string "(1 2)")))
;; (test '(1 . 2) (read (open-input-string "(1 . 2)")))
;; (test '(1 2) (read (open-input-string "(1 . (2))")))
;; (test '(1 2 3 4 5) (read (open-input-string "(1 . (2 3 4 . (5)))")))
;; (test '1 (cadr (read (open-input-string "#0=(1 . #0#)"))))
;; (test '(1 2 3) (cadr (read (open-input-string "(#0=(1 2 3) #0#)"))))
(test '() (read (open-input-string "()")))
(test '(1 2) (read (open-input-string "(1 2)")))
(test '(1 . 2) (read (open-input-string "(1 . 2)")))
(test '(1 2) (read (open-input-string "(1 . (2))")))
(test '(1 2 3 4 5) (read (open-input-string "(1 . (2 3 4 . (5)))")))
(test '1 (cadr (read (open-input-string "#0=(1 . #0#)"))))
(test '(1 2 3) (cadr (read (open-input-string "(#0=(1 2 3) #0#)"))))
;; (test '(quote (1 2)) (read (open-input-string "'(1 2)")))
;; (test '(quote (1 (unquote 2))) (read (open-input-string "'(1 ,2)")))
;; (test '(quote (1 (unquote-splicing 2))) (read (open-input-string "'(1 ,@2)")))
;; (test '(quasiquote (1 (unquote 2))) (read (open-input-string "`(1 ,2)")))
(test '(quote (1 2)) (read (open-input-string "'(1 2)")))
(test '(quote (1 (unquote 2))) (read (open-input-string "'(1 ,2)")))
(test '(quote (1 (unquote-splicing 2))) (read (open-input-string "'(1 ,@2)")))
(test '(quasiquote (1 (unquote 2))) (read (open-input-string "`(1 ,2)")))
;; (test #() (read (open-input-string "#()")))
;; (test #(a b) (read (open-input-string "#(a b)")))
(test #() (read (open-input-string "#()")))
(test #(a b) (read (open-input-string "#(a b)")))
;; (test #u8() (read (open-input-string "#u8()")))
;; (test #u8(0 1) (read (open-input-string "#u8(0 1)")))
(test #u8() (read (open-input-string "#u8()")))
(test #u8(0 1) (read (open-input-string "#u8(0 1)")))
;; (test 'abc (read (open-input-string "abc")))
;; (test 'abc (read (open-input-string "abc def")))
;; (test 'ABC (read (open-input-string "ABC")))
;; (test 'Hello (read (open-input-string "|H\\x65;llo|")))
(test 'abc (read (open-input-string "abc")))
(test 'abc (read (open-input-string "abc def")))
(test 'ABC (read (open-input-string "ABC")))
(test 'Hello (read (open-input-string "|H\\x65;llo|")))
;; (test 'abc (read (open-input-string "#!fold-case ABC")))
;; (test 'ABC (read (open-input-string "#!fold-case #!no-fold-case ABC")))
(test 'abc (read (open-input-string "#!fold-case ABC")))
(test 'ABC (read (open-input-string "#!fold-case #!no-fold-case ABC")))
;; (test 'def (read (open-input-string "#; abc def")))
;; (test 'def (read (open-input-string "; abc \ndef")))
;; (test 'def (read (open-input-string "#| abc |# def")))
;; (test 'ghi (read (open-input-string "#| abc #| def |# |# ghi")))
;; (test 'ghi (read (open-input-string "#; ; abc\n def ghi")))
;; (test '(abs -16) (read (open-input-string "(#;sqrt abs -16)")))
;; (test '(a d) (read (open-input-string "(a #; #;b c d)")))
;; (test '(a e) (read (open-input-string "(a #;(b #;c d) e)")))
;; (test '(a . c) (read (open-input-string "(a . #;b c)")))
;; (test '(a . b) (read (open-input-string "(a . b #;c)")))
(test 'def (read (open-input-string "#; abc def")))
(test 'def (read (open-input-string "; abc \ndef")))
(test 'def (read (open-input-string "#| abc |# def")))
(test 'ghi (read (open-input-string "#| abc #| def |# |# ghi")))
(test 'ghi (read (open-input-string "#; ; abc\n def ghi")))
(test '(abs -16) (read (open-input-string "(#;sqrt abs -16)")))
(test '(a d) (read (open-input-string "(a #; #;b c d)")))
(test '(a e) (read (open-input-string "(a #;(b #;c d) e)")))
(test '(a . c) (read (open-input-string "(a . #;b c)")))
(test '(a . b) (read (open-input-string "(a . b #;c)")))
;; (define (test-read-error str)
;; (test-assert
@ -2058,7 +2058,7 @@
;; (test "line 1\n\nline 3\n" (read (open-input-string "\"line 1\\ \t \n \t \n\nline 3\n\"")))
;; (test #x03BB (char->integer (string-ref (read (open-input-string "\"\\x03BB;\"")) 0)))
;; (test-end)
(test-end)
(test-begin "Numeric syntax")