open-stream-p.lsp 1.38 KB
Newer Older
1 2 3 4 5 6 7 8 9
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Tue Jan 13 19:52:30 2004
;;;; Contains: Tests of OPEN-STREAM-P

(in-package :cl-test)

(deftest open-stream-p.1
  (loop for s in (list *debug-io* *error-output* *query-io*
sds's avatar
sds committed
10 11 12 13 14 15
                       *standard-input* *standard-output*
                       *trace-output* *terminal-io*)
        for results = (multiple-value-list (open-stream-p s))
        unless (and (eql (length results) 1)
                    (car results))
        collect s)
16 17 18 19
  nil)

(deftest open-stream-p.2
  (with-open-file (s "open-stream-p.lsp" :direction :input)
sds's avatar
sds committed
20
                  (notnot-mv (open-stream-p s)))
21 22 23 24
  t)

(deftest open-stream-p.3
  (with-open-file (s "foo.txt" :direction :output
sds's avatar
sds committed
25 26
                     :if-exists :supersede)
                  (notnot-mv (open-stream-p s)))
27 28 29 30 31 32 33 34 35 36
  t)

(deftest open-stream-p.4
  (let ((s (open "open-stream-p.lsp" :direction :input)))
    (close s)
    (open-stream-p s))
  nil)

(deftest open-stream-p.5
  (let ((s (open "foo.txt" :direction :output
sds's avatar
sds committed
37
                 :if-exists :supersede)))
38 39 40 41 42 43 44
    (close s)
    (open-stream-p s))
  nil)

;;; error tests

(deftest open-stream-p.error.1
45 46
  (signals-error (open-stream-p) program-error)
  t)
47 48

(deftest open-stream-p.error.2
49 50
  (signals-error (open-stream-p *standard-input* nil) program-error)
  t)
51

pfdietz's avatar
pfdietz committed
52
(deftest open-stream-p.error.3
pfdietz's avatar
pfdietz committed
53
  (check-type-error #'open-stream-p #'streamp)
54
  nil)