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