source: trunk/source/tests/ansi-tests/make-synonym-stream.lsp @ 8991

Last change on this file since 8991 was 8991, checked in by gz, 12 years ago

Check in the gcl ansi test suite (original, in preparation for making local changes)

File size: 2.6 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Wed Jan 28 06:54:33 2004
4;;;; Contains: Tests of MAKE-SYNONYM-STREAM
5
6(in-package :cl-test)
7
8(deftest make-synonym-stream.1
9  (with-input-from-string
10   (*s* "abcde")
11   (declare (special *s*))
12   (let ((ss (make-synonym-stream '*s*)))
13     (assert (typep ss 'stream))
14     (assert (typep ss 'synonym-stream))
15     (assert (input-stream-p ss))
16     (assert (not (output-stream-p ss)))
17     (assert (open-stream-p ss))
18     (assert (streamp ss))
19     (assert (stream-element-type ss))
20     (values
21      (read-char *s*)
22      (read-char ss)
23      (read-char *s*)
24      (read-char ss)
25      (read-char ss))))
26  #\a #\b #\c #\d #\e)
27
28
29;;; This test was wrong (section 21.1.4)
30#|
31(deftest make-synonym-stream.2
32   (let ((ss (make-synonym-stream '*s*)))
33     (with-input-from-string
34      (*s* "z")
35      (declare (special *s*))
36      (assert (typep ss 'stream))
37      (assert (typep ss 'synonym-stream))
38      (assert (input-stream-p ss))
39      (assert (not (output-stream-p ss)))
40      (assert (open-stream-p ss))
41      (assert (streamp ss))
42      (assert (stream-element-type ss))
43      (read-char ss)))
44   #\z)
45|#
46
47(deftest make-synonym-stream.3
48  (with-output-to-string
49   (*s*)
50   (declare (special *s*))
51   (let ((ss (make-synonym-stream '*s*)))
52     (assert (typep ss 'stream))
53     (assert (typep ss 'synonym-stream))
54     (assert (output-stream-p ss))
55     (assert (not (input-stream-p ss)))
56     (assert (open-stream-p ss))
57     (assert (streamp ss))
58     (assert (stream-element-type ss))
59     (write-char #\a *s*)
60     (write-char #\b ss)
61     (write-char #\x *s*)
62     (write-char #\y ss)))
63  "abxy")
64
65(deftest make-synonym-stream.4
66  (let ((ss (make-synonym-stream '*terminal-io*)))
67     (assert (typep ss 'stream))
68     (assert (typep ss 'synonym-stream))
69     (assert (output-stream-p ss))
70     (assert (input-stream-p ss))
71     (assert (open-stream-p ss))
72     (assert (streamp ss))
73     (assert (stream-element-type ss))
74     nil)
75  nil)
76
77
78;;; FIXME
79;;; Add tests for: close,
80;;;  peek-char, read-char-no-hang, terpri, fresh-line, unread-char,
81;;;  read-line, write-line, write-string, read-sequence, write-sequence,
82;;;  read-byte, write-byte, listen, clear-input, finish-output, force-output,
83;;;  clear-output, format, print, prin1, princ
84
85;;; Error cases
86
87(deftest make-synonym-stream.error.1
88  (signals-error (make-synonym-stream) program-error)
89  t)
90
91(deftest make-synonym-stream.error.2
92  (signals-error (make-synonym-stream '*standard-input* nil) program-error)
93  t)
94
95(deftest make-synonym-stream.error.3
96  (check-type-error #'make-synonym-stream #'symbolp)
97  nil)
Note: See TracBrowser for help on using the repository browser.