]> gitweb.factorcode.org Git - factor.git/blob - core/io/pathnames/pathnames-tests.factor
Merge branch 'master' into experimental
[factor.git] / core / io / pathnames / pathnames-tests.factor
1 USING: io.pathnames io.files.temp io.directories
2 continuations math io.files.private kernel
3 namespaces tools.test ;
4 IN: io.pathnames.tests
5
6 [ "passwd" ] [ "/etc/passwd" file-name ] unit-test
7 [ "awk" ] [ "/usr/libexec/awk/" file-name ] unit-test
8 [ "awk" ] [ "/usr/libexec/awk///" file-name ] unit-test
9 [ "" ] [ "" file-name ] unit-test
10
11 [ "freetype6.dll" ] [ "resource:freetype6.dll" file-name ] unit-test
12 [ "freetype6.dll" ] [ "resource:/freetype6.dll" file-name ] unit-test
13
14 [ "/usr/lib" ] [ "/usr" "lib" append-path ] unit-test
15 [ "/usr/lib" ] [ "/usr/" "lib" append-path ] unit-test
16 [ "/usr/lib" ] [ "/usr" "./lib" append-path ] unit-test
17 [ "/usr/lib/" ] [ "/usr" "./lib/" append-path ] unit-test
18 [ "/lib" ] [ "/usr" "../lib" append-path ] unit-test
19 [ "/lib/" ] [ "/usr" "../lib/" append-path ] unit-test
20
21 [ "" ] [ "" "." append-path ] unit-test
22 [ "" ".." append-path ] must-fail
23
24 [ "/" ] [ "/" "./." append-path ] unit-test
25 [ "/" ] [ "/" "././" append-path ] unit-test
26 [ "/a/b/lib" ] [ "/a/b/c/d/e/f/" "../../../../lib" append-path ] unit-test
27 [ "/a/b/lib/" ] [ "/a/b/c/d/e/f/" "../../../../lib/" append-path ] unit-test
28
29 [ "" "../lib/" append-path ] must-fail
30 [ "lib" ] [ "" "lib" append-path ] unit-test
31 [ "lib" ] [ "" "./lib" append-path ] unit-test
32
33 [ "foo/bar/." parent-directory ] must-fail
34 [ "foo/bar/./" parent-directory ] must-fail
35 [ "foo/bar/baz/.." parent-directory ] must-fail
36 [ "foo/bar/baz/../" parent-directory ] must-fail
37
38 [ "." parent-directory ] must-fail
39 [ "./" parent-directory ] must-fail
40 [ ".." parent-directory ] must-fail
41 [ "../" parent-directory ] must-fail
42 [ "../../" parent-directory ] must-fail
43 [ "foo/.." parent-directory ] must-fail
44 [ "foo/../" parent-directory ] must-fail
45 [ "" parent-directory ] must-fail
46 [ "." ] [ "boot.x86.64.image" parent-directory ] unit-test
47
48 [ "bar/foo" ] [ "bar/baz" "..///foo" append-path ] unit-test
49 [ "bar/baz/foo" ] [ "bar/baz" ".///foo" append-path ] unit-test
50 [ "bar/foo" ] [ "bar/baz" "./..//foo" append-path ] unit-test
51 [ "bar/foo" ] [ "bar/baz" "./../././././././///foo" append-path ] unit-test
52
53 [ t ] [ "resource:core" absolute-path? ] unit-test
54 [ f ] [ "" absolute-path? ] unit-test
55
56 [ "touch-twice-test" temp-file delete-file ] ignore-errors
57 [ ] [ 2 [ "touch-twice-test" temp-file touch-file ] times ] unit-test
58
59 ! aum's bug
60 [
61     "." current-directory set
62     ".." "resource-path" set
63     [ "../core/bootstrap/stage2.factor" ]
64     [ "resource:core/bootstrap/stage2.factor" (normalize-path) ]
65     unit-test
66 ] with-scope
67
68 [ t ] [ cwd "misc" resource-path [ ] with-directory cwd = ] unit-test