-
Notifications
You must be signed in to change notification settings - Fork 464
/
Copy patha_filename_test.res
76 lines (67 loc) · 2.1 KB
/
a_filename_test.res
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
72
73
74
75
76
@var @scope("process")
external platform: [#aix | #darwin | #freebsd | #linux | #openbsd | #sunos | #win32] = "platform"
let suites: ref<Mt.pair_suites> = ref(list{})
let test_id = ref(0)
let eq = (loc, x, y) => {
incr(test_id)
suites :=
list{(loc ++ (" id " ++ string_of_int(test_id.contents)), _ => Mt.Eq(x, y)), ...suites.contents}
}
let test = Ext_filename_test.node_relative_path(true)
let () = /* TODO: adapt these tests to run on Windows. */
if platform !== #win32 {
eq(
__LOC__,
{
let \"//" = Ext_filename_test.combine
(
\"//"("/tmp", "subdir/file.txt"),
\"//"("/tmp", "/a/tmp.txt"),
\"//"("/a/tmp.txt", "subdir/file.txt"),
)
},
("/tmp/subdir/file.txt", "/a/tmp.txt", "/a/tmp.txt/subdir/file.txt"),
)
eq(__LOC__, test(#File("./a/b.c"), #File("./a/u/g.c")), "./u/g.c")
eq(
__LOC__,
test(#File("./a/b.c"), #File("xxxghsoghos/ghsoghso/node_modules/buckle-stdlib/list.js")),
"buckle-stdlib/list.js",
)
eq(
__LOC__,
test(#File("./a/b.c"), #File("xxxghsoghos/ghsoghso/node_modules//buckle-stdlib/list.js")),
"buckle-stdlib/list.js",
)
eq(
__LOC__,
test(#File("./a/b.c"), #File("xxxghsoghos/ghsoghso/node_modules/./buckle-stdlib/list.js")),
"buckle-stdlib/list.js",
)
eq(__LOC__, test(#File("./a/c.js"), #File("./a/b")), "./b")
eq(__LOC__, test(#File("./a/c"), #File("./a/b.js")), "./b.js")
eq(__LOC__, test(#Dir("./a/"), #File("./a/b.js")), "./b.js")
eq(__LOC__, Ext_filename_test.get_extension("a.txt"), ".txt")
eq(__LOC__, Ext_filename_test.get_extension("a"), "")
eq(__LOC__, Ext_filename_test.get_extension(".txt"), ".txt")
eq(
__LOC__,
Array.map(
Ext_filename_test.normalize_absolute_path,
[
"/gsho/./..",
"/a/b/../c../d/e/f",
"/a/b/../c/../d/e/f",
"/gsho/./../..",
"/a/b/c/d",
"/a/b/c/d/",
"/a/",
"/a",
"/a.txt/",
"/a.txt",
],
),
["/", "/a/c../d/e/f", "/a/d/e/f", "/", "/a/b/c/d", "/a/b/c/d", "/a", "/a", "/a.txt", "/a.txt"],
)
}
Mt.from_pair_suites(__MODULE__, suites.contents)