[Git][cmucl/cmucl][issue-140-stream-element-type-two-way-stream] Address review comments
Raymond Toy (@rtoy)
gitlab at common-lisp.net
Tue Nov 22 15:45:32 UTC 2022
Raymond Toy pushed to branch issue-140-stream-element-type-two-way-stream at cmucl / cmucl
Commits:
8144bada by Raymond Toy at 2022-11-22T07:43:26-08:00
Address review comments
Since `two-way-stream` isn't a `file-stream`, signal an error from
`stream-external-format`.
Update the test to verify that `stream-external-format` for a
`two-way-stream` signals a `type-error`.
Add a test for `broadcast-stream`s to verify that we return the format
of the last stream.
- - - - -
2 changed files:
- src/code/stream.lisp
- tests/issues.lisp
Changes:
=====================================
src/code/stream.lisp
=====================================
@@ -304,11 +304,7 @@
;; Not defined by CLHS. What should happen if
;; (synonym-stream-symbol stream) is unbound?
(stream-external-format
- (symbol-value (synonym-stream-symbol stream))))
- (two-way-stream
- ;; Not defined by CLHS, but use default for backward
- ;; compatibility.
- :default))
+ (symbol-value (synonym-stream-symbol stream)))))
;; fundamental-stream
:default))
=====================================
tests/issues.lisp
=====================================
@@ -747,9 +747,7 @@
;;; Test stream-external-format for various types of streams.
-;; Test two-way-stream where both streams have the same external
-;; format.
-(define-test issue.140.two-way-stream-same
+(define-test issue.140.two-way-stream
(:tag :issues)
(with-open-file (in (merge-pathnames "issues.lisp" cmucl-test-runner::*load-path*)
:direction :input
@@ -759,21 +757,8 @@
:external-format :utf-8
:if-exists :supersede)
(let ((two-way-stream (make-two-way-stream in out)))
- (assert-equal :default (stream-external-format two-way-stream))))))
-
-;; Test two-way-stream where the two streams have the different
-;; external formats.
-(define-test issue.140.two-way-stream-diff
- (:tag :issues)
- (with-open-file (in (merge-pathnames "issues.lisp" cmucl-test-runner::*load-path*)
- :direction :input
- :external-format :iso8859-1)
- (with-open-file (out "/tmp/output.tst"
- :direction :output
- :external-format :utf-8
- :if-exists :supersede)
- (let ((two-way-stream (make-two-way-stream in out)))
- (assert-equal :default (stream-external-format two-way-stream))))))
+ (assert-error 'type-error
+ (stream-external-format two-way-stream))))))
;; Test synonym-stream returns the format of the underlying stream.
(define-test issue.140.synonym-stream
@@ -785,6 +770,29 @@
(setf syn s)
(assert-equal :iso8859-1 (stream-external-format syn)))))
+(define-test issue.140.broadcast-stream
+ (:tag :issues)
+ ;; Create 3 output streams. The exact external formats aren't
+ ;; really important here as long as they're different for each file
+ ;; so we can tell if we got the right answer.
+ (with-open-file (s1 "/tmp/broad-1"
+ :direction :output
+ :if-exists :supersede
+ :external-format :latin1)
+ (with-open-file (s2 "/tmp/broad-2"
+ :direction :output
+ :if-exists :supersede
+ :external-format :utf-8)
+ (with-open-file (s3 "/tmp/broad-3"
+ :direction :output
+ :if-exists :supersede
+ :external-format :utf-16)
+ ;; The format must be the value from the last stream.
+ (assert-equal :utf-16
+ (stream-external-format
+ (make-broadcast-stream s1 s2 s3)))))))
+
+
(define-test issue.150
(:tag :issues)
(let ((ext:*gc-verbose* nil)
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/8144bada55b3ac9880c61067cfd4c5c0e9386690
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/8144bada55b3ac9880c61067cfd4c5c0e9386690
You're receiving this email because of your account on gitlab.common-lisp.net.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cmucl-cvs/attachments/20221122/03ff646f/attachment-0001.html>
More information about the cmucl-cvs
mailing list