logical-pathname.lsp 2.41 KB
Newer Older
1 2 3 4 5 6 7
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Tue Dec 30 19:05:01 2003
;;;; Contains: Tests of LOGICAL-PATHNAME

(deftest logical-pathname.1
  (loop for x in *logical-pathnames*
sds's avatar
sds committed
8
        always (eql x (logical-pathname x)))
9 10
  t)

11 12 13 14 15 16 17 18
(deftest logical-pathname.2
  (notnot-mv (typep (logical-pathname "CLTEST:FOO") 'logical-pathname))
  t)

(deftest logical-pathname.3
  (let ((name "CLTEST:TEMP.DAT.NEWEST"))
    (with-open-file
     (s (logical-pathname name)
sds's avatar
sds committed
19 20 21
        :direction :output
        :if-exists :supersede
        :if-does-not-exist :create)
22
     (or (equalt (logical-pathname s) (logical-pathname name))
sds's avatar
sds committed
23
         (list (logical-pathname s) (logical-pathname name)))))
24 25
  t)

26

27 28 29
;;; Error tests

(deftest logical-pathname.error.1
pfdietz's avatar
pfdietz committed
30
  (check-type-error #'logical-pathname
sds's avatar
sds committed
31
                    (typef '(or string stream logical-pathname)))
32 33
  nil)

34 35 36 37 38 39 40
(deftest logical-pathname.error.2
  ;; Doesn't specify a host
  (signals-error (logical-pathname "FOO.TXT") type-error)
  t)

(deftest logical-pathname.error.3
  (signals-error
41
   (with-open-file (s #p"logical-pathname.txt" :direction :input)
sds's avatar
sds committed
42
                   (logical-pathname s))
43 44 45
   type-error)
  t)

46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
(deftest logical-pathname.error.4
  (signals-error
   (with-open-stream
    (is (make-concatenated-stream))
    (with-open-stream
     (os (make-broadcast-stream))
     (with-open-stream
      (s (make-two-way-stream is os))
      (logical-pathname s))))
   type-error)
  t)

(deftest logical-pathname.error.5
  (signals-error
   (with-open-stream
    (is (make-concatenated-stream))
    (with-open-stream
     (os (make-broadcast-stream))
     (with-open-stream
      (s (make-echo-stream is os))
      (logical-pathname s))))
   type-error)
  t)

(deftest logical-pathname.error.6
  (signals-error (with-open-stream (s (make-broadcast-stream)) (logical-pathname s)) type-error)
  t)

(deftest logical-pathname.error.7
  (signals-error (with-open-stream (s (make-concatenated-stream)) (logical-pathname s)) type-error)
  t)

(deftest logical-pathname.error.8
  (signals-error (with-open-stream (s (make-string-input-stream "foo"))
sds's avatar
sds committed
80
                                   (logical-pathname s)) type-error)
81 82 83 84 85 86 87
  t)

(deftest logical-pathname.error.9
  (signals-error (with-output-to-string (s) (logical-pathname s)) type-error)
  t)

(deftest logical-pathname.error.10
88 89 90
  (handler-case
   (progn (eval '(locally (declare (optimize safety)) (logical-pathname "CLROOT:%"))) t)
   (type-error () t))
91
  t)