pathname-directory.lsp 3.03 KB
Newer Older
1 2 3 4 5 6 7
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Sat Dec  6 14:24:39 2003
;;;; Contains: Tests for PATHNAME-DIRECTORY

(in-package :cl-test)

pfdietz's avatar
pfdietz committed
8 9
(compile-and-load "pathnames-aux.lsp")

10 11
(deftest pathname-directory.1
  (loop for p in *pathnames*
sds's avatar
sds committed
12 13 14 15 16 17
        for directory = (pathname-directory p)
        unless (or (stringp directory)
                   (member directory '(nil :wild :unspecific))
                   (and (consp directory)
                        (member (car directory) '(:absolute :relative))))
        collect (list p directory))
18 19 20 21
  nil)

(deftest pathname-directory.2
  (loop for p in *pathnames*
sds's avatar
sds committed
22 23 24 25 26 27
        for directory = (pathname-directory p :case :local)
        unless (or (stringp directory)
                   (member directory '(nil :wild :unspecific))
                   (and (consp directory)
                        (member (car directory) '(:absolute :relative))))
        collect (list p directory))
28 29 30 31
  nil)

(deftest pathname-directory.3
  (loop for p in *pathnames*
sds's avatar
sds committed
32 33 34 35 36 37
        for directory = (pathname-directory p :case :common)
        unless (or (stringp directory)
                   (member directory '(nil :wild :unspecific))
                   (and (consp directory)
                        (member (car directory) '(:absolute :relative))))
        collect (list p directory))
38 39 40 41
  nil)

(deftest pathname-directory.4
  (loop for p in *pathnames*
sds's avatar
sds committed
42 43 44 45 46 47
        for directory = (pathname-directory p :allow-other-keys nil)
        unless (or (stringp directory)
                   (member directory '(nil :wild :unspecific))
                   (and (consp directory)
                        (member (car directory) '(:absolute :relative))))
        collect (list p directory))
48 49 50 51
  nil)

(deftest pathname-directory.5
  (loop for p in *pathnames*
sds's avatar
sds committed
52 53 54 55 56 57
        for directory = (pathname-directory p :foo 'bar :allow-other-keys t)
        unless (or (stringp directory)
                   (member directory '(nil :wild :unspecific))
                   (and (consp directory)
                        (member (car directory) '(:absolute :relative))))
        collect (list p directory))
58 59 60 61
  nil)

(deftest pathname-directory.6
  (loop for p in *pathnames*
sds's avatar
sds committed
62 63 64 65 66 67 68 69
        for directory = (pathname-directory p :allow-other-keys t
                                            :allow-other-keys nil
                                            'foo 'bar)
        unless (or (stringp directory)
                   (member directory '(nil :wild :unspecific))
                   (and (consp directory)
                        (member (car directory) '(:absolute :relative))))
        collect (list p directory))
70 71
  nil)

72 73 74
;;; section 19.3.2.1
(deftest pathname-directory.7
  (loop for p in *logical-pathnames*
sds's avatar
sds committed
75 76
        when (eq (pathname-directory p) :unspecific)
        collect p)
77 78
  nil)

pfdietz's avatar
pfdietz committed
79 80 81 82
(deftest pathname-directory.8
  (do-special-strings (s "" nil) (pathname-directory s))
  nil)

83
(deftest pathname-directory.error.1
84 85
  (signals-error (pathname-directory) program-error)
  t)
86 87

(deftest pathname-directory.error.2
pfdietz's avatar
pfdietz committed
88
  (check-type-error #'pathname-directory #'could-be-pathname-designator)
89
  nil)