-
Notifications
You must be signed in to change notification settings - Fork 4
/
clear-input.lsp
64 lines (50 loc) · 1.39 KB
/
clear-input.lsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Wed Jan 28 06:12:39 2004
;;;; Contains: Tests of CLEAR-INPUT
(in-package :cl-test)
;;; These tests are limited, since whether an input stream can be
;;; cleared is not well specified.
(deftest clear-input.1
(loop for s in (list *debug-io* *query-io*
*standard-input* *terminal-io*)
always (eq (clear-input s) nil))
t)
(deftest clear-input.2
(clear-input)
nil)
(deftest clear-input.3
(clear-input nil)
nil)
(deftest clear-input.4
(clear-input t)
nil)
(deftest clear-input.5
(with-input-from-string
(is "!?*")
(let ((*terminal-io* (make-two-way-stream is (make-broadcast-stream))))
(clear-input t)))
nil)
(deftest clear-input.6
(with-input-from-string
(*standard-input* "345")
(clear-input nil))
nil)
;;; Error cases
(deftest clear-input.error.1
:notes (:assume-no-simple-streams)
(signals-error (clear-input t nil) program-error)
t)
(deftest clear-input.error.2
:notes (:assume-no-simple-streams)
(signals-error (clear-input nil nil) program-error)
t)
(deftest clear-input.error.3
(signals-error (clear-input t nil nil) program-error)
t)
(deftest clear-input.error.4
(signals-error (clear-input nil nil nil) program-error)
t)
(deftest clear-input.error.5
(check-type-error #'clear-input #'(lambda (x) (typep x '(or stream (member nil t)))))
nil)