Commit | Line | Data |
3149a8e4 |
1 | #!./perl |
270d1e39 |
2 | |
3 | BEGIN { |
3149a8e4 |
4 | $^O = ''; |
5 | chdir 't' if -d 't'; |
20822f61 |
6 | @INC = '../lib'; |
270d1e39 |
7 | } |
8 | |
0994714a |
9 | # Each element in this array is a single test. Storing them this way makes |
10 | # maintenance easy, and should be OK since perl should be pretty functional |
11 | # before these tests are run. |
3149a8e4 |
12 | |
0994714a |
13 | @tests = ( |
14 | # Function Expected |
15 | [ "Unix->catfile('a','b','c')", 'a/b/c' ], |
270d1e39 |
16 | |
0994714a |
17 | [ "Unix->splitpath('file')", ',,file' ], |
18 | [ "Unix->splitpath('/d1/d2/d3/')", ',/d1/d2/d3/,' ], |
19 | [ "Unix->splitpath('d1/d2/d3/')", ',d1/d2/d3/,' ], |
20 | [ "Unix->splitpath('/d1/d2/d3/.')", ',/d1/d2/d3/.,' ], |
21 | [ "Unix->splitpath('/d1/d2/d3/..')", ',/d1/d2/d3/..,' ], |
22 | [ "Unix->splitpath('/d1/d2/d3/.file')", ',/d1/d2/d3/,.file' ], |
23 | [ "Unix->splitpath('d1/d2/d3/file')", ',d1/d2/d3/,file' ], |
24 | [ "Unix->splitpath('/../../d1/')", ',/../../d1/,' ], |
25 | [ "Unix->splitpath('/././d1/')", ',/././d1/,' ], |
270d1e39 |
26 | |
0994714a |
27 | [ "Unix->catpath('','','file')", 'file' ], |
28 | [ "Unix->catpath('','/d1/d2/d3/','')", '/d1/d2/d3/' ], |
29 | [ "Unix->catpath('','d1/d2/d3/','')", 'd1/d2/d3/' ], |
30 | [ "Unix->catpath('','/d1/d2/d3/.','')", '/d1/d2/d3/.' ], |
31 | [ "Unix->catpath('','/d1/d2/d3/..','')", '/d1/d2/d3/..' ], |
32 | [ "Unix->catpath('','/d1/d2/d3/','.file')", '/d1/d2/d3/.file' ], |
33 | [ "Unix->catpath('','d1/d2/d3/','file')", 'd1/d2/d3/file' ], |
34 | [ "Unix->catpath('','/../../d1/','')", '/../../d1/' ], |
35 | [ "Unix->catpath('','/././d1/','')", '/././d1/' ], |
36 | [ "Unix->catpath('d1','d2/d3/','')", 'd2/d3/' ], |
37 | [ "Unix->catpath('d1','d2','d3/')", 'd2/d3/' ], |
270d1e39 |
38 | |
0994714a |
39 | [ "Unix->splitdir('')", '' ], |
40 | [ "Unix->splitdir('/d1/d2/d3/')", ',d1,d2,d3,' ], |
41 | [ "Unix->splitdir('d1/d2/d3/')", 'd1,d2,d3,' ], |
42 | [ "Unix->splitdir('/d1/d2/d3')", ',d1,d2,d3' ], |
43 | [ "Unix->splitdir('d1/d2/d3')", 'd1,d2,d3' ], |
270d1e39 |
44 | |
0994714a |
45 | [ "Unix->catdir()", '' ], |
46 | [ "Unix->catdir('/')", '/' ], |
47 | [ "Unix->catdir('','d1','d2','d3','')", '/d1/d2/d3' ], |
48 | [ "Unix->catdir('d1','d2','d3','')", 'd1/d2/d3' ], |
49 | [ "Unix->catdir('','d1','d2','d3')", '/d1/d2/d3' ], |
50 | [ "Unix->catdir('d1','d2','d3')", 'd1/d2/d3' ], |
51 | |
52 | [ "Unix->catfile('a','b','c')", 'a/b/c' ], |
53 | |
54 | [ "Unix->canonpath('')", '' ], |
55 | [ "Unix->canonpath('///../../..//./././a//b/.././c/././')", '/a/b/../c' ], |
6bf11762 |
56 | [ "Unix->canonpath('/.')", '/' ], |
57 | [ "Unix->canonpath('/./')", '/' ], |
58 | [ "Unix->canonpath('/a/./')", '/a' ], |
59 | [ "Unix->canonpath('/a/.')", '/a' ], |
0994714a |
60 | |
61 | [ "Unix->abs2rel('/t1/t2/t3','/t1/t2/t3')", '' ], |
62 | [ "Unix->abs2rel('/t1/t2/t4','/t1/t2/t3')", '../t4' ], |
63 | [ "Unix->abs2rel('/t1/t2','/t1/t2/t3')", '..' ], |
64 | [ "Unix->abs2rel('/t1/t2/t3/t4','/t1/t2/t3')", 't4' ], |
65 | [ "Unix->abs2rel('/t4/t5/t6','/t1/t2/t3')", '../../../t4/t5/t6' ], |
66 | #[ "Unix->abs2rel('../t4','/t1/t2/t3')", '../t4' ], |
67 | [ "Unix->abs2rel('/','/t1/t2/t3')", '../../..' ], |
68 | [ "Unix->abs2rel('///','/t1/t2/t3')", '../../..' ], |
6bf11762 |
69 | [ "Unix->abs2rel('/.','/t1/t2/t3')", '../../..' ], |
0994714a |
70 | [ "Unix->abs2rel('/./','/t1/t2/t3')", '../../..' ], |
71 | #[ "Unix->abs2rel('../t4','/t1/t2/t3')", '../t4' ], |
72 | |
73 | [ "Unix->rel2abs('t4','/t1/t2/t3')", '/t1/t2/t3/t4' ], |
74 | [ "Unix->rel2abs('t4/t5','/t1/t2/t3')", '/t1/t2/t3/t4/t5' ], |
75 | [ "Unix->rel2abs('.','/t1/t2/t3')", '/t1/t2/t3' ], |
76 | [ "Unix->rel2abs('..','/t1/t2/t3')", '/t1/t2/t3/..' ], |
77 | [ "Unix->rel2abs('../t4','/t1/t2/t3')", '/t1/t2/t3/../t4' ], |
78 | [ "Unix->rel2abs('/t1','/t1/t2/t3')", '/t1' ], |
79 | |
80 | [ "Win32->splitpath('file')", ',,file' ], |
81 | [ "Win32->splitpath('\\d1/d2\\d3/')", ',\\d1/d2\\d3/,' ], |
82 | [ "Win32->splitpath('d1/d2\\d3/')", ',d1/d2\\d3/,' ], |
83 | [ "Win32->splitpath('\\d1/d2\\d3/.')", ',\\d1/d2\\d3/.,' ], |
84 | [ "Win32->splitpath('\\d1/d2\\d3/..')", ',\\d1/d2\\d3/..,' ], |
85 | [ "Win32->splitpath('\\d1/d2\\d3/.file')", ',\\d1/d2\\d3/,.file' ], |
86 | [ "Win32->splitpath('\\d1/d2\\d3/file')", ',\\d1/d2\\d3/,file' ], |
87 | [ "Win32->splitpath('d1/d2\\d3/file')", ',d1/d2\\d3/,file' ], |
88 | [ "Win32->splitpath('C:\\d1/d2\\d3/')", 'C:,\\d1/d2\\d3/,' ], |
89 | [ "Win32->splitpath('C:d1/d2\\d3/')", 'C:,d1/d2\\d3/,' ], |
90 | [ "Win32->splitpath('C:\\d1/d2\\d3/file')", 'C:,\\d1/d2\\d3/,file' ], |
91 | [ "Win32->splitpath('C:d1/d2\\d3/file')", 'C:,d1/d2\\d3/,file' ], |
92 | [ "Win32->splitpath('C:\\../d2\\d3/file')", 'C:,\\../d2\\d3/,file' ], |
93 | [ "Win32->splitpath('C:../d2\\d3/file')", 'C:,../d2\\d3/,file' ], |
94 | [ "Win32->splitpath('\\../..\\d1/')", ',\\../..\\d1/,' ], |
95 | [ "Win32->splitpath('\\./.\\d1/')", ',\\./.\\d1/,' ], |
96 | [ "Win32->splitpath('\\\\node\\share\\d1/d2\\d3/')", '\\\\node\\share,\\d1/d2\\d3/,' ], |
97 | [ "Win32->splitpath('\\\\node\\share\\d1/d2\\d3/file')", '\\\\node\\share,\\d1/d2\\d3/,file' ], |
98 | [ "Win32->splitpath('\\\\node\\share\\d1/d2\\file')", '\\\\node\\share,\\d1/d2\\,file' ], |
99 | [ "Win32->splitpath('file',1)", ',file,' ], |
100 | [ "Win32->splitpath('\\d1/d2\\d3/',1)", ',\\d1/d2\\d3/,' ], |
101 | [ "Win32->splitpath('d1/d2\\d3/',1)", ',d1/d2\\d3/,' ], |
102 | [ "Win32->splitpath('\\\\node\\share\\d1/d2\\d3/',1)", '\\\\node\\share,\\d1/d2\\d3/,' ], |
103 | |
104 | [ "Win32->catpath('','','file')", 'file' ], |
105 | [ "Win32->catpath('','\\d1/d2\\d3/','')", '\\d1/d2\\d3/' ], |
106 | [ "Win32->catpath('','d1/d2\\d3/','')", 'd1/d2\\d3/' ], |
107 | [ "Win32->catpath('','\\d1/d2\\d3/.','')", '\\d1/d2\\d3/.' ], |
108 | [ "Win32->catpath('','\\d1/d2\\d3/..','')", '\\d1/d2\\d3/..' ], |
109 | [ "Win32->catpath('','\\d1/d2\\d3/','.file')", '\\d1/d2\\d3/.file' ], |
110 | [ "Win32->catpath('','\\d1/d2\\d3/','file')", '\\d1/d2\\d3/file' ], |
111 | [ "Win32->catpath('','d1/d2\\d3/','file')", 'd1/d2\\d3/file' ], |
112 | [ "Win32->catpath('C:','\\d1/d2\\d3/','')", 'C:\\d1/d2\\d3/' ], |
113 | [ "Win32->catpath('C:','d1/d2\\d3/','')", 'C:d1/d2\\d3/' ], |
114 | [ "Win32->catpath('C:','\\d1/d2\\d3/','file')", 'C:\\d1/d2\\d3/file' ], |
115 | [ "Win32->catpath('C:','d1/d2\\d3/','file')", 'C:d1/d2\\d3/file' ], |
116 | [ "Win32->catpath('C:','\\../d2\\d3/','file')", 'C:\\../d2\\d3/file' ], |
117 | [ "Win32->catpath('C:','../d2\\d3/','file')", 'C:../d2\\d3/file' ], |
118 | [ "Win32->catpath('','\\../..\\d1/','')", '\\../..\\d1/' ], |
119 | [ "Win32->catpath('','\\./.\\d1/','')", '\\./.\\d1/' ], |
120 | [ "Win32->catpath('\\\\node\\share','\\d1/d2\\d3/','')", '\\\\node\\share\\d1/d2\\d3/' ], |
121 | [ "Win32->catpath('\\\\node\\share','\\d1/d2\\d3/','file')", '\\\\node\\share\\d1/d2\\d3/file' ], |
122 | [ "Win32->catpath('\\\\node\\share','\\d1/d2\\','file')", '\\\\node\\share\\d1/d2\\file' ], |
123 | |
124 | [ "Win32->splitdir('')", '' ], |
125 | [ "Win32->splitdir('\\d1/d2\\d3/')", ',d1,d2,d3,' ], |
126 | [ "Win32->splitdir('d1/d2\\d3/')", 'd1,d2,d3,' ], |
127 | [ "Win32->splitdir('\\d1/d2\\d3')", ',d1,d2,d3' ], |
128 | [ "Win32->splitdir('d1/d2\\d3')", 'd1,d2,d3' ], |
129 | |
130 | [ "Win32->catdir()", '' ], |
131 | [ "Win32->catdir('')", '\\' ], |
132 | [ "Win32->catdir('/')", '\\' ], |
133 | [ "Win32->catdir('//d1','d2')", '\\\\d1\\d2' ], |
134 | [ "Win32->catdir('','/d1','d2')", '\\\\d1\\d2' ], |
135 | [ "Win32->catdir('','','/d1','d2')", '\\\\\\d1\\d2' ], |
136 | [ "Win32->catdir('','//d1','d2')", '\\\\\\d1\\d2' ], |
137 | [ "Win32->catdir('','','//d1','d2')", '\\\\\\\\d1\\d2' ], |
138 | [ "Win32->catdir('','d1','','d2','')", '\\d1\\d2' ], |
139 | [ "Win32->catdir('','d1','d2','d3','')", '\\d1\\d2\\d3' ], |
140 | [ "Win32->catdir('d1','d2','d3','')", 'd1\\d2\\d3' ], |
141 | [ "Win32->catdir('','d1','d2','d3')", '\\d1\\d2\\d3' ], |
142 | [ "Win32->catdir('d1','d2','d3')", 'd1\\d2\\d3' ], |
143 | [ "Win32->catdir('A:/d1','d2','d3')", 'A:\\d1\\d2\\d3' ], |
144 | [ "Win32->catdir('A:/d1','d2','d3','')", 'A:\\d1\\d2\\d3' ], |
145 | #[ "Win32->catdir('A:/d1','B:/d2','d3','')", 'A:\\d1\\d2\\d3' ], |
146 | [ "Win32->catdir('A:/d1','B:/d2','d3','')", 'A:\\d1\\B:\\d2\\d3' ], |
147 | [ "Win32->catdir('A:/')", 'A:\\' ], |
148 | |
149 | [ "Win32->catfile('a','b','c')", 'a\\b\\c' ], |
150 | |
151 | [ "Win32->canonpath('')", '' ], |
152 | [ "Win32->canonpath('a:')", 'A:' ], |
153 | [ "Win32->canonpath('A:f')", 'A:f' ], |
154 | [ "Win32->canonpath('//a\\b//c')", '\\\\a\\b\\c' ], |
155 | [ "Win32->canonpath('/a/..../c')", '\\a\\....\\c' ], |
156 | [ "Win32->canonpath('//a/b\\c')", '\\\\a\\b\\c' ], |
157 | [ "Win32->canonpath('////')", '\\\\\\' ], |
158 | [ "Win32->canonpath('//')", '\\' ], |
159 | [ "Win32->canonpath('/.')", '\\.' ], |
160 | [ "Win32->canonpath('//a/b/../../c')", '\\\\a\\b\\..\\..\\c' ], |
161 | [ "Win32->canonpath('//a/../../c')", '\\\\a\\..\\..\\c' ], |
162 | |
163 | [ "Win32->abs2rel('/t1/t2/t3','/t1/t2/t3')", '' ], |
164 | [ "Win32->abs2rel('/t1/t2/t4','/t1/t2/t3')", '..\\t4' ], |
165 | [ "Win32->abs2rel('/t1/t2','/t1/t2/t3')", '..' ], |
166 | [ "Win32->abs2rel('/t1/t2/t3/t4','/t1/t2/t3')", 't4' ], |
167 | [ "Win32->abs2rel('/t4/t5/t6','/t1/t2/t3')", '..\\..\\..\\t4\\t5\\t6' ], |
168 | #[ "Win32->abs2rel('../t4','/t1/t2/t3')", '\\t1\\t2\\t3\\..\\t4' ], |
169 | [ "Win32->abs2rel('/','/t1/t2/t3')", '..\\..\\..' ], |
170 | [ "Win32->abs2rel('///','/t1/t2/t3')", '..\\..\\..' ], |
171 | [ "Win32->abs2rel('/.','/t1/t2/t3')", '..\\..\\..\\.' ], |
172 | [ "Win32->abs2rel('/./','/t1/t2/t3')", '..\\..\\..' ], |
173 | [ "Win32->abs2rel('\\\\a/t1/t2/t4','/t2/t3')", '..\\t4' ], |
174 | [ "Win32->abs2rel('//a/t1/t2/t4','/t2/t3')", '..\\t4' ], |
175 | |
176 | [ "Win32->rel2abs('temp','C:/')", 'C:\\temp' ], |
177 | [ "Win32->rel2abs('temp','C:/a')", 'C:\\a\\temp' ], |
178 | [ "Win32->rel2abs('temp','C:/a/')", 'C:\\a\\temp' ], |
179 | [ "Win32->rel2abs('../','C:/')", 'C:\\..' ], |
180 | [ "Win32->rel2abs('../','C:/a')", 'C:\\a\\..' ], |
181 | [ "Win32->rel2abs('temp','//prague_main/work/')", '\\\\prague_main\\work\\temp' ], |
182 | [ "Win32->rel2abs('../temp','//prague_main/work/')", '\\\\prague_main\\work\\..\\temp' ], |
183 | [ "Win32->rel2abs('temp','//prague_main/work')", '\\\\prague_main\\work\\temp' ], |
184 | [ "Win32->rel2abs('../','//prague_main/work')", '\\\\prague_main\\work\\..' ], |
185 | |
186 | [ "VMS->splitpath('file')", ',,file' ], |
08c7cbbb |
187 | [ "VMS->splitpath('[d1.d2.d3]')", ',[d1.d2.d3],' ], |
188 | [ "VMS->splitpath('[.d1.d2.d3]')", ',[.d1.d2.d3],' ], |
189 | [ "VMS->splitpath('[d1.d2.d3]file')", ',[d1.d2.d3],file' ], |
190 | [ "VMS->splitpath('d1/d2/d3/file')", ',[.d1.d2.d3],file' ], |
191 | [ "VMS->splitpath('/d1/d2/d3/file')", 'd1:,[d2.d3],file' ], |
192 | [ "VMS->splitpath('[.d1.d2.d3]file')", ',[.d1.d2.d3],file' ], |
193 | [ "VMS->splitpath('node::volume:[d1.d2.d3]')", 'node::volume:,[d1.d2.d3],' ], |
194 | [ "VMS->splitpath('node::volume:[d1.d2.d3]file')", 'node::volume:,[d1.d2.d3],file' ], |
195 | [ "VMS->splitpath('node\"access_spec\"::volume:[d1.d2.d3]')", 'node"access_spec"::volume:,[d1.d2.d3],' ], |
196 | [ "VMS->splitpath('node\"access_spec\"::volume:[d1.d2.d3]file')", 'node"access_spec"::volume:,[d1.d2.d3],file' ], |
0994714a |
197 | |
198 | [ "VMS->catpath('','','file')", 'file' ], |
199 | [ "VMS->catpath('','[d1.d2.d3]','')", '[d1.d2.d3]' ], |
200 | [ "VMS->catpath('','[.d1.d2.d3]','')", '[.d1.d2.d3]' ], |
201 | [ "VMS->catpath('','[d1.d2.d3]','file')", '[d1.d2.d3]file' ], |
202 | [ "VMS->catpath('','[.d1.d2.d3]','file')", '[.d1.d2.d3]file' ], |
08c7cbbb |
203 | [ "VMS->catpath('','d1/d2/d3','file')", '[.d1.d2.d3]file' ], |
204 | [ "VMS->catpath('v','d1/d2/d3','file')", 'v:[.d1.d2.d3]file' ], |
0994714a |
205 | [ "VMS->catpath('node::volume:','[d1.d2.d3]','')", 'node::volume:[d1.d2.d3]' ], |
206 | [ "VMS->catpath('node::volume:','[d1.d2.d3]','file')", 'node::volume:[d1.d2.d3]file' ], |
207 | [ "VMS->catpath('node\"access_spec\"::volume:','[d1.d2.d3]','')", 'node"access_spec"::volume:[d1.d2.d3]' ], |
208 | [ "VMS->catpath('node\"access_spec\"::volume:','[d1.d2.d3]','file')", 'node"access_spec"::volume:[d1.d2.d3]file' ], |
209 | |
210 | [ "VMS->canonpath('')", '' ], |
178326fd |
211 | [ "VMS->canonpath('volume:[d1]file')", 'volume:[d1]file' ], |
08c7cbbb |
212 | [ "VMS->canonpath('volume:[d1.-.d2.][d3.d4.-]')", 'volume:[d2.d3]' ], |
178326fd |
213 | [ "VMS->canonpath('volume:[000000.d1]d2.dir;1')", 'volume:[d1]d2.dir;1' ], |
0994714a |
214 | |
215 | [ "VMS->splitdir('')", '' ], |
216 | [ "VMS->splitdir('[]')", '' ], |
217 | [ "VMS->splitdir('d1.d2.d3')", 'd1,d2,d3' ], |
218 | [ "VMS->splitdir('[d1.d2.d3]')", 'd1,d2,d3' ], |
219 | [ "VMS->splitdir('.d1.d2.d3')", ',d1,d2,d3' ], |
220 | [ "VMS->splitdir('[.d1.d2.d3]')", ',d1,d2,d3' ], |
221 | [ "VMS->splitdir('.-.d2.d3')", ',-,d2,d3' ], |
222 | [ "VMS->splitdir('[.-.d2.d3]')", ',-,d2,d3' ], |
223 | |
08c7cbbb |
224 | [ "VMS->catdir('')", '' ], |
225 | [ "VMS->catdir('d1','d2','d3')", '[.d1.d2.d3]' ], |
226 | [ "VMS->catdir('d1','d2/','d3')", '[.d1.d2.d3]' ], |
227 | [ "VMS->catdir('','d1','d2','d3')", '[.d1.d2.d3]' ], |
228 | [ "VMS->catdir('','-','d2','d3')", '[-.d2.d3]' ], |
229 | [ "VMS->catdir('','-','','d3')", '[-.d3]' ], |
230 | [ "VMS->catdir('dir.dir','d2.dir','d3.dir')", '[.dir.d2.d3]' ], |
231 | [ "VMS->catdir('[.name]')", '[.name]' ], |
232 | [ "VMS->catdir('[.name]','[.name]')", '[.name.name]'], |
0994714a |
233 | |
234 | [ "VMS->abs2rel('node::volume:[t1.t2.t3]','[t1.t2.t3]')", '' ], |
235 | [ "VMS->abs2rel('node::volume:[t1.t2.t4]','[t1.t2.t3]')", '[-.t4]' ], |
236 | [ "VMS->abs2rel('[t1.t2.t3]','[t1.t2.t3]')", '' ], |
237 | [ "VMS->abs2rel('[t1.t2.t3]file','[t1.t2.t3]')", 'file' ], |
238 | [ "VMS->abs2rel('[t1.t2.t4]','[t1.t2.t3]')", '[-.t4]' ], |
239 | [ "VMS->abs2rel('[t1.t2]file','[t1.t2.t3]')", '[-]file' ], |
240 | [ "VMS->abs2rel('[t1.t2.t3.t4]','[t1.t2.t3]')", '[t4]' ], |
08c7cbbb |
241 | [ "VMS->abs2rel('[t4.t5.t6]','[t1.t2.t3]')", '[---.t4.t5.t6]' ], |
242 | [ "VMS->abs2rel('[000000]','[t1.t2.t3]')", '[---.000000]' ], |
243 | [ "VMS->abs2rel('a:[t1.t2.t4]','[t1.t2.t3]')", '[-.t4]' ], |
244 | [ "VMS->abs2rel('[a.-.b.c.-]','[t1.t2.t3]')", '[---.b]' ], |
270d1e39 |
245 | |
0994714a |
246 | [ "VMS->rel2abs('[.t4]','[t1.t2.t3]')", '[t1.t2.t3.t4]' ], |
247 | [ "VMS->rel2abs('[.t4.t5]','[t1.t2.t3]')", '[t1.t2.t3.t4.t5]' ], |
248 | [ "VMS->rel2abs('[]','[t1.t2.t3]')", '[t1.t2.t3]' ], |
08c7cbbb |
249 | [ "VMS->rel2abs('[-]','[t1.t2.t3]')", '[t1.t2]' ], |
250 | [ "VMS->rel2abs('[-.t4]','[t1.t2.t3]')", '[t1.t2.t4]' ], |
0994714a |
251 | [ "VMS->rel2abs('[t1]','[t1.t2.t3]')", '[t1]' ], |
270d1e39 |
252 | |
0994714a |
253 | [ "OS2->catdir('A:/d1','B:/d2','d3','')", 'A:/d1/B:/d2/d3' ], |
254 | [ "OS2->catfile('a','b','c')", 'a/b/c' ], |
255 | |
be708cc0 |
256 | |
257 | [ "Mac->catpath('','','')", '' ], |
258 | [ "Mac->catpath('',':','')", ':' ], |
259 | [ "Mac->catpath('','::','')", '::' ], |
260 | |
261 | [ "Mac->catpath('hd','','')", 'hd:' ], |
262 | [ "Mac->catpath('hd:','','')", 'hd:' ], |
263 | [ "Mac->catpath('hd:',':','')", 'hd:' ], |
264 | [ "Mac->catpath('hd:','::','')", 'hd::' ], |
265 | |
266 | [ "Mac->catpath('hd','','file')", 'hd:file' ], |
267 | [ "Mac->catpath('hd',':','file')", 'hd:file' ], |
268 | [ "Mac->catpath('hd','::','file')", 'hd::file' ], |
269 | [ "Mac->catpath('hd',':::','file')", 'hd:::file' ], |
270 | |
271 | [ "Mac->catpath('hd:','',':file')", 'hd:file' ], |
272 | [ "Mac->catpath('hd:',':',':file')", 'hd:file' ], |
273 | [ "Mac->catpath('hd:','::',':file')", 'hd::file' ], |
274 | [ "Mac->catpath('hd:',':::',':file')", 'hd:::file' ], |
275 | |
276 | [ "Mac->catpath('hd:','d1','file')", 'hd:d1:file' ], |
277 | [ "Mac->catpath('hd:',':d1:',':file')", 'hd:d1:file' ], |
278 | |
279 | [ "Mac->catpath('','d1','')", ':d1:' ], |
280 | [ "Mac->catpath('',':d1','')", ':d1:' ], |
281 | [ "Mac->catpath('',':d1:','')", ':d1:' ], |
282 | |
283 | [ "Mac->catpath('','d1','file')", ':d1:file' ], |
284 | [ "Mac->catpath('',':d1:',':file')", ':d1:file' ], |
285 | |
286 | [ "Mac->catpath('','','file')", 'file' ], |
287 | [ "Mac->catpath('','',':file')", 'file' ], # ! |
288 | [ "Mac->catpath('',':',':file')", ':file' ], # ! |
289 | |
290 | |
291 | [ "Mac->splitpath(':')", ',:,' ], |
292 | [ "Mac->splitpath('::')", ',::,' ], |
293 | [ "Mac->splitpath(':::')", ',:::,' ], |
294 | |
295 | [ "Mac->splitpath('file')", ',,file' ], |
296 | [ "Mac->splitpath(':file')", ',:,file' ], |
297 | |
298 | [ "Mac->splitpath('d1',1)", ',:d1:,' ], # dir, not volume |
299 | [ "Mac->splitpath(':d1',1)", ',:d1:,' ], |
300 | [ "Mac->splitpath(':d1:',1)", ',:d1:,' ], |
301 | [ "Mac->splitpath(':d1:')", ',:d1:,' ], |
302 | [ "Mac->splitpath(':d1:d2:d3:')", ',:d1:d2:d3:,' ], |
303 | [ "Mac->splitpath(':d1:d2:d3:',1)", ',:d1:d2:d3:,' ], |
304 | [ "Mac->splitpath(':d1:file')", ',:d1:,file' ], |
305 | [ "Mac->splitpath('::d1:file')", ',::d1:,file' ], |
306 | |
307 | [ "Mac->splitpath('hd:', 1)", 'hd:,,' ], |
308 | [ "Mac->splitpath('hd:')", 'hd:,,' ], |
309 | [ "Mac->splitpath('hd:d1:d2:')", 'hd:,:d1:d2:,' ], |
310 | [ "Mac->splitpath('hd:d1:d2',1)", 'hd:,:d1:d2:,' ], |
311 | [ "Mac->splitpath('hd:d1:d2:file')", 'hd:,:d1:d2:,file' ], |
312 | [ "Mac->splitpath('hd:d1:d2::file')", 'hd:,:d1:d2::,file' ], |
313 | [ "Mac->splitpath('hd::d1:d2:file')", 'hd:,::d1:d2:,file' ], # invalid path |
314 | [ "Mac->splitpath('hd:file')", 'hd:,,file' ], |
315 | |
316 | [ "Mac->splitdir('')", '' ], |
317 | [ "Mac->splitdir(':')", ':' ], |
318 | [ "Mac->splitdir('::')", '::' ], |
319 | [ "Mac->splitdir(':::')", ':::' ], |
320 | [ "Mac->splitdir(':::d1:d2')", ',,,d1,d2' ], |
321 | |
322 | [ "Mac->splitdir(':d1:d2:d3::')", ',d1,d2,d3,' ], |
323 | [ "Mac->splitdir(':d1:d2:d3:')", ',d1,d2,d3' ], |
324 | [ "Mac->splitdir(':d1:d2:d3')", ',d1,d2,d3' ], |
325 | |
326 | [ "Mac->splitdir('hd:d1:d2:::')", 'hd,d1,d2,,' ], |
327 | [ "Mac->splitdir('hd:d1:d2::')", 'hd,d1,d2,' ], |
328 | [ "Mac->splitdir('hd:d1:d2:')", 'hd,d1,d2' ], |
329 | [ "Mac->splitdir('hd:d1:d2')", 'hd,d1,d2' ], |
330 | [ "Mac->splitdir('hd:d1::d2::')", 'hd,d1,,d2,' ], |
331 | |
332 | [ "Mac->catdir()", '' ], |
333 | [ "Mac->catdir('')", ':' ], |
334 | [ "Mac->catdir(':')", ':' ], |
335 | |
336 | [ "Mac->catdir('', '')", '::' ], # Hmm... ":" ? |
337 | [ "Mac->catdir('', ':')", '::' ], # Hmm... ":" ? |
338 | [ "Mac->catdir(':', ':')", '::' ], # Hmm... ":" ? |
339 | [ "Mac->catdir(':', '')", '::' ], # Hmm... ":" ? |
340 | |
341 | [ "Mac->catdir('', '::')", '::' ], |
342 | [ "Mac->catdir(':', '::')", '::' ], # but catdir('::', ':') is ':::' |
343 | |
344 | [ "Mac->catdir('::', '')", ':::' ], # Hmm... "::" ? |
345 | [ "Mac->catdir('::', ':')", ':::' ], # Hmm... "::" ? |
346 | |
347 | [ "Mac->catdir('::', '::')", ':::' ], # ok |
348 | |
349 | # |
350 | # Unix counterparts: |
351 | # |
352 | |
353 | # Unix catdir('.') = "." |
354 | |
355 | # Unix catdir('','') = "/" |
356 | # Unix catdir('','.') = "/" |
357 | # Unix catdir('.','.') = "." |
358 | # Unix catdir('.','') = "." |
359 | |
360 | # Unix catdir('','..') = "/" |
361 | # Unix catdir('.','..') = ".." |
362 | |
363 | # Unix catdir('..','') = ".." |
364 | # Unix catdir('..','.') = ".." |
365 | # Unix catdir('..','..') = "../.." |
366 | |
367 | [ "Mac->catdir(':d1','d2')", ':d1:d2:' ], |
0994714a |
368 | [ "Mac->catdir('','d1','d2','d3')", ':d1:d2:d3:' ], |
369 | [ "Mac->catdir('','','d2','d3')", '::d2:d3:' ], |
370 | [ "Mac->catdir('','','','d3')", ':::d3:' ], |
be708cc0 |
371 | [ "Mac->catdir(':d1')", ':d1:' ], |
372 | [ "Mac->catdir(':d1',':d2')", ':d1:d2:' ], |
373 | [ "Mac->catdir('', ':d1',':d2')", ':d1:d2:' ], |
374 | [ "Mac->catdir('','',':d1',':d2')", '::d1:d2:' ], |
375 | |
376 | [ "Mac->catdir('hd')", 'hd:' ], |
377 | [ "Mac->catdir('hd','d1','d2')", 'hd:d1:d2:' ], |
378 | [ "Mac->catdir('hd','d1/','d2')", 'hd:d1/:d2:' ], |
379 | [ "Mac->catdir('hd','',':d1')", 'hd::d1:' ], |
380 | [ "Mac->catdir('hd','d1')", 'hd:d1:' ], |
381 | [ "Mac->catdir('hd','d1', '')", 'hd:d1::' ], |
382 | [ "Mac->catdir('hd','d1','','')", 'hd:d1:::' ], |
383 | [ "Mac->catdir('hd:',':d1')", 'hd:d1:' ], |
384 | [ "Mac->catdir('hd:d1:',':d2')", 'hd:d1:d2:' ], |
385 | [ "Mac->catdir('hd:','d1')", 'hd:d1:' ], |
386 | [ "Mac->catdir('hd',':d1')", 'hd:d1:' ], |
387 | [ "Mac->catdir('hd:d1:',':d2')", 'hd:d1:d2:' ], |
388 | [ "Mac->catdir('hd:d1:',':d2:')", 'hd:d1:d2:' ], |
389 | |
390 | |
391 | [ "Mac->catfile()", '' ], |
392 | [ "Mac->catfile('')", '' ], |
393 | [ "Mac->catfile(':')", ':' ], |
394 | [ "Mac->catfile(':', '')", ':' ], |
395 | |
396 | [ "Mac->catfile('hd','d1','file')", 'hd:d1:file' ], |
397 | [ "Mac->catfile('hd','d1',':file')", 'hd:d1:file' ], |
398 | [ "Mac->catfile('file')", 'file' ], |
399 | [ "Mac->catfile(':', 'file')", ':file' ], |
400 | [ "Mac->catfile('', 'file')", ':file' ], |
0994714a |
401 | |
0994714a |
402 | |
403 | [ "Mac->canonpath('')", '' ], |
404 | [ "Mac->canonpath(':')", ':' ], |
405 | [ "Mac->canonpath('::')", '::' ], |
406 | [ "Mac->canonpath('a::')", 'a::' ], |
407 | [ "Mac->canonpath(':a::')", ':a::' ], |
408 | |
be708cc0 |
409 | [ "Mac->abs2rel('hd:d1:d2:','hd:d1:d2:')", ':' ], |
410 | [ "Mac->abs2rel('hd:d1:d2:','hd:d1:d2:file')", ':' ], # ignore base's file portion |
411 | [ "Mac->abs2rel('hd:d1:d2:file','hd:d1:d2:')", ':file' ], |
412 | [ "Mac->abs2rel('hd:d1:','hd:d1:d2:')", '::' ], |
413 | [ "Mac->abs2rel('hd:d3:','hd:d1:d2:')", ':::d3:' ], |
414 | [ "Mac->abs2rel('hd:d3:','hd:d1:d2::')", '::d3:' ], |
415 | [ "Mac->abs2rel('hd:d1:d4:d5:','hd:d1::d2:d3::')", '::d1:d4:d5:' ], |
416 | [ "Mac->abs2rel('hd:d1:d4:d5:','hd:d1::d2:d3:')", ':::d1:d4:d5:' ], # first, resolve updirs in base |
417 | [ "Mac->abs2rel('hd:d1:d3:','hd:d1:d2:')", '::d3:' ], |
418 | [ "Mac->abs2rel('hd:d1::d3:','hd:d1:d2:')", ':::d3:' ], |
419 | [ "Mac->abs2rel('hd:d3:','hd:d1:d2:')", ':::d3:' ], # same as above |
420 | [ "Mac->abs2rel('hd:d1:d2:d3:','hd:d1:d2:')", ':d3:' ], |
421 | [ "Mac->abs2rel('hd:d1:d2:d3::','hd:d1:d2:')", ':d3::' ], |
422 | [ "Mac->abs2rel('v1:d3:d4:d5:','v2:d1:d2:')", ':::d3:d4:d5:' ], # ignore base's volume |
423 | [ "Mac->abs2rel('hd:','hd:d1:d2:')", ':::' ], |
424 | |
425 | [ "Mac->rel2abs(':d3:','hd:d1:d2:')", 'hd:d1:d2:d3:' ], |
426 | [ "Mac->rel2abs(':d3:d4:','hd:d1:d2:')", 'hd:d1:d2:d3:d4:' ], |
427 | [ "Mac->rel2abs('','hd:d1:d2:')", '' ], |
428 | [ "Mac->rel2abs('::','hd:d1:d2:')", 'hd:d1:d2::' ], |
429 | [ "Mac->rel2abs('::','hd:d1:d2:file')", 'hd:d1:d2::' ],# ignore base's file portion |
430 | [ "Mac->rel2abs(':file','hd:d1:d2:')", 'hd:d1:d2:file' ], |
431 | [ "Mac->rel2abs('::file','hd:d1:d2:')", 'hd:d1:d2::file' ], |
432 | [ "Mac->rel2abs('::d3:','hd:d1:d2:')", 'hd:d1:d2::d3:' ], |
433 | [ "Mac->rel2abs('hd:','hd:d1:d2:')", 'hd:' ], # path already absolute |
434 | [ "Mac->rel2abs('hd:d3:file','hd:d1:d2:')", 'hd:d3:file' ], |
435 | [ "Mac->rel2abs('hd:d3:','hd:d1:file')", 'hd:d3:' ], |
0994714a |
436 | ) ; |
437 | |
438 | # Grab all of the plain routines from File::Spec |
439 | use File::Spec @File::Spec::EXPORT_OK ; |
440 | |
441 | require File::Spec::Unix ; |
442 | require File::Spec::Win32 ; |
443 | |
444 | eval { |
445 | require VMS::Filespec ; |
446 | } ; |
447 | |
d7bc03f0 |
448 | my $skip_exception = "Install VMS::Filespec (from vms/ext)" ; |
449 | |
0994714a |
450 | if ( $@ ) { |
451 | # Not pretty, but it allows testing of things not implemented soley |
452 | # on VMS. It might be better to change File::Spec::VMS to do this, |
453 | # making it more usable when running on (say) Unix but working with |
454 | # VMS paths. |
178326fd |
455 | eval qq- |
d7bc03f0 |
456 | sub File::Spec::VMS::vmsify { die "$skip_exception" } |
457 | sub File::Spec::VMS::unixify { die "$skip_exception" } |
458 | sub File::Spec::VMS::vmspath { die "$skip_exception" } |
178326fd |
459 | - ; |
0994714a |
460 | $INC{"VMS/Filespec.pm"} = 1 ; |
270d1e39 |
461 | } |
0994714a |
462 | require File::Spec::VMS ; |
270d1e39 |
463 | |
0994714a |
464 | require File::Spec::OS2 ; |
465 | require File::Spec::Mac ; |
270d1e39 |
466 | |
0994714a |
467 | print "1..", scalar( @tests ), "\n" ; |
468 | |
469 | my $current_test= 1 ; |
470 | |
0994714a |
471 | # Test out the class methods |
472 | for ( @tests ) { |
473 | tryfunc( @$_ ) ; |
270d1e39 |
474 | } |
475 | |
0994714a |
476 | |
477 | |
478 | # |
479 | # Tries a named function with the given args and compares the result against |
480 | # an expected result. Works with functions that return scalars or arrays. |
481 | # |
482 | sub tryfunc { |
483 | my $function = shift ; |
484 | my $expected = shift ; |
f6a53ef2 |
485 | my $platform = shift ; |
486 | |
487 | if ($platform && $^O ne $platform) { |
488 | print "ok $current_test # skipped: $function\n" ; |
489 | ++$current_test ; |
490 | return; |
491 | } |
0994714a |
492 | |
493 | $function =~ s#\\#\\\\#g ; |
494 | |
495 | my $got ; |
496 | if ( $function =~ /^[^\$].*->/ ) { |
497 | $got = eval( "join( ',', File::Spec::$function )" ) ; |
498 | } |
499 | else { |
500 | $got = eval( "join( ',', $function )" ) ; |
501 | } |
502 | |
503 | if ( $@ ) { |
d7bc03f0 |
504 | if ( substr( $@, 0, length $skip_exception ) eq $skip_exception ) { |
505 | chomp $@ ; |
506 | print "ok $current_test # skip $function: $@\n" ; |
0994714a |
507 | } |
508 | else { |
509 | chomp $@ ; |
510 | print "not ok $current_test # $function: $@\n" ; |
511 | } |
512 | } |
513 | elsif ( !defined( $got ) || $got ne $expected ) { |
514 | print "not ok $current_test # $function: got '$got', expected '$expected'\n" ; |
515 | } |
516 | else { |
517 | print "ok $current_test # $function\n" ; |
518 | } |
519 | ++$current_test ; |
520 | } |