source: trunk/source/tests/ansi-tests/read-char.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.1 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Sun Jan 18 08:53:56 2004
4;;;; Contains: Tests of READ-CHAR
5
6(in-package :cl-test)
7
8(deftest read-char.1
9  (with-input-from-string
10   (*standard-input* "a")
11   (read-char))
12  #\a)
13
14(deftest read-char.2
15  (with-input-from-string
16   (*standard-input* "abc")
17   (values
18    (read-char)
19    (read-char)
20    (read-char)))
21  #\a #\b #\c)
22
23(when (code-char 0)
24  (deftest read-char.3
25    (with-input-from-string
26     (*standard-input* (concatenate 'string
27                                    "a"
28                                    (string (code-char 0))
29                                    "b"))
30     (values
31      (read-char)
32      (read-char)
33      (read-char)))
34    #\a #.(code-char 0) #\b))
35
36(deftest read-char.4
37  (with-input-from-string
38   (s "abc")
39   (values
40    (read-char s)
41    (read-char s)
42    (read-char s)))
43  #\a #\b #\c)
44
45(deftest read-char.5
46  (with-input-from-string
47   (s "")
48   (read-char s nil))
49  nil)
50
51(deftest read-char.6
52  (with-input-from-string
53   (s "")
54   (read-char s nil 'foo))
55  foo)
56
57(deftest read-char.7
58  (with-input-from-string
59   (s "abc")
60   (values
61    (read-char s nil nil)
62    (read-char s nil nil)
63    (read-char s nil nil)))
64  #\a #\b #\c)
65
66(deftest read-char.8
67  (with-input-from-string
68   (s "abc")
69   (values
70    (read-char s nil t)
71    (read-char s nil t)
72    (read-char s nil t)))
73  #\a #\b #\c)
74
75(deftest read-char.9
76  (with-input-from-string
77   (is "!?*")
78   (let ((*terminal-io* (make-two-way-stream is (make-string-output-stream))))
79     (read-char t)))
80  #\!)
81
82(deftest read-char.10
83  (with-input-from-string
84   (*standard-input* "345")
85   (read-char nil))
86  #\3)
87
88
89;;; Error tests
90
91(deftest read-char.error.1
92  (signals-error
93   (with-input-from-string
94    (s "abc")
95    (read-char s nil nil nil nil))
96   program-error)
97  t)
98
99(deftest read-char.error.2
100  (signals-error-always
101   (with-input-from-string
102    (s "")
103    (read-char s))
104   end-of-file)
105  t t)
106
107(deftest read-char.error.3
108  (signals-error-always
109   (with-input-from-string
110    (s "")
111    (read-char s t))
112   end-of-file)
113  t t)
114
115(deftest read-char.error.4
116  (signals-error-always
117   (with-input-from-string
118    (s "")
119    (read-char s t t))
120   end-of-file)
121  t t)
Note: See TracBrowser for help on using the repository browser.