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

(in-package :cl-test)

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

pfdietz's avatar
pfdietz committed
13 14 15 16 17 18 19 20
(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
21 22 23
        :direction :output
        :if-exists :supersede
        :if-does-not-exist :create)
pfdietz's avatar
pfdietz committed
24
     (or (equalt (logical-pathname s) (logical-pathname name))
sds's avatar
sds committed
25
         (list (logical-pathname s) (logical-pathname name)))))
pfdietz's avatar
pfdietz committed
26 27
  t)

28

29 30 31
;;; Error tests

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

36 37 38 39 40 41 42 43
(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
   (with-open-file (s #p"logical-pathname.lsp" :direction :input)
sds's avatar
sds committed
44
                   (logical-pathname s))
45 46 47
   type-error)
  t)

pfdietz's avatar
pfdietz committed
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 80 81
(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
82
                                   (logical-pathname s)) type-error)
pfdietz's avatar
pfdietz committed
83 84 85 86 87 88 89
  t)

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

(deftest logical-pathname.error.10
pfdietz's avatar
pfdietz committed
90 91 92
  (handler-case
   (progn (eval '(locally (declare (optimize safety)) (logical-pathname "CLROOT:%"))) t)
   (type-error () t))
pfdietz's avatar
pfdietz committed
93
  t)