Commit 362aa34a authored by pfdietz's avatar pfdietz

Added tests for TRUENAME, FILE-AUTHOR

parent 82f6e8e6
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Tue Jan 6 05:41:06 2004
;;;; Contains: Tests of FILE-AUTHOR
(in-package :cl-test)
(deftest file-author.1
(loop for pn in
(directory (make-pathname :name :wild :type :wild
:defaults *default-pathname-defaults*))
for author = (file-author pn)
unless (or (null author) (stringp author))
collect (list pn author))
nil)
(deftest file-author.2
(let ((author (file-author "file-author.lsp")))
(if (or (null author) (stringp author))
nil
author))
nil)
(deftest file-author.3
(let ((author (file-author #p"file-author.lsp")))
(if (or (null author) (stringp author))
nil
author))
nil)
(deftest file-author.4
(let ((author (file-author (truename "file-author.lsp"))))
(if (or (null author) (stringp author))
nil
author))
nil)
(deftest file-author.5
(let ((author (with-open-file (s "file-author.lsp" :direction :input)
(file-author s))))
(if (or (null author) (stringp author))
nil
author))
nil)
(deftest file-author.6
(let ((author (let ((s (open "file-author.lsp" :direction :input)))
(close s)
(file-author s))))
(if (or (null author) (stringp author))
nil
author))
nil)
;;; Error tests
(deftest file-author.error.1
(classify-error (file-author))
program-error)
(deftest file-author.error.2
(classify-error (file-author "file-author.lsp" nil))
program-error)
(deftest file-author.error.3
(classify-error
(file-author (make-pathname :name :wild :type "lsp"
:defaults *default-pathname-defaults*)))
file-error)
(deftest file-author.error.4
(classify-error
(file-author (make-pathname :name "file-author" :type :wild
:defaults *default-pathname-defaults*)))
file-error)
......@@ -8,3 +8,6 @@
(load "directory.lsp")
(load "probe-file.lsp")
(load "ensure-directories-exist.lsp")
(load "truename.lsp")
(load "file-author.lsp")
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Tue Jan 6 05:32:37 2004
;;;; Contains: Tests of TRUENAME
(in-package :cl-test)
(deftest truename.1
(let* ((pn #p"truename.lsp")
(tn (truename pn)))
(values
(notnot (pathnamep pn))
(typep pn 'logical-pathname)
(equalt (pathname-name pn) (pathname-name tn))
(equalt (pathname-type pn) (pathname-type tn))
))
t nil t t)
(deftest truename.2
(let* ((name "truename.lsp")
(pn (pathname name))
(tn (truename name)))
(values
(notnot (pathnamep pn))
(typep pn 'logical-pathname)
(equalt (pathname-name pn) (pathname-name tn))
(equalt (pathname-type pn) (pathname-type tn))
))
t nil t t)
(deftest truename.3
(let* ((pn #p"truename.lsp"))
(with-open-file
(s pn :direction :input)
(let ((tn (truename s)))
(values
(notnot (pathnamep pn))
(typep pn 'logical-pathname)
(equalt (pathname-name pn) (pathname-name tn))
(equalt (pathname-type pn) (pathname-type tn))
))))
t nil t t)
(deftest truename.4
(let* ((pn #p"truename.lsp"))
(let ((s (open pn :direction :input)))
(close s)
(let ((tn (truename s)))
(values
(notnot (pathnamep pn))
(typep pn 'logical-pathname)
(equalt (pathname-name pn) (pathname-name tn))
(equalt (pathname-type pn) (pathname-type tn))
))))
t nil t t)
;;;
(deftest truename.error.1
(classify-error (truename))
program-error)
(deftest truename.error.2
(classify-error (truename "truename.lsp" nil))
program-error)
(deftest truename.error.3
(classify-error (truename "nonexistent"))
file-error)
(deftest truename.error.4
(classify-error (truename #p"nonexistent"))
file-error)
(deftest truename.error.5
(classify-error (truename (logical-pathname "CLTESTROOT:nonexistent")))
file-error)
(deftest truename.error.6
(classify-error
(let ((pn (make-pathname :name :wild
:defaults *default-pathname-defaults*)))
(truename pn)))
file-error)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment