directory.lsp 1.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Thu Jan  1 12:00:18 2004
;;;; Contains: Tests of DIRECTORY

(in-package :cl-test)

(deftest directory.1
  (directory "nonexistent")
  nil)

(deftest directory.2
  (directory #p"nonexistent")
  nil)

(deftest directory.3
  (directory "nonexistent" :allow-other-keys nil)
  nil)

(deftest directory.4
  (directory "nonexistent" :allow-other-keys t :foo 'bar)
  nil)

(deftest directory.5
  (directory "nonexistent" :foo 0 :allow-other-keys t)
  nil)

(deftest directory.6
  (let* ((pattern-pathname (make-pathname :name :wild :type :wild
sds's avatar
sds committed
30 31
                                          :defaults *default-pathname-defaults*))
         (pathnames (directory pattern-pathname)))
32 33 34
    (values
     (remove-if #'pathnamep pathnames)
     (loop for pn in pathnames
sds's avatar
sds committed
35 36
           unless (equal pn (truename pn))
           collect pn)
37
;;     (loop for pn in pathnames
sds's avatar
sds committed
38 39
;;         unless (pathname-match-p pn pattern-pathname)
;;         collect pn))
40
     ))
41 42 43 44 45
  nil nil ;; nil
  )

(deftest directory.7
  (let* ((pattern-pathname (make-pathname :name :wild :type :wild
sds's avatar
sds committed
46 47
                                          :defaults *default-pathname-defaults*))
         (pathnames (directory pattern-pathname)))
48
    (loop for pn in pathnames
sds's avatar
sds committed
49 50
          unless (equal pn (probe-file pn))
          collect pn))
51 52 53 54
  nil)

(deftest directory.8
  (let* ((pathname-pattern "CLTEST:*.*")
sds's avatar
sds committed
55
         (len (length (directory pathname-pattern))))
56 57
    (if (< len 500) len nil))
  nil)
58

59 60 61 62 63 64 65 66 67 68
;;; Specialized string tests

(deftest directory.9
  (do-special-strings
   (s "nonexistent" nil)
   (assert (null (directory s))))
  nil)

;;; Error tests

69
(deftest directory.error.1
70 71
  (signals-error (directory) program-error)
  t)