09085606cbecc8a645e040e8f50b3c215eb282af
[sbcl.git] / tests / stream.impure.lisp
1 ;;;; tests related to Lisp streams
2
3 ;;;; This software is part of the SBCL system. See the README file for
4 ;;;; more information.
5 ;;;;
6 ;;;; While most of SBCL is derived from the CMU CL system, the test
7 ;;;; files (like this one) were written from scratch after the fork
8 ;;;; from CMU CL.
9 ;;;; 
10 ;;;; This software is in the public domain and is provided with
11 ;;;; absolutely no warranty. See the COPYING and CREDITS files for
12 ;;;; more information.
13
14 (in-package :cl-user)
15
16 (load "assertoid.lisp")
17
18 ;;; type errors for inappropriate stream arguments, fixed in
19 ;;; sbcl-0.7.8.19
20 (locally
21     (declare (optimize (safety 3)))
22   (assert (raises-error? (make-two-way-stream (make-string-output-stream)
23                                               (make-string-output-stream))
24                          type-error))
25   (assert (raises-error? (make-two-way-stream (make-string-input-stream "foo")
26                                               (make-string-input-stream "bar"))
27                          type-error))
28   ;; the following two aren't actually guaranteed, because ANSI, as it
29   ;; happens, doesn't say "should signal an error" for
30   ;; MAKE-ECHO-STREAM. It's still good to have, but if future
31   ;; maintenance work causes this test to fail because of these
32   ;; MAKE-ECHO-STREAM clauses, consider simply removing these clauses
33   ;; from the test. -- CSR, 2002-10-06
34   (assert (raises-error? (make-echo-stream (make-string-output-stream)
35                                            (make-string-output-stream))
36                          type-error))
37   (assert (raises-error? (make-echo-stream (make-string-input-stream "foo")
38                                            (make-string-input-stream "bar"))
39                          type-error))
40   (assert (raises-error? (make-concatenated-stream
41                           (make-string-output-stream)
42                           (make-string-input-stream "foo"))
43                          type-error)))
44
45 ;;; bug 225: STRING-STREAM was not a class
46 (eval `(defgeneric bug225 (s)
47          ,@(mapcar (lambda (class)
48                      `(:method :around ((s ,class)) (cons ',class (call-next-method))))
49                    '(stream string-stream sb-impl::string-input-stream
50                      sb-impl::string-output-stream))
51          (:method (class) nil)))
52
53 (assert (equal (bug225 (make-string-input-stream "hello"))
54                '(sb-impl::string-input-stream string-stream stream)))
55 (assert (equal (bug225 (make-string-output-stream))
56                '(sb-impl::string-output-stream string-stream stream)))
57
58 \f
59 ;;; success
60 (quit :unix-status 104)