mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-21 14:49:18 +02:00
Making custom port tests optional.
This commit is contained in:
parent
24b43e367b
commit
e2cae1558c
1 changed files with 31 additions and 25 deletions
|
@ -23,34 +23,40 @@
|
||||||
(call-with-input-string "abc\ndef"
|
(call-with-input-string "abc\ndef"
|
||||||
(lambda (in) (let ((line (read-line in))) (list line (read-line in))))))
|
(lambda (in) (let ((line (read-line in))) (list line (read-line in))))))
|
||||||
|
|
||||||
(test "null-output-port" #t
|
;; Custom ports are only supported with string streams (i.e. either
|
||||||
(let ((out (make-null-output-port)))
|
;; GNU fopencookie or BSD funopen).
|
||||||
(write 1 out)
|
|
||||||
(close-output-port out)
|
|
||||||
#t))
|
|
||||||
|
|
||||||
(test "null-input-port" #t
|
(cond-expand
|
||||||
(let ((in (make-concatenated-port)))
|
(string-streams
|
||||||
(let ((res (eof-object? (read-char in))))
|
|
||||||
(close-input-port in)
|
|
||||||
res)))
|
|
||||||
|
|
||||||
(define (string-upcase str)
|
(test "null-output-port" #t
|
||||||
(list->string (map char-upcase (string->list str))))
|
(let ((out (make-null-output-port)))
|
||||||
|
(write 1 out)
|
||||||
|
(close-output-port out)
|
||||||
|
#t))
|
||||||
|
|
||||||
(test "upcase-input-port" "ABC"
|
(test "null-input-port" #t
|
||||||
(call-with-input-string "abc"
|
(let ((in (make-concatenated-port)))
|
||||||
(lambda (in)
|
(let ((res (eof-object? (read-char in))))
|
||||||
(let ((in (make-filtered-input-port string-upcase in)))
|
(close-input-port in)
|
||||||
(let ((res (read-line in)))
|
res)))
|
||||||
(close-input-port in)
|
|
||||||
res)))))
|
|
||||||
|
|
||||||
(test "upcase-output-port" "ABC"
|
(define (string-upcase str)
|
||||||
(call-with-output-string
|
(list->string (map char-upcase (string->list str))))
|
||||||
(lambda (out)
|
|
||||||
(let ((out (make-filtered-output-port string-upcase out)))
|
(test "upcase-input-port" "ABC"
|
||||||
(display "abc" out)
|
(call-with-input-string "abc"
|
||||||
(close-output-port out)))))
|
(lambda (in)
|
||||||
|
(let ((in (make-filtered-input-port string-upcase in)))
|
||||||
|
(let ((res (read-line in)))
|
||||||
|
(close-input-port in)
|
||||||
|
res)))))
|
||||||
|
|
||||||
|
(test "upcase-output-port" "ABC"
|
||||||
|
(call-with-output-string
|
||||||
|
(lambda (out)
|
||||||
|
(let ((out (make-filtered-output-port string-upcase out)))
|
||||||
|
(display "abc" out)
|
||||||
|
(close-output-port out)))))))
|
||||||
|
|
||||||
(test-end)
|
(test-end)
|
||||||
|
|
Loading…
Add table
Reference in a new issue