forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patha_filename_test.ml
109 lines (98 loc) · 2.35 KB
/
a_filename_test.ml
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
external platform : [ `aix | `darwin | `freebsd | `linux | `openbsd | `sunos | `win32 ]
= "platform" [@@var] [@@scope "process"]
let suites : Mt.pair_suites ref = ref []
let test_id = ref 0
let eq loc x y =
incr test_id ;
suites :=
(loc ^" id " ^ (string_of_int !test_id), (fun _ -> Mt.Eq(x,y))) :: !suites
let test = Ext_filename_test.node_relative_path true
let () =
(* TODO: adapt these tests to run on Windows. *)
if platform != `win32 then (
eq __LOC__
(let (//) = Ext_filename_test.combine in
("/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