Commit c1758743 authored by pfdietz's avatar pfdietz

Added tests checking that stream functions that accept stream designators actually do so.

parent 8c04f1a3
......@@ -26,6 +26,19 @@
(clear-input t)
nil)
(deftest clear-input.5
(with-input-from-string
(is "!?*")
(let ((*terminal-io* (make-two-way-stream is *standard-output*)))
(clear-input t)))
nil)
(deftest clear-input.6
(with-input-from-string
(*standard-input* "345")
(clear-input nil))
nil)
;;; Error cases
(deftest clear-input.error.1
......
......@@ -26,6 +26,17 @@
collect s)
nil)
(deftest clear-output.5
(let ((os (make-string-output-stream)))
(let ((*terminal-io* (make-two-way-stream *standard-input* os)))
(clear-output t)))
nil)
(deftest clear-output.6
(let ((*standard-output* (make-string-output-stream)))
(clear-output nil))
nil)
;;; Error tests
(deftest clear-output.error.1
......
......@@ -25,6 +25,17 @@
collect s)
nil)
(deftest finish-output.5
(let ((os (make-string-output-stream)))
(let ((*terminal-io* (make-two-way-stream *standard-input* os)))
(finish-output t)))
nil)
(deftest finish-output.6
(let ((*standard-output* (make-string-output-stream)))
(finish-output nil))
nil)
;;; Error tests
(deftest finish-output.error.1
......
......@@ -25,6 +25,18 @@
collect s)
nil)
(deftest force-output.5
(let ((os (make-string-output-stream)))
(let ((*terminal-io* (make-two-way-stream *standard-input* os)))
(force-output t)))
nil)
(deftest force-output.6
(let ((*standard-output* (make-string-output-stream)))
(force-output nil))
nil)
;;; Error tests
(deftest force-output.error.1
......
......@@ -60,7 +60,21 @@
"
" ((t) (nil) (nil)))
(deftest fresh-line.6
(with-output-to-string
(os)
(let ((*terminal-io* (make-two-way-stream *standard-input* os)))
(write-char #\a t)
(fresh-line t)
(finish-output t)))
#.(concatenate 'string (string #\a) (string #\Newline)))
(deftest fresh-line.7
(with-output-to-string
(*standard-output*)
(write-char #\a nil)
(terpri nil))
#.(concatenate 'string (string #\a) (string #\Newline)))
;;; Error tests
......
......@@ -47,6 +47,19 @@
(end-of-file () (listen s)))))
t nil)
(deftest listen.8
(with-input-from-string
(is "abc")
(let ((*terminal-io* (make-two-way-stream is *standard-output*)))
(notnot-mv (listen t))))
t)
(deftest listen.9
(with-input-from-string
(*standard-input* "345")
(notnot-mv (listen nil)))
t)
;;; Error tests
(deftest listen.error.1
......
......@@ -257,6 +257,20 @@
#\a #\a ; *not* #\x #\x
)
;;; Stream designators are accepted for the stream argument
(deftest peek-char.22
(with-input-from-string
(is "!?*")
(let ((*terminal-io* (make-two-way-stream is *standard-output*)))
(peek-char nil t)))
#\!)
(deftest peek-char.23
(with-input-from-string
(*standard-input* "345")
(peek-char nil nil))
#\3)
;;; Error tests
......
......@@ -72,6 +72,19 @@
(read-char-no-hang s nil t)))
#\a #\b #\c)
(deftest read-char-no-hang.9
(with-input-from-string
(is "!?*")
(let ((*terminal-io* (make-two-way-stream is *standard-output*)))
(read-char-no-hang t)))
#\!)
(deftest read-char-no-hang.10
(with-input-from-string
(*standard-input* "345")
(read-char-no-hang nil))
#\3)
;;; Need a test of the non-hanging.
;;; This is hard to do portably.
......
......@@ -72,6 +72,20 @@
(read-char s nil t)))
#\a #\b #\c)
(deftest read-char.9
(with-input-from-string
(is "!?*")
(let ((*terminal-io* (make-two-way-stream is *standard-output*)))
(read-char t)))
#\!)
(deftest read-char.10
(with-input-from-string
(*standard-input* "345")
(read-char nil))
#\3)
;;; Error tests
(deftest read-char.error.1
......
......@@ -49,6 +49,24 @@
(values (first vals) (notnot (second vals)))))
" abcd " t)
(deftest read-line.7
(with-input-from-string
(is "abc")
(let ((*terminal-io* (make-two-way-stream is *standard-output*)))
(let ((vals (multiple-value-list (read-line t))))
(assert (= (length vals) 2))
(assert (second vals))
(first vals))))
"abc")
(deftest read-line.8
(with-input-from-string
(*standard-input* "abc")
(let ((vals (multiple-value-list (read-line nil))))
(assert (= (length vals) 2))
(assert (second vals))
(first vals)))
"abc")
;;; Error tests
......
......@@ -36,6 +36,20 @@
(write-char #\y s))
#.(concatenate 'string "x" (string #\Newline) (string #\Newline) "y"))
(deftest terpri.4
(with-output-to-string
(os)
(let ((*terminal-io* (make-two-way-stream *standard-input* os)))
(terpri t)
(finish-output t)))
#.(string #\Newline))
(deftest terpri.5
(with-output-to-string
(*standard-output*)
(terpri nil))
#.(string #\Newline))
;;; Error tests
(deftest terpri.error.1
......
......@@ -46,6 +46,33 @@
(read-char s))))
"abc")
(deftest unread-char.4
(with-input-from-string
(*standard-input* "abc")
(values
(read-char)
(unread-char #\a nil)
(read-char)
(read-char)
(unread-char #\b nil)
(read-char)
(read-char)))
#\a nil #\a #\b nil #\b #\c)
(deftest unread-char.5
(with-input-from-string
(is "abc")
(let ((*terminal-io* (make-two-way-stream is *standard-output*)))
(values
(read-char t)
(unread-char #\a t)
(read-char t)
(read-char t)
(unread-char #\b t)
(read-char t)
(read-char t))))
#\a nil #\a #\b nil #\b #\c)
;;; Error tests
(deftest unread-char.error.1
......
......@@ -16,6 +16,20 @@
collect c)
nil)
(deftest write-char.2
(with-output-to-string
(os)
(let ((*terminal-io* (make-two-way-stream *standard-input* os)))
(write-char #\$ t)
(close *terminal-io*)))
"$")
(deftest write-char.3
(with-output-to-string
(*standard-output*)
(write-char #\: nil))
":")
;;; Error tests
(deftest write-char.error.1
......
......@@ -114,6 +114,20 @@
#.(concatenate 'string "abc" (string #\Newline))
("abcde"))
(deftest write-line.11
(with-output-to-string
(os)
(let ((*terminal-io* (make-two-way-stream *standard-input* os)))
(write-line "951" t)
(close *terminal-io*)))
#.(concatenate 'string "951" (string #\Newline)))
(deftest write-line.12
(with-output-to-string
(*standard-output*)
(write-line "-=|!" nil))
#.(concatenate 'string "-=|!" (string #\Newline)))
;;; Error tests
(deftest write-line.error.1
......
......@@ -104,6 +104,20 @@
result))
"abc" ("abcde"))
(deftest write-string.11
(with-output-to-string
(os)
(let ((*terminal-io* (make-two-way-stream *standard-input* os)))
(write-string "951" t)
(close *terminal-io*)))
"951")
(deftest write-string.12
(with-output-to-string
(*standard-output*)
(write-string "-=|!" nil))
"-=|!")
;;; Error tests
(deftest write-string.error.1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment