~ chicken-core (master) /tests/path-tests.scm
Trap1(import (chicken pathname))23(define-syntax test4 (syntax-rules ()5 ((_ r x) (let ((y x)) (print y) (assert (equal? r y))))))67(test "/" (pathname-directory "/"))8(test "/" (pathname-directory "/abc"))9(test "abc" (pathname-directory "abc/"))10(test "abc" (pathname-directory "abc/def"))11(test "abc" (pathname-directory "abc/def.ghi"))12(test "abc" (pathname-directory "abc/.def.ghi"))13(test "abc" (pathname-directory "abc/.ghi"))14(test "/abc" (pathname-directory "/abc/"))15(test "/abc" (pathname-directory "/abc/def"))16(test "/abc" (pathname-directory "/abc/def.ghi"))17(test "/abc" (pathname-directory "/abc/.def.ghi"))18(test "/abc" (pathname-directory "/abc/.ghi"))19(test "q/abc" (pathname-directory "q/abc/"))20(test "q/abc" (pathname-directory "q/abc/def"))21(test "q/abc" (pathname-directory "q/abc/def.ghi"))22(test "q/abc" (pathname-directory "q/abc/.def.ghi"))23(test "q/abc" (pathname-directory "q/abc/.ghi"))2425(test "." (normalize-pathname "" 'unix))26(test "." (normalize-pathname "" 'windows))27(test "/" (normalize-pathname "/" 'unix))28(test "/" (normalize-pathname "/." 'unix))29(test "/" (normalize-pathname "/./" 'unix))30(test "/" (normalize-pathname "/./." 'unix))31(test "." (normalize-pathname "./" 'unix))32(test "a" (normalize-pathname "./a"))33(test "a" (normalize-pathname ".///a"))34(test "a" (normalize-pathname "a"))35(test "a/" (normalize-pathname "a/" 'unix))36(test "a/b" (normalize-pathname "a/b" 'unix))37(test "a\\b" (normalize-pathname "a\\b" 'unix))38(test "a/b/" (normalize-pathname "a/b/" 'unix))39(test "a/b/" (normalize-pathname "a/b//" 'unix))40(test "a/b" (normalize-pathname "a//b" 'unix))41(test "/a/b" (normalize-pathname "/a//b" 'unix))42(test "/a/b" (normalize-pathname "///a//b" 'unix))43(test "c:a/b" (normalize-pathname "c:a/./b" 'windows))44(test "c:/a/b" (normalize-pathname "c:/a/./b" 'unix))45(test "c:a/b" (normalize-pathname "c:a/./b" 'windows))46(test "c:b" (normalize-pathname "c:a/../b" 'windows))47(test "c:/b" (normalize-pathname "c:/a/../b" 'windows))48(test "a/b" (normalize-pathname "a/./././b" 'unix))49(test "a/b" (normalize-pathname "a/b/c/d/../.." 'unix))50(test "a/b/" (normalize-pathname "a/b/c/d/../../" 'unix))51(test "../../foo" (normalize-pathname "../../foo" 'unix))52(test "c:/" (normalize-pathname "c:/" 'windows))53(test "c:/" (normalize-pathname "c:/." 'windows))54(test "c:/" (normalize-pathname "c:/./" 'windows))55(test "c:/" (normalize-pathname "c:/./." 'windows))5657(test "~/foo" (normalize-pathname "~/foo" 'unix))58(test "c:~/foo" (normalize-pathname "c:~/foo" 'unix))59(test "c:~/foo" (normalize-pathname "c:~/foo" 'windows))6061(assert (directory-null? "/.//"))62(assert (directory-null? ""))63(assert (not (directory-null? "//foo//")))6465(test '(#f "/" (".")) (receive (decompose-directory "/.//")))6667(if ##sys#windows-platform68 (test '(#f "/" #f) (receive (decompose-directory "///\\///")))69 (test '(#f "/" ("\\")) (receive (decompose-directory "///\\///"))))7071(test '(#f "/" ("foo")) (receive (decompose-directory "//foo//")))72(test '(#f "/" ("foo" "bar")) (receive (decompose-directory "//foo//bar")))73(test '(#f #f (".")) (receive (decompose-directory ".//")))74(test '(#f #f ("." "foo")) (receive (decompose-directory ".//foo//")))75(test '(#f #f (" " "foo" "bar")) (receive (decompose-directory " //foo//bar")))76(test '(#f #f ("foo" "bar")) (receive (decompose-directory "foo//bar/")))7778(test '(#f #f #f) (receive (decompose-pathname "")))79(test '("/" #f #f) (receive (decompose-pathname "/")))8081(test '("/" "a" #f) (receive (decompose-pathname "/a")))8283(test '("/" #f #f) (receive (decompose-pathname "///")))8485(test '("/" "a" #f) (receive (decompose-pathname "///a")))8687(test '("/a" "b" #f) (receive (decompose-pathname "/a/b")))8889(test '("/a" "b" "c") (receive (decompose-pathname "/a/b.c")))9091(test '("." "a" #f) (receive (decompose-pathname "./a")))9293(test '("." "a" "b") (receive (decompose-pathname "./a.b")))9495(test '("./a" "b" #f) (receive (decompose-pathname "./a/b")))9697(test '(#f "a" #f) (receive (decompose-pathname "a")))98(test '(#f "a." #f) (receive (decompose-pathname "a.")))99(test '(#f ".a" #f) (receive (decompose-pathname ".a")))100(test '("a" "b" #f) (receive (decompose-pathname "a/b")))101102(test '("a" "b" #f) (receive (decompose-pathname "a///b")))103104(test '("a/b" "c" #f) (receive (decompose-pathname "a/b/c")))105106(test '("a/b/c" #f #f) (receive (decompose-pathname "a/b/c/")))107108(test '("a/b/c" #f #f) (receive (decompose-pathname "a/b/c///")))109110(test '(#f "a" "b") (receive (decompose-pathname "a.b")))111(test '("a.b" #f #f) (receive (decompose-pathname "a.b/")))112113(test '(#f "a.b" "c") (receive (decompose-pathname "a.b.c")))114(test '(#f "a." "b") (receive (decompose-pathname "a..b")))115(test '(#f "a.." "b") (receive (decompose-pathname "a...b")))116(test '("a." ".b" #f) (receive (decompose-pathname "a./.b")))117118 (test "x/y/z.q" (make-pathname "x/y" "z" "q"))119 (test "x/y/z.q" (make-pathname "x/y" "z.q"))120 (test "x/y/z.q" (make-pathname "x/y/" "z.q"))121 (test "x/y/z.q" (make-pathname "x/y/" "z.q"))122 (test "x/y\\/z.q" (make-pathname "x/y\\" "z.q"))123 (test "x//y/z.q" (make-pathname "x//y/" "z.q"))124 (test "x\\y/z.q" (make-pathname "x\\y" "z.q"))125126(test 'error (handle-exceptions _ 'error (make-pathname '(#f) "foo")))127128(test "/x/y/z" (make-pathname #f "/x/y/z"))129 (test "/x/y/z" (make-pathname "/" "x/y/z"))130 (test "/x/y/z" (make-pathname "/x" "/y/z"))131 (test "/x/y/z" (make-pathname '("/") "x/y/z"))132 (test "/x/y/z" (make-pathname '("/" "x") "y/z"))133 (test "/x/y/z" (make-pathname '("/x" "y") "z"))134 (test "/x/y/z/" (make-pathname '("/x" "y" "z") #f))