X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fpathnames.impure.lisp;h=bb23ae0f1adc67b51960fc33caccb9e6ba982ab0;hb=9b55754d5328a5f44ee224d32865fc8dadee123b;hp=9b93d337d9fdd265219a5d167a29fe5d3a50a7f9;hpb=696e38f7210c587ba0b54795f4795f58e62fed2d;p=sbcl.git diff --git a/tests/pathnames.impure.lisp b/tests/pathnames.impure.lisp index 9b93d33..bb23ae0 100644 --- a/tests/pathnames.impure.lisp +++ b/tests/pathnames.impure.lisp @@ -264,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= @@ -293,5 +298,46 @@ (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) + (print p) + (handler-case + (let ((*print-readably* t)) + (assert (equal (read-from-string (format nil "~S" p)) p))) + (print-not-readable () nil)))) + +;;; BUG 330: "PARSE-NAMESTRING should accept namestrings as the +;;; default argument" ...and streams as well +(assert (equal (parse-namestring "foo" nil "/") + (parse-namestring "foo" nil #P"/"))) +(let ((test "parse-namestring-test.tmp")) + (unwind-protect + (with-open-file (f test :direction :output) + ;; FIXME: This test is a bit flaky, since we only check that + ;; no error is signalled. The dilemma here is "what is the + ;; correct result when defaults is a _file_, not a + ;; directory". Currently (0.8.10.73) we get #P"foo" here (as + ;; opposed to eg. #P"/path/to/current/foo"), which is + ;; possibly mildly surprising but probably conformant. + (assert (parse-namestring "foo" nil f))) + (when (probe-file test) + (delete-file test)))) + +;;; ENOUGH-NAMESTRING should probably not fail when the namestring in +;;; question has a :RELATIVE pathname. +(assert (equal (enough-namestring #p"foo" #p"./") "foo")) + +;;; bug reported by Artem V. Andreev: :WILD not handled in unparsing +;;; directory lists. +(assert (equal (namestring #p"/tmp/*/") "/tmp/*/")) ;;;; success (quit :unix-status 104)