X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=tests%2Fstream.pure.lisp;h=4bf264c3b00d29d50445e02b7e8508f1bfacf81c;hb=42765fe1c5c3ae34ad199ffdead00c2fc4e8cddb;hp=d1f52f8ef79cd34582e1d2defb53c6ca7334c8f9;hpb=24407d11d34abdaaef6d839fd0b2665c73b0e6d5;p=sbcl.git diff --git a/tests/stream.pure.lisp b/tests/stream.pure.lisp index d1f52f8..4bf264c 100644 --- a/tests/stream.pure.lisp +++ b/tests/stream.pure.lisp @@ -53,7 +53,7 @@ (return))))) ;;; Entomotomy PEEK-CHAR-WRONGLY-ECHOS-TO-ECHO-STREAM bug, fixed by -;;; by MRD patch sbcl-devel 2002-11-02 merged ca. sbcl-0.7.9.32... +;;; MRD patch sbcl-devel 2002-11-02 merged ca. sbcl-0.7.9.32... (assert (string= (with-output-to-string (out) (peek-char #\] @@ -73,3 +73,52 @@ (get-output-stream-string out-stream)) ;; (Before the fix, the LET* expression just signalled an error.) "a")) + +;;; 0.7.12 doesn't advance current stream in concatenated streams +;;; correctly when searching a stream for a char to read. +(with-input-from-string (p "") + (with-input-from-string (q "foo") + (let* ((r (make-concatenated-stream p q))) + (peek-char nil r)))) + +;;; 0.7.14 and previous SBCLs don't have a working INTERACTIVE-STREAM-P +;;; because it called UNIX-ISATTY, which wasn't defined. +(with-input-from-string (s "a non-interactive stream") + (assert (not (interactive-stream-p s)))) +;;; KLUDGE: Unfortunately it's hard to find a reliably interactive +;;; stream to test, since it's reasonable for these tests to be run +;;; from a script, conceivably even as something like a cron job. +;;; Ideas? +#+nil (assert (eq (interactive-stream-p *terminal-io*) t)) + +;;; FILE-POSITION on string-input-streams should work, even with +;;; :START or :END new positions. +(let ((stream (make-string-input-stream "abc"))) + (assert (char= (read-char stream) #\a)) + (assert (= (file-position stream) 1)) + (assert (file-position stream 0)) + (assert (char= (read-char stream) #\a)) + (assert (file-position stream :start)) + (assert (char= (read-char stream) #\a)) + (assert (file-position stream :end)) + (assert (eq (read-char stream nil 'foo) 'foo))) + +;;; MAKE-STRING-OUTPUT-STREAM and WITH-OUTPUT-TO-STRING take an +;;; :ELEMENT-TYPE keyword argument +(macrolet ((frob (element-type-form) + `(progn + (let ((s (with-output-to-string + (s nil ,@(when element-type-form + `(:element-type ,element-type-form)))))) + (assert (typep s '(simple-array ,(if element-type-form + (eval element-type-form) + 'character) + (0))))) + (get-output-stream-string + (make-string-output-stream + ,@(when element-type-form + `(:element-type ,element-type-form))))))) + (frob nil) + (frob 'character) + (frob 'base-char) + (frob 'nil))