;;;; absolutely no warranty. See the COPYING and CREDITS files for
;;;; more information.
-(in-package "CL-USER")
-
(load "assertoid.lisp")
+(use-package "ASSERTOID")
(setf (logical-pathname-translations "demo0")
'(("**;*.*.*" "/tmp/")))
;;; compelling reason for the implementors to choose case
;;; insensitivity and a canonical case.)
(setf (logical-pathname-translations "FOO")
- '(("**;*.*.*" "/full/path/to/foo/**/*.*.*")))
+ '(("**;*.*.*" "/full/path/to/foo/**/*.*")))
(let* ((pn1 (make-pathname :host "FOO" :directory "etc" :name "INETD"
:type "conf"))
(pn2 (make-pathname :host "foo" :directory "ETC" :name "inetd"
;;; FIXME: currently SBCL throws NAMESTRING-PARSE-ERROR: should this be
;;; a TYPE-ERROR?
-(assert (not (ignore-errors
- (make-pathname :host "FOO" :directory "!bla" :name "bar"))))
-
-;; error: name-component not valid
-(assert (not (ignore-errors
- (make-pathname :host "FOO" :directory "bla" :name "!bar"))))
-
-;; error: type-component not valid.
-(assert (not (ignore-errors
- (make-pathname :host "FOO" :directory "bla" :name "bar"
- :type "&baz"))))
+(locally
+ ;; MAKE-PATHNAME is UNSAFELY-FLUSHABLE
+ (declare (optimize safety))
+
+ (assert (not (ignore-errors
+ (make-pathname :host "FOO" :directory "!bla" :name "bar"))))
+
+ ;; error: name-component not valid
+ (assert (not (ignore-errors
+ (make-pathname :host "FOO" :directory "bla" :name "!bar"))))
+
+ ;; error: type-component not valid.
+ (assert (not (ignore-errors
+ (make-pathname :host "FOO" :directory "bla" :name "bar"
+ :type "&baz")))))
;;; We may need to parse the host as a LOGICAL-NAMESTRING HOST. The
;;; HOST in PARSE-NAMESTRING can be either a string or :UNSPECIFIC
;; FIXME: test version handling in LPNs
)
- do (assert (string= (namestring (apply #'merge-pathnames params))
- (namestring expected-result))))
+ do (let ((result (apply #'merge-pathnames params)))
+ (macrolet ((frob (op)
+ `(assert (equal (,op result) (,op expected-result)))))
+ (frob pathname-host)
+ (frob pathname-directory)
+ (frob pathname-name)
+ (frob pathname-type))))
\f
;;; host-namestring testing
(assert (string=
(assert (raises-error? (merge-pathnames (make-string-output-stream))
type-error))
\f
+;;; ensure read/print consistency (or print-not-readable-error) on
+;;; pathnames:
+(let ((pathnames (list
+ (make-pathname :name "foo" :type "txt" :version :newest)
+ (make-pathname :name "foo" :type "txt" :version 1)
+ (make-pathname :name "foo" :type ".txt")
+ (make-pathname :name "foo." :type "txt")
+ (parse-namestring "SCRATCH:FOO.TXT.1")
+ (parse-namestring "SCRATCH:FOO.TXT.NEWEST")
+ (parse-namestring "SCRATCH:FOO.TXT"))))
+ (dolist (p pathnames)
+ (handler-case
+ (let ((*print-readably* t))
+ (assert (equal (read-from-string (format nil "~S" p)) p)))
+ (print-not-readable () nil))))
+\f
;;;; success
(quit :unix-status 104)