1
;; Filename : test-exp.scm
2
;; About : unit test for R5RS expressions
1
;; Filename : test-srfi6.scm
2
;; About : unit test for SRFI-6 Basic String Ports
4
4
;; Copyright (C) 2005-2006 Kazuki Ohta <mover AT hct.zaq.ne.jp>
5
;; Copyright (c) 2007 SigScheme Project <uim AT freedesktop.org>
6
7
;; All rights reserved.
38
(if (not (provided? "srfi-6"))
39
(test-skip "SRFI-6 is not enabled"))
38
44
;; open-input-string
47
(tn "open-input-string invalid forms")
48
(assert-error (tn) (lambda () (open-input-string)))
49
(assert-error (tn) (lambda () (open-input-string '())))
50
(assert-error (tn) (lambda () (open-input-string (current-input-port))))
51
(assert-error (tn) (lambda () (open-input-string "" "")))
41
55
(open-input-string "(a . (b . (c . ()))) 34"))
43
(assert-true "open-input-string immutable" (input-port? p))
44
(assert-equal? "open-input-string immutable" '(a b c) (read p))
45
(assert-equal? "open-input-string immutable" 34 (read p))
57
(tn "open-input-string immutable")
58
(assert-true (tn) (input-port? p))
59
(assert-equal? (tn) '(a b c) (read p))
60
(assert-equal? (tn) 34 (read p))
61
(assert-true (tn) (eof-object? (read p)))
62
(assert-true (tn) (eof-object? (read-char (open-input-string ""))))
48
66
(open-input-string (string-copy "(a . (b . (c . ()))) 34")))
50
(assert-true "open-input-string mutable" (input-port? p2))
51
(assert-equal? "open-input-string mutable" '(a b c) (read p2))
52
(assert-equal? "open-input-string mutable" 34 (read p2))
68
(tn "open-input-string mutable")
69
(assert-true (tn) (input-port? p2))
70
(assert-equal? (tn) '(a b c) (read p2))
71
(assert-equal? (tn) 34 (read p2))
72
(assert-true (tn) (eof-object? (read p2)))
73
(assert-true (tn) (eof-object? (read-char
74
(open-input-string (string-copy "")))))
54
77
;; open-output-string and get-output-string
55
(assert-equal? "output string test 1" "a(b c)" (let ((q (open-output-string))
59
(get-output-string q)))
60
(assert-equal? "output string test 2" "" (get-output-string
61
(open-output-string)))
80
(tn "open-output-string invalid forms")
81
(assert-error (tn) (lambda () (open-output-string '())))
82
(assert-error (tn) (lambda () (open-output-string (current-input-port))))
83
(assert-error (tn) (lambda () (open-output-string "")))
85
(tn "get-output-string invalid forms")
86
(assert-error (tn) (lambda () (get-output-string)))
87
(assert-error (tn) (lambda () (get-output-string (current-output-port))))
92
(let ((q (open-output-string))
96
(get-output-string q)))
99
(let ((q (open-output-string)))
102
(get-output-string q)))
105
(get-output-string (open-output-string)))