;;;; While most of SBCL is derived from the CMU CL system, the test
;;;; files (like this one) were written from scratch after the fork
;;;; from CMU CL.
;;;; While most of SBCL is derived from the CMU CL system, the test
;;;; files (like this one) were written from scratch after the fork
;;;; from CMU CL.
;;;; This software is in the public domain and is provided with
;;;; absolutely no warranty. See the COPYING and CREDITS files for
;;;; more information.
;;;; This software is in the public domain and is provided with
;;;; absolutely no warranty. See the COPYING and CREDITS files for
;;;; more information.
(read-sequence buffer stream))
;;; test for the new N-BIN method doing what it's supposed to
(let* ((substrings (list "This " "is " "a " ""
(read-sequence buffer stream))
;;; test for the new N-BIN method doing what it's supposed to
(let* ((substrings (list "This " "is " "a " ""
- "test of concatenated streams behaving "
- "as ordinary streams do under READ-SEQUENCE. "
- (make-string 140041 :initial-element #\%)
- "For any size of read.."
- (make-string 4123 :initial-element #\.)
- "they should give the same results."
- (make-string (expt 2 14) :initial-element #\*)
- "There should be no differences."))
+ "test of concatenated streams behaving "
+ "as ordinary streams do under READ-SEQUENCE. "
+ (make-string 140041 :initial-element #\%)
+ "For any size of read.."
+ (make-string 4123 :initial-element #\.)
+ "they should give the same results."
+ (make-string (expt 2 14) :initial-element #\*)
+ "There should be no differences."))
(substreams (mapcar #'make-string-input-stream substrings))
(concatenated-stream (apply #'make-concatenated-stream substreams))
(concatenated-string (apply #'concatenate 'string substrings))
(substreams (mapcar #'make-string-input-stream substrings))
(concatenated-stream (apply #'make-concatenated-stream substreams))
(concatenated-string (apply #'concatenate 'string substrings))
;; (format t "buffer-1=~S~%buffer-2=~S~%" buffer-1 buffer-2)
(assert (= n-actually-read-1 n-actually-read-2))
(assert (string= buffer-1 buffer-2
;; (format t "buffer-1=~S~%buffer-2=~S~%" buffer-1 buffer-2)
(assert (= n-actually-read-1 n-actually-read-2))
(assert (string= buffer-1 buffer-2
;;; Entomotomy PEEK-CHAR-WRONGLY-ECHOS-TO-ECHO-STREAM bug, fixed by
;;; MRD patch sbcl-devel 2002-11-02 merged ca. sbcl-0.7.9.32...
(assert (string=
;;; Entomotomy PEEK-CHAR-WRONGLY-ECHOS-TO-ECHO-STREAM bug, fixed by
;;; MRD patch sbcl-devel 2002-11-02 merged ca. sbcl-0.7.9.32...
(assert (string=
- (with-output-to-string (out)
- (peek-char #\]
- (make-echo-stream
- (make-string-input-stream "ab cd e df s]") out)))
- ;; (Before the fix, the result had a trailing #\] in it.)
- "ab cd e df s"))
+ (with-output-to-string (out)
+ (peek-char #\]
+ (make-echo-stream
+ (make-string-input-stream "ab cd e df s]") out)))
+ ;; (Before the fix, the result had a trailing #\] in it.)
+ "ab cd e df s"))
;;; ...and a missing wrinkle in the original patch, dealing with
;;; PEEK-CHAR/UNREAD-CHAR on ECHO-STREAMs, fixed by MRD patch
;;; sbcl-devel 2002-11-18, merged ca. sbcl-0.7.9.66
(assert (string=
;;; ...and a missing wrinkle in the original patch, dealing with
;;; PEEK-CHAR/UNREAD-CHAR on ECHO-STREAMs, fixed by MRD patch
;;; sbcl-devel 2002-11-18, merged ca. sbcl-0.7.9.66
(assert (string=
- (let* ((in-stream (make-string-input-stream "abc"))
- (out-stream (make-string-output-stream))
- (echo-stream (make-echo-stream in-stream out-stream)))
- (unread-char (read-char echo-stream) echo-stream)
- (peek-char #\a echo-stream)
- (get-output-stream-string out-stream))
- ;; (Before the fix, the LET* expression just signalled an error.)
- "a"))
+ (let* ((in-stream (make-string-input-stream "abc"))
+ (out-stream (make-string-output-stream))
+ (echo-stream (make-echo-stream in-stream out-stream)))
+ (unread-char (read-char echo-stream) echo-stream)
+ (peek-char #\a echo-stream)
+ (get-output-stream-string out-stream))
+ ;; (Before the fix, the LET* expression just signalled an error.)
+ "a"))
;;; the same character that peek-char returns, the character is
;;; removed from the input stream, as if read by read-char.
(assert (equal (with-input-from-string (s "123")
;;; the same character that peek-char returns, the character is
;;; removed from the input stream, as if read by read-char.
(assert (equal (with-input-from-string (s "123")
;;; ... and verify that the fix does not break echo streams
(assert (string= (let ((out (make-string-output-stream)))
;;; ... and verify that the fix does not break echo streams
(assert (string= (let ((out (make-string-output-stream)))
- (with-open-stream (s (make-echo-stream
- (make-string-input-stream "123")
- out))
- (format s "=>~{~A~}"
- (list (peek-char nil s nil #\1)
- (read-char s)
- (read-char s)))
- (get-output-stream-string out)))
- "12=>112"))
+ (with-open-stream (s (make-echo-stream
+ (make-string-input-stream "123")
+ out))
+ (format s "=>~{~A~}"
+ (list (peek-char nil s nil #\1)
+ (read-char s)
+ (read-char s)))
+ (get-output-stream-string out)))
+ "12=>112"))
;;; 0.7.12 doesn't advance current stream in concatenated streams
;;; correctly when searching a stream for a char to read.
;;; 0.7.12 doesn't advance current stream in concatenated streams
;;; correctly when searching a stream for a char to read.
;;; MAKE-STRING-OUTPUT-STREAM
;;;
;;; * Observe FILE-POSITION :START and :END, and allow setting of
;;; MAKE-STRING-OUTPUT-STREAM
;;;
;;; * Observe FILE-POSITION :START and :END, and allow setting of
;;;
;;; * END will always refer to the farthest position of stream so-far
;;; seen, and setting FILE-POSITION beyond the current END will extend
;;;
;;; * END will always refer to the farthest position of stream so-far
;;; seen, and setting FILE-POSITION beyond the current END will extend
;;; MAKE-STRING-OUTPUT-STREAM and WITH-OUTPUT-TO-STRING take an
;;; :ELEMENT-TYPE keyword argument
(macrolet ((frob (element-type-form)
;;; 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)))))))
+ `(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)))))))