X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fpathnames.impure.lisp;h=3d5c721f7974060b741a6cb7d59145c49dd2dc88;hb=cd13034f9415f64cdaa05893a4ac5ff1e95c97bd;hp=2219012db5de2566169756221ccc3c066100879c;hpb=1b64697e4e8a85ff8f11f5c05de71687dc5ad2e2;p=sbcl.git diff --git a/tests/pathnames.impure.lisp b/tests/pathnames.impure.lisp index 2219012..3d5c721 100644 --- a/tests/pathnames.impure.lisp +++ b/tests/pathnames.impure.lisp @@ -14,9 +14,8 @@ ;;;; 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/"))) @@ -64,7 +63,7 @@ ;;; 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" @@ -79,17 +78,21 @@ ;;; 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 @@ -261,8 +264,13 @@ ;; 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)))) ;;; host-namestring testing (assert (string= @@ -290,5 +298,21 @@ (assert (raises-error? (merge-pathnames (make-string-output-stream)) type-error)) +;;; 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)))) + ;;;; success (quit :unix-status 104)