Changeset 9979


Ignore:
Timestamp:
09/17/05 19:17:06 (16 years ago)
Author:
piso
Message:

CHECK-TRANSLATE-PATHNAME

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/j/src/org/armedbear/lisp/tests/pathname-tests.lisp

    r9978 r9979  
    5757              expected-version))))
    5858
     59(defun check-translate-pathname (args expected)
     60  (declare (optimize safety))
     61  (declare (type list args))
     62  (declare (type string expected))
     63  (let ((result (namestring (apply 'translate-pathname args))))
     64    (unless (equal result expected)
     65      (format t "(translate-pathname ~S ~S ~S) => ~S; expected ~S~%"
     66              (first args) (second args) (third args) result expected))))
     67
    5968(check-physical-pathname #p"/" '(:absolute) nil nil)
    6069(check-physical-pathname #p"/foo" '(:absolute) "foo" nil)
     
    146155(check-physical-pathname #p"effluvia:bar.baz.bop" nil "effluvia:bar.baz" "bop")
    147156
     157;; Parse error.
     158(expect (signals-error (logical-pathname "effluvia::foo.bar")
     159                       #-allegro 'parse-error
     160                       #+allegro 'type-error))
     161
    148162#-allegro
    149163(progn
     
    244258(expect (pathname-match-p "/usr/local/bin/foo.bar" "/**/foo.bar"))
    245259(expect (not (pathname-match-p "/usr/local/bin/foo.bar" "**/foo.bar")))
     260(expect (pathname-match-p "/foo/bar.txt" "/**/*.*"))
     261(expect (not (pathname-match-p "/foo/bar.txt" "**/*.*")))
    246262(expect (pathname-match-p #p"effluvia:foo.bar" #p"effluvia:**;*.*.*"))
    247263
     
    263279(expect (string= (namestring (translate-pathname "foo.bar" "*.*" "/usr/local/*.*"))
    264280                 "/usr/local/foo.bar"))
    265 (expect (equal (translate-pathname "foo.bar" "*.*" "/usr/local/*.*") #p"/usr/local/foo.bar"))
    266 
     281(expect (equal (translate-pathname "foo.bar" "*.*" "/usr/local/*.*")
     282               #p"/usr/local/foo.bar"))
     283
     284;; (expect (equal (translate-pathname "/foo/" "/*/" "/usr/local/*/") #p"/usr/local/foo/"))
     285(check-translate-pathname '("/foo/" "/*/" "/usr/local/*/") "/usr/local/foo/")
     286(check-translate-pathname '("/foo/baz/bar.txt" "/**/*.*" "/usr/local/**/*.*")
     287                          "/usr/local/foo/baz/bar.txt")
     288
     289(expect (equal (translate-pathname "/foo/" "/*/" "/usr/local/*/bar/") #p"/usr/local/foo/bar/"))
     290
     291(expect (equal (translate-pathname "/foo/bar.txt" "/*/*.*" "/usr/local/*/*.*")
     292               #P"/usr/local/foo/bar.txt"))
     293
     294;; "TRANSLATE-PATHNAME translates SOURCE (that matches FROM-WILDCARD)..."
     295(expect (not (pathname-match-p "/foo/bar.txt" "**/*.*")))
     296;; Since (pathname-match-p "/foo/bar.txt" "**/*.*" ) => NIL...
     297#+(or clisp allegro abcl)
     298;; This seems to be the correct behavior.
     299(expect (signals-error (translate-pathname "/foo/bar.txt" "**/*.*" "/usr/local/**/*.*") 'error))
     300#+(or sbcl cmu)
     301;; This appears to be a bug, since SOURCE doesn't match FROM-WILDCARD.
     302(expect (equal (translate-pathname "/foo/bar.txt" "**/*.*" "/usr/local/**/*.*")
     303               #p"/usr/local/foo/bar.txt"))
     304
     305(expect (pathname-match-p "/foo/bar.txt" "/**/*.*"))
     306(expect (equal (translate-pathname "/foo/bar.txt" "/**/*.*" "/usr/local/**/*.*")
     307               #p"/usr/local/foo/bar.txt"))
     308
     309;; TRANSLATE-LOGICAL-PATHNAME
    267310#-clisp
    268311(expect (equal (translate-pathname "foo.bar" "/**/*.*" "/usr/local/") #p"/usr/local/foo.bar"))
     
    275318  (expect (eq (pathname-device (translate-logical-pathname "effluvia:foo.bar")) :unspecific))
    276319  (expect (eq (pathname-device #p"/usr/local/foo/bar") nil)))
    277 (check-physical-pathname (translate-logical-pathname "effluvia:foo.bar")
    278                          '(:absolute "usr" "local") "foo" "bar")
     320;; (check-physical-pathname (translate-logical-pathname "effluvia:foo.bar")
     321;;                          '(:absolute "usr" "local") "foo" "bar")
     322(expect (string= (namestring (translate-logical-pathname "effluvia:foo.bar"))
     323                 "/usr/local/foo.bar"))
     324;; (check-physical-pathname (translate-logical-pathname "effluvia:foo;bar.txt")
     325;;                          '(:absolute "usr" "local" "foo") "bar" "txt")
     326(expect (string= (namestring (translate-logical-pathname "effluvia:foo;bar.txt"))
     327                 "/usr/local/foo/bar.txt"))
    279328
    280329#-allegro
Note: See TracChangeset for help on using the changeset viewer.