file-error.lsp 2.62 KB
Newer Older
1
2
3
4
5
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Tue Jan 13 19:10:02 2004
;;;; Contains: Tests of the FILE-ERROR condition, and associated accessor function

Daniel Kochmański's avatar
Daniel Kochmański committed
6

7
8
9

(deftest file-error.1
  (let ((pn (make-pathname :name :wild
sds's avatar
sds committed
10
11
12
                           :type "txt"
                           :version :newest
                           :defaults *default-pathname-defaults*)))
13
14
15
    (handler-case
     (probe-file pn)
     (error (c)
sds's avatar
sds committed
16
17
18
19
20
            (values
             (notnot (typep c 'file-error))
             (if (equalp (file-error-pathname c) pn)
                 t
               (list (file-error-pathname c) pn))))))
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
  t t)

(deftest file-error-pathname.1
  (let ((c (make-condition 'file-error :pathname "foo.txt")))
    (values
     (notnot (typep c 'file-error))
     (eqlt (class-of c) (find-class 'file-error))
     (file-error-pathname c)))
  t t "foo.txt")

(deftest file-error-pathname.2
  (let ((c (make-condition 'file-error :pathname #p"foo.txt")))
    (values
     (notnot (typep c 'file-error))
     (eqlt (class-of c) (find-class 'file-error))
     (equalt #p"foo.txt" (file-error-pathname c))))
  t t t)

(deftest file-error-pathname.3
  (let ((c (make-condition 'file-error :pathname "CLTEST:foo.txt")))
    (values
     (notnot (typep c 'file-error))
     (eqlt (class-of c) (find-class 'file-error))
     (equalpt "CLTEST:foo.txt"
sds's avatar
sds committed
45
              (file-error-pathname c))))
46
47
48
49
50
51
52
53
  t t t)

(deftest file-error-pathname.4
  (let ((c (make-condition 'file-error :pathname (logical-pathname "CLTEST:foo.txt"))))
    (values
     (notnot (typep c 'file-error))
     (eqlt (class-of c) (find-class 'file-error))
     (equalpt (logical-pathname "CLTEST:foo.txt")
sds's avatar
sds committed
54
              (file-error-pathname c))))
55
56
57
58
  t t t)

(deftest file-error-pathname.5
  (with-open-file (s "file-error.lsp" :direction :input)
sds's avatar
sds committed
59
60
61
62
63
                  (let ((c (make-condition 'file-error :pathname s)))
                    (values
                     (notnot (typep c 'file-error))
                     (eqlt (class-of c) (find-class 'file-error))
                     (equalpt s (file-error-pathname c)))))
64
65
66
67
68
69
70
71
72
73
74
75
76
  t t t)

(deftest file-error-pathname.6
  (let ((s (open "file-error.lsp" :direction :input)))
    (close s)
    (let ((c (make-condition 'file-error :pathname s)))
      (values
       (notnot (typep c 'file-error))
       (eqlt (class-of c) (find-class 'file-error))
       (equalpt s (file-error-pathname c)))))
  t t t)

(deftest file-error-pathname.error.1
77
78
  (signals-error (file-error-pathname) program-error)
  t)
79
80

(deftest file-error-pathname.error.2
81
82
83
84
  (signals-error
   (file-error-pathname (make-condition 'file-error :pathname "foo.txt") nil)
   program-error)
  t)
85
86
87
88
89