-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathpath.t
71 lines (47 loc) · 854 Bytes
/
path.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
(use test test-by-example)
(let r (runtime '(path))
(example-test r #<<.
> (path "abc")
"abc"
> (path "abc" "def")
"abc/def"
> (path "abc" "def" "ghi")
"abc/def/ghi"
> (dirpart "foo")
nil
> (dirpart "a/b/c/foo")
"a/b/c/"
> (dirpart "/a/b/c")
"/a/b/"
> (filepart "/a/b/c/")
nil
> (filepart "/a/b/c/foo.bar")
"foo.bar"
> (filepart "foo")
"foo"
> (extension "foo")
nil
> (extension "foo.")
nil
> (extension "foo.a")
"a"
> (extension "foo.a.")
nil
> (extension "foo.arc")
"arc"
> (extension "/a/b/c/foo.bar/")
nil
> (extension "/a/b/c/foo.bar")
"bar"
> (fullpath "/a/b/c/foo.bar")
"/a/b/c/foo.bar"
> (w/cwd "/tmp" (fullpath "foo.bar"))
"/tmp/foo.bar"
> (fullpath "foo.bar" "/tmp")
"/tmp/foo.bar"
> (fullpath "/tmp/a/b/../foo")
"/tmp/a/foo"
.
)
(testis (r!fullpath "~")
(+ (trim (tostring (system "cd ~; pwd"))) "/")))