clear-input.lsp 1.39 KB
Newer Older
pfdietz's avatar
pfdietz committed
1 2 3 4 5 6 7 8 9 10 11 12
;-*- 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*
sds's avatar
sds committed
13 14
                       *standard-input* *terminal-io*)
        always (eq (clear-input s) nil))
pfdietz's avatar
pfdietz committed
15 16 17 18 19 20 21 22 23 24 25 26 27 28
  t)

(deftest clear-input.2
  (clear-input)
  nil)

(deftest clear-input.3
  (clear-input nil)
  nil)

(deftest clear-input.4
  (clear-input t)
  nil)

29 30 31
(deftest clear-input.5
  (with-input-from-string
   (is "!?*")
pfdietz's avatar
pfdietz committed
32
   (let ((*terminal-io* (make-two-way-stream is (make-broadcast-stream))))
33 34 35 36 37 38 39 40 41
     (clear-input t)))
  nil)

(deftest clear-input.6
  (with-input-from-string
   (*standard-input* "345")
   (clear-input nil))
  nil)

pfdietz's avatar
pfdietz committed
42 43 44
;;; Error cases

(deftest clear-input.error.1
45
  :notes (:assume-no-simple-streams)
pfdietz's avatar
pfdietz committed
46 47 48 49
  (signals-error (clear-input t nil) program-error)
  t)

(deftest clear-input.error.2
50
  :notes (:assume-no-simple-streams)
pfdietz's avatar
pfdietz committed
51 52 53 54
  (signals-error (clear-input nil nil) program-error)
  t)

(deftest clear-input.error.3
55 56 57 58 59 60 61 62
  (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
63
  (check-type-error #'clear-input #'(lambda (x) (typep x '(or stream (member nil t)))))
pfdietz's avatar
pfdietz committed
64
  nil)