+ 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=
+ (namestring (parse-namestring "/foo" (host-namestring #p"/bar")))
+ "/foo"))
+(assert (string=
+ (namestring (parse-namestring "FOO" (host-namestring #p"SCRATCH:BAR")))
+ "SCRATCH:FOO"))
+(assert (raises-error?
+ (setf (logical-pathname-translations "")
+ (list '("**;*.*.*" "/**/*.*")))))
+\f
+;;; Bug 200: translate-logical-pathname is according to the spec supposed
+;;; not to give errors if asked to translate a namestring for a valid
+;;; physical pathname. Failed in 0.7.7.28 and before
+(assert (string= (namestring (translate-logical-pathname "/")) "/"))
+
+\f
+;;; Not strictly pathname logic testing, but until sbcl-0.7.6.19 we
+;;; had difficulty with non-FILE-STREAM stream arguments to pathname
+;;; functions (they would cause memory protection errors). Make sure
+;;; that those errors are gone:
+(assert (raises-error? (pathname (make-string-input-stream "FOO"))
+ type-error))
+(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
+;;; 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))))