probe-file.lsp 1.31 KB
Newer Older
pfdietz's avatar
pfdietz committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Mon Jan  5 20:46:29 2004
;;;; Contains: Tests of PROBE-FILE

(in-package :cl-test)

(deftest probe-file.1
  (probe-file #p"nonexistent")
  nil)

(deftest probe-file.2
  (let ((s (open #p"probe-file.lsp" :direction :input)))
    (prog1
sds's avatar
sds committed
15
16
        (equalpt (truename #p"probe-file.lsp")
                 (probe-file s))
pfdietz's avatar
pfdietz committed
17
18
19
20
21
22
      (close s)))
  t)

(deftest probe-file.3
  (let ((s (open #p"probe-file.lsp" :direction :input)))
    (close s)
23
    (equalpt (truename #p"probe-file.lsp")
sds's avatar
sds committed
24
             (probe-file s)))
25
26
27
28
  t)

(deftest probe-file.4
  (equalpt (truename #p"probe-file.lsp")
sds's avatar
sds committed
29
           (probe-file "CLTEST:probe-file.lsp"))
pfdietz's avatar
pfdietz committed
30
31
  t)

32
33
34
35
36
37
38
39
40
;;; Specialized string tests

(deftest probe-file.5
  (do-special-strings
   (str "probe-file.lsp" nil)
   (let ((s (open str :direction :input)))
     (assert (equalpt (truename #p"probe-file.lsp") (probe-file s)))
     (close s)))
  nil)
sds's avatar
sds committed
41

42
43
;;; Error tests

pfdietz's avatar
pfdietz committed
44
(deftest probe-file.error.1
45
46
  (signals-error (probe-file) program-error)
  t)
pfdietz's avatar
pfdietz committed
47
48

(deftest probe-file.error.2
49
50
  (signals-error (probe-file #p"probe-file.lsp" nil) program-error)
  t)
pfdietz's avatar
pfdietz committed
51
52

(deftest probe-file.error.3
53
54
  (signals-error-always (probe-file (make-pathname :name :wild)) file-error)
  t t)
pfdietz's avatar
pfdietz committed
55

56
(deftest probe-file.error.4
57
58
  (signals-error-always (probe-file "CLTEST:*.FOO") file-error)
  t t)