source: trunk/source/tests/ansi-tests/unread-char.lsp @ 8991

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

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

File size: 1.8 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Sun Jan 18 20:05:36 2004
4;;;; Contains: Tests of UNREAD-CHAR
5
6(in-package :cl-test)
7
8(deftest unread-char.1
9  (with-input-from-string
10   (*standard-input* "abc")
11   (values
12    (read-char)
13    (unread-char #\a)
14    (read-char)
15    (read-char)
16    (unread-char #\b)
17    (read-char)
18    (read-char)))
19  #\a nil #\a #\b nil #\b #\c)
20
21(deftest unread-char.2
22  (with-input-from-string
23   (s "abc")
24   (values
25    (read-char s)
26    (unread-char #\a s)
27    (read-char s)
28    (read-char s)
29    (unread-char #\b s)
30    (read-char s)
31    (read-char s)))
32  #\a nil #\a #\b nil #\b #\c)
33
34(deftest unread-char.3
35  (with-input-from-string
36   (is "abc")
37   (with-output-to-string
38     (os)
39     (let ((s (make-echo-stream is os)))
40       (read-char s)
41       (unread-char #\a s)
42       (read-char s)
43       (read-char s)
44       (read-char s)
45       (unread-char #\c s)
46       (read-char s))))
47  "abc")
48
49(deftest unread-char.4
50  (with-input-from-string
51   (*standard-input* "abc")
52   (values
53    (read-char)
54    (unread-char #\a nil)
55    (read-char)
56    (read-char)
57    (unread-char #\b nil)
58    (read-char)
59    (read-char)))
60  #\a nil #\a #\b nil #\b #\c)
61
62(deftest unread-char.5
63  (with-input-from-string
64   (is "abc")
65   (let ((*terminal-io* (make-two-way-stream
66                         is (make-string-output-stream))))
67     (values
68      (read-char t)
69      (unread-char #\a t)
70      (read-char t)
71      (read-char t)
72      (unread-char #\b t)
73      (read-char t)
74      (read-char t))))
75  #\a nil #\a #\b nil #\b #\c)
76
77;;; Error tests
78
79(deftest unread-char.error.1
80  (signals-error (unread-char) program-error)
81  t)
82
83(deftest unread-char.error.2
84  (signals-error
85   (with-input-from-string
86    (s "abc")
87    (read-char s)
88    (unread-char #\a s nil))
89   program-error)
90  t)
91
92
Note: See TracBrowser for help on using the repository browser.