6 require_ok('File::Spec');
13 if (eval 'require VMS::Feature') {
14 $vms_unix_rpt = VMS::Feature::current("filename_unix_report");
16 my $unix_rpt = $ENV{'DECC$FILENAME_UNIX_REPORT'} || '';
17 $vms_unix_rpt = $unix_rpt =~ /^[ET1]/i;
22 my $skip_exception = "Needs VMS::Filespec (and thus VMS)" ;
25 require VMS::Filespec ;
29 # Not pretty, but it allows testing of things not implemented solely
30 # on VMS. It might be better to change File::Spec::VMS to do this,
31 # making it more usable when running on (say) Unix but working with
34 sub File::Spec::VMS::vmsify { die "$skip_exception" }
35 sub File::Spec::VMS::unixify { die "$skip_exception" }
36 sub File::Spec::VMS::vmspath { die "$skip_exception" }
38 $INC{"VMS/Filespec.pm"} = 1 ;
41 foreach (qw(Unix Win32 VMS OS2 Mac Epoc Cygwin)) {
42 require_ok("File::Spec::$_");
45 # Each element in this array is a single test. Storing them this way makes
46 # maintenance easy, and should be OK since perl should be pretty functional
47 # before these tests are run.
50 # [ Function , Expected , Platform ]
52 [ "Unix->case_tolerant()", '0' ],
54 [ "Unix->catfile('a','b','c')", 'a/b/c' ],
55 [ "Unix->catfile('a','b','./c')", 'a/b/c' ],
56 [ "Unix->catfile('./a','b','c')", 'a/b/c' ],
57 [ "Unix->catfile('c')", 'c' ],
58 [ "Unix->catfile('./c')", 'c' ],
59 [ "Unix->catfile('a', 'b'.chr(0xaf))", 'a/b'.chr(0xaf) ],
61 [ "Unix->catfile('a', do { my \$x = 'b'.chr(0xaf); use utf8 (); utf8::upgrade(\$x); \$x })", 'a/b'.chr(0xaf) ],
63 [ "Unix->catfile(substr('foo', 2))", 'o' ],
65 [ "Unix->splitpath('file')", ',,file' ],
66 [ "Unix->splitpath('/d1/d2/d3/')", ',/d1/d2/d3/,' ],
67 [ "Unix->splitpath('d1/d2/d3/')", ',d1/d2/d3/,' ],
68 [ "Unix->splitpath('/d1/d2/d3/.')", ',/d1/d2/d3/.,' ],
69 [ "Unix->splitpath('/d1/d2/d3/..')", ',/d1/d2/d3/..,' ],
70 [ "Unix->splitpath('/d1/d2/d3/.file')", ',/d1/d2/d3/,.file' ],
71 [ "Unix->splitpath('d1/d2/d3/file')", ',d1/d2/d3/,file' ],
72 [ "Unix->splitpath('/../../d1/')", ',/../../d1/,' ],
73 [ "Unix->splitpath('/././d1/')", ',/././d1/,' ],
75 [ "Unix->catpath('','','file')", 'file' ],
76 [ "Unix->catpath('','/d1/d2/d3/','')", '/d1/d2/d3/' ],
77 [ "Unix->catpath('','d1/d2/d3/','')", 'd1/d2/d3/' ],
78 [ "Unix->catpath('','/d1/d2/d3/.','')", '/d1/d2/d3/.' ],
79 [ "Unix->catpath('','/d1/d2/d3/..','')", '/d1/d2/d3/..' ],
80 [ "Unix->catpath('','/d1/d2/d3/','.file')", '/d1/d2/d3/.file' ],
81 [ "Unix->catpath('','d1/d2/d3/','file')", 'd1/d2/d3/file' ],
82 [ "Unix->catpath('','/../../d1/','')", '/../../d1/' ],
83 [ "Unix->catpath('','/././d1/','')", '/././d1/' ],
84 [ "Unix->catpath('d1','d2/d3/','')", 'd2/d3/' ],
85 [ "Unix->catpath('d1','d2','d3/')", 'd2/d3/' ],
87 [ "Unix->splitdir('')", '' ],
88 [ "Unix->splitdir('/d1/d2/d3/')", ',d1,d2,d3,' ],
89 [ "Unix->splitdir('d1/d2/d3/')", 'd1,d2,d3,' ],
90 [ "Unix->splitdir('/d1/d2/d3')", ',d1,d2,d3' ],
91 [ "Unix->splitdir('d1/d2/d3')", 'd1,d2,d3' ],
93 [ "Unix->catdir()", '' ],
94 [ "Unix->catdir('')", '/' ],
95 [ "Unix->catdir('/')", '/' ],
96 [ "Unix->catdir('','d1','d2','d3','')", '/d1/d2/d3' ],
97 [ "Unix->catdir('d1','d2','d3','')", 'd1/d2/d3' ],
98 [ "Unix->catdir('','d1','d2','d3')", '/d1/d2/d3' ],
99 [ "Unix->catdir('d1','d2','d3')", 'd1/d2/d3' ],
100 # QNX is POSIXly special
101 [ "Unix->catdir('/','d2/d3')", ( $^O =~ m!^(nto|qnx)! ? '//d2/d3' : '/d2/d3' ) ],
102 [ "Unix->catdir('a', 'b'.chr(0xaf))", 'a/b'.chr(0xaf) ],
104 [ "Unix->catdir('a', do { my \$x = 'b'.chr(0xaf); use utf8 (); utf8::upgrade(\$x); \$x })", 'a/b'.chr(0xaf) ],
107 [ "Unix->canonpath('///../../..//./././a//b/.././c/././')", '/a/b/../c' ],
108 [ "Unix->canonpath('')", '' ],
110 [ "Unix->canonpath('a/../../b/c')", 'a/../../b/c' ],
111 [ "Unix->canonpath('/')", '/' ],
112 [ "Unix->canonpath('///')", '/' ],
113 [ "Unix->canonpath('/.')", '/' ],
114 [ "Unix->canonpath('/./')", '/' ],
115 [ "Unix->canonpath('///.')", '/' ],
116 [ "Unix->canonpath('///.///')", '/' ],
117 [ "Unix->canonpath('///..')", '/' ],
118 [ "Unix->canonpath('///..///')", '/' ],
119 [ "Unix->canonpath('///..///.///..///')", '/' ],
120 [ "Unix->canonpath('.')", '.' ],
121 [ "Unix->canonpath('.///')", '.' ],
122 [ "Unix->canonpath('.///.')", '.' ],
123 [ "Unix->canonpath('.///.///')", '.' ],
124 [ "Unix->canonpath('..')", '..' ],
125 [ "Unix->canonpath('..///')", '..' ],
126 [ "Unix->canonpath('../..')", '../..' ],
127 [ "Unix->canonpath('../../')", '../..' ],
128 [ "Unix->canonpath('..///.///..///')", '../..' ],
129 [ "Unix->canonpath('///../../..//./././a//b/.././c/././')", '/a/b/../c' ],
130 [ "Unix->canonpath('a/../../b/c')", 'a/../../b/c' ],
131 [ "Unix->canonpath('a///..///..///b////c')", 'a/../../b/c' ],
132 [ "Unix->canonpath('.///a///.///..///.///..///.///b///.////c///.')", 'a/../../b/c' ],
133 [ "Unix->canonpath('/a/./')", '/a' ],
134 [ "Unix->canonpath('/a/.')", '/a' ],
135 [ "Unix->canonpath('/../../')", '/' ],
136 [ "Unix->canonpath('/../..')", '/' ],
137 [ "Unix->canonpath('/foo', '/bar')", '/foo' ],
138 [ "Unix->canonpath('///a'.chr(0xaf))", '/a'.chr(0xaf) ],
140 [ "Unix->canonpath(do { my \$x = '///a'.chr(0xaf); use utf8 (); utf8::upgrade(\$x); \$x })", '/a'.chr(0xaf) ],
142 [ "Unix->canonpath(1)", '1' ],
144 [ "Unix->abs2rel('/t1/t2/t3','/t1/t2/t3')", '.' ],
145 [ "Unix->abs2rel('/t1/t2/t4','/t1/t2/t3')", '../t4' ],
146 [ "Unix->abs2rel('/t1/t2','/t1/t2/t3')", '..' ],
147 [ "Unix->abs2rel('/t1/t2/t3/t4','/t1/t2/t3')", 't4' ],
148 [ "Unix->abs2rel('/t4/t5/t6','/t1/t2/t3')", '../../../t4/t5/t6' ],
149 #[ "Unix->abs2rel('../t4','/t1/t2/t3')", '../t4' ],
150 [ "Unix->abs2rel('/','/t1/t2/t3')", '../../..' ],
151 [ "Unix->abs2rel('///','/t1/t2/t3')", '../../..' ],
152 [ "Unix->abs2rel('/.','/t1/t2/t3')", '../../..' ],
153 [ "Unix->abs2rel('/./','/t1/t2/t3')", '../../..' ],
154 #[ "Unix->abs2rel('../t4','/t1/t2/t3')", '../t4' ],
155 [ "Unix->abs2rel('/t1/t2/t3', '/')", 't1/t2/t3' ],
156 [ "Unix->abs2rel('/t1/t2/t3', '/t1')", 't2/t3' ],
157 [ "Unix->abs2rel('t1/t2/t3', 't1')", 't2/t3' ],
158 [ "Unix->abs2rel('t1/t2/t3', 't4')", '../t1/t2/t3' ],
159 [ "Unix->abs2rel('.', '.')", '.' ],
160 [ "Unix->abs2rel('/', '/')", '.' ],
161 [ "Unix->abs2rel('../t1', 't2/t3')", '../../../t1' ],
162 [ "Unix->abs2rel('t1', 't2/../t3')", '../t1' ],
164 [ "Unix->rel2abs('t4','/t1/t2/t3')", '/t1/t2/t3/t4' ],
165 [ "Unix->rel2abs('t4/t5','/t1/t2/t3')", '/t1/t2/t3/t4/t5' ],
166 [ "Unix->rel2abs('.','/t1/t2/t3')", '/t1/t2/t3' ],
167 [ "Unix->rel2abs('..','/t1/t2/t3')", '/t1/t2/t3/..' ],
168 [ "Unix->rel2abs('../t4','/t1/t2/t3')", '/t1/t2/t3/../t4' ],
169 [ "Unix->rel2abs('/t1','/t1/t2/t3')", '/t1' ],
171 [ "Win32->case_tolerant()", '1' ],
172 [ "Win32->rootdir()", '\\' ],
174 [ "Win32->splitpath('file')", ',,file' ],
175 [ "Win32->splitpath('\\d1/d2\\d3/')", ',\\d1/d2\\d3/,' ],
176 [ "Win32->splitpath('d1/d2\\d3/')", ',d1/d2\\d3/,' ],
177 [ "Win32->splitpath('\\d1/d2\\d3/.')", ',\\d1/d2\\d3/.,' ],
178 [ "Win32->splitpath('\\d1/d2\\d3/..')", ',\\d1/d2\\d3/..,' ],
179 [ "Win32->splitpath('\\d1/d2\\d3/.file')", ',\\d1/d2\\d3/,.file' ],
180 [ "Win32->splitpath('\\d1/d2\\d3/file')", ',\\d1/d2\\d3/,file' ],
181 [ "Win32->splitpath('d1/d2\\d3/file')", ',d1/d2\\d3/,file' ],
182 [ "Win32->splitpath('C:\\d1/d2\\d3/')", 'C:,\\d1/d2\\d3/,' ],
183 [ "Win32->splitpath('C:d1/d2\\d3/')", 'C:,d1/d2\\d3/,' ],
184 [ "Win32->splitpath('C:\\d1/d2\\d3/file')", 'C:,\\d1/d2\\d3/,file' ],
185 [ "Win32->splitpath('C:d1/d2\\d3/file')", 'C:,d1/d2\\d3/,file' ],
186 [ "Win32->splitpath('C:\\../d2\\d3/file')", 'C:,\\../d2\\d3/,file' ],
187 [ "Win32->splitpath('C:../d2\\d3/file')", 'C:,../d2\\d3/,file' ],
188 [ "Win32->splitpath('\\../..\\d1/')", ',\\../..\\d1/,' ],
189 [ "Win32->splitpath('\\./.\\d1/')", ',\\./.\\d1/,' ],
190 [ "Win32->splitpath('\\\\node\\share\\d1/d2\\d3/')", '\\\\node\\share,\\d1/d2\\d3/,' ],
191 [ "Win32->splitpath('\\\\node\\share\\d1/d2\\d3/file')", '\\\\node\\share,\\d1/d2\\d3/,file' ],
192 [ "Win32->splitpath('\\\\node\\share\\d1/d2\\file')", '\\\\node\\share,\\d1/d2\\,file' ],
193 [ "Win32->splitpath('file',1)", ',file,' ],
194 [ "Win32->splitpath('\\d1/d2\\d3/',1)", ',\\d1/d2\\d3/,' ],
195 [ "Win32->splitpath('d1/d2\\d3/',1)", ',d1/d2\\d3/,' ],
196 [ "Win32->splitpath('\\\\node\\share\\d1/d2\\d3/',1)", '\\\\node\\share,\\d1/d2\\d3/,' ],
198 [ "Win32->catpath('','','file')", 'file' ],
199 [ "Win32->catpath('','\\d1/d2\\d3/','')", '\\d1/d2\\d3/' ],
200 [ "Win32->catpath('','d1/d2\\d3/','')", 'd1/d2\\d3/' ],
201 [ "Win32->catpath('','\\d1/d2\\d3/.','')", '\\d1/d2\\d3/.' ],
202 [ "Win32->catpath('','\\d1/d2\\d3/..','')", '\\d1/d2\\d3/..' ],
203 [ "Win32->catpath('','\\d1/d2\\d3/','.file')", '\\d1/d2\\d3/.file' ],
204 [ "Win32->catpath('','\\d1/d2\\d3/','file')", '\\d1/d2\\d3/file' ],
205 [ "Win32->catpath('','d1/d2\\d3/','file')", 'd1/d2\\d3/file' ],
206 [ "Win32->catpath('C:','\\d1/d2\\d3/','')", 'C:\\d1/d2\\d3/' ],
207 [ "Win32->catpath('C:','d1/d2\\d3/','')", 'C:d1/d2\\d3/' ],
208 [ "Win32->catpath('C:','\\d1/d2\\d3/','file')", 'C:\\d1/d2\\d3/file' ],
209 [ "Win32->catpath('C:','d1/d2\\d3/','file')", 'C:d1/d2\\d3/file' ],
210 [ "Win32->catpath('C:','\\../d2\\d3/','file')", 'C:\\../d2\\d3/file' ],
211 [ "Win32->catpath('C:','../d2\\d3/','file')", 'C:../d2\\d3/file' ],
212 [ "Win32->catpath('','\\../..\\d1/','')", '\\../..\\d1/' ],
213 [ "Win32->catpath('','\\./.\\d1/','')", '\\./.\\d1/' ],
214 [ "Win32->catpath('\\\\node\\share','\\d1/d2\\d3/','')", '\\\\node\\share\\d1/d2\\d3/' ],
215 [ "Win32->catpath('\\\\node\\share','\\d1/d2\\d3/','file')", '\\\\node\\share\\d1/d2\\d3/file' ],
216 [ "Win32->catpath('\\\\node\\share','\\d1/d2\\','file')", '\\\\node\\share\\d1/d2\\file' ],
218 [ "Win32->splitdir('')", '' ],
219 [ "Win32->splitdir('\\d1/d2\\d3/')", ',d1,d2,d3,' ],
220 [ "Win32->splitdir('d1/d2\\d3/')", 'd1,d2,d3,' ],
221 [ "Win32->splitdir('\\d1/d2\\d3')", ',d1,d2,d3' ],
222 [ "Win32->splitdir('d1/d2\\d3')", 'd1,d2,d3' ],
224 [ "Win32->catdir()", '' ],
225 [ "Win32->catdir('')", '\\' ],
226 [ "Win32->catdir('/')", '\\' ],
227 [ "Win32->catdir('/', '../')", '\\' ],
228 [ "Win32->catdir('/', '..\\')", '\\' ],
229 [ "Win32->catdir('\\', '../')", '\\' ],
230 [ "Win32->catdir('\\', '..\\')", '\\' ],
231 [ "Win32->catdir('//d1','d2')", '\\\\d1\\d2' ],
232 [ "Win32->catdir('\\d1\\','d2')", '\\d1\\d2' ],
233 [ "Win32->catdir('\\d1','d2')", '\\d1\\d2' ],
234 [ "Win32->catdir('\\d1','\\d2')", '\\d1\\d2' ],
235 [ "Win32->catdir('\\d1','\\d2\\')", '\\d1\\d2' ],
236 [ "Win32->catdir('','/d1','d2')", '\\d1\\d2' ],
237 [ "Win32->catdir('','','/d1','d2')", '\\d1\\d2' ],
238 [ "Win32->catdir('','//d1','d2')", '\\d1\\d2' ],
239 [ "Win32->catdir('','','//d1','d2')", '\\d1\\d2' ],
240 [ "Win32->catdir('','d1','','d2','')", '\\d1\\d2' ],
241 [ "Win32->catdir('','d1','d2','d3','')", '\\d1\\d2\\d3' ],
242 [ "Win32->catdir('d1','d2','d3','')", 'd1\\d2\\d3' ],
243 [ "Win32->catdir('','d1','d2','d3')", '\\d1\\d2\\d3' ],
244 [ "Win32->catdir('d1','d2','d3')", 'd1\\d2\\d3' ],
245 [ "Win32->catdir('A:/d1','d2','d3')", 'A:\\d1\\d2\\d3' ],
246 [ "Win32->catdir('A:/d1','d2','d3','')", 'A:\\d1\\d2\\d3' ],
247 #[ "Win32->catdir('A:/d1','B:/d2','d3','')", 'A:\\d1\\d2\\d3' ],
248 [ "Win32->catdir('A:/d1','B:/d2','d3','')", 'A:\\d1\\B:\\d2\\d3' ],
249 [ "Win32->catdir('A:/')", 'A:\\' ],
250 [ "Win32->catdir('\\', 'foo')", '\\foo' ],
251 [ "Win32->catdir('','','..')", '\\' ],
252 [ "Win32->catdir('A:', 'foo')", 'A:\\foo' ],
254 [ "Win32->catfile('a','b','c')", 'a\\b\\c' ],
255 [ "Win32->catfile('a','b','.\\c')", 'a\\b\\c' ],
256 [ "Win32->catfile('.\\a','b','c')", 'a\\b\\c' ],
257 [ "Win32->catfile('c')", 'c' ],
258 [ "Win32->catfile('.\\c')", 'c' ],
259 [ "Win32->catfile('a/..','../b')", '..\\b' ],
260 [ "Win32->catfile('A:', 'foo')", 'A:\\foo' ],
263 [ "Win32->canonpath('')", '' ],
264 [ "Win32->canonpath('a:')", 'A:' ],
265 [ "Win32->canonpath('A:f')", 'A:f' ],
266 [ "Win32->canonpath('A:/')", 'A:\\' ],
268 [ "Win32->canonpath('a\\..\\..\\b\\c')", '..\\b\\c' ],
269 [ "Win32->canonpath('//a\\b//c')", '\\\\a\\b\\c' ],
270 [ "Win32->canonpath('/a/..../c')", '\\a\\....\\c' ],
271 [ "Win32->canonpath('//a/b\\c')", '\\\\a\\b\\c' ],
272 [ "Win32->canonpath('////')", '\\' ],
273 [ "Win32->canonpath('//')", '\\' ],
274 [ "Win32->canonpath('/.')", '\\' ],
275 [ "Win32->canonpath('//a/b/../../c')", '\\\\a\\b\\c' ],
276 [ "Win32->canonpath('//a/b/c/../d')", '\\\\a\\b\\d' ],
277 [ "Win32->canonpath('//a/b/c/../../d')",'\\\\a\\b\\d' ],
278 [ "Win32->canonpath('//a/b/c/.../d')", '\\\\a\\b\\d' ],
279 [ "Win32->canonpath('/a/b/c/../../d')", '\\a\\d' ],
280 [ "Win32->canonpath('/a/b/c/.../d')", '\\a\\d' ],
281 [ "Win32->canonpath('\\../temp\\')", '\\temp' ],
282 [ "Win32->canonpath('\\../')", '\\' ],
283 [ "Win32->canonpath('\\..\\')", '\\' ],
284 [ "Win32->canonpath('/../')", '\\' ],
285 [ "Win32->canonpath('/..\\')", '\\' ],
286 [ "Win32->canonpath('d1/../foo')", 'foo' ],
288 # FakeWin32 subclass (see below) just sets CWD to C:\one\two and getdcwd('D') to D:\alpha\beta
290 [ "FakeWin32->abs2rel('/t1/t2/t3','/t1/t2/t3')", '.' ],
291 [ "FakeWin32->abs2rel('/t1/t2/t4','/t1/t2/t3')", '..\\t4' ],
292 [ "FakeWin32->abs2rel('/t1/t2','/t1/t2/t3')", '..' ],
293 [ "FakeWin32->abs2rel('/t1/t2/t3/t4','/t1/t2/t3')", 't4' ],
294 [ "FakeWin32->abs2rel('/t4/t5/t6','/t1/t2/t3')", '..\\..\\..\\t4\\t5\\t6' ],
295 [ "FakeWin32->abs2rel('../t4','/t1/t2/t3')", '..\\..\\..\\one\\t4' ], # Uses _cwd()
296 [ "FakeWin32->abs2rel('/','/t1/t2/t3')", '..\\..\\..' ],
297 [ "FakeWin32->abs2rel('///','/t1/t2/t3')", '..\\..\\..' ],
298 [ "FakeWin32->abs2rel('/.','/t1/t2/t3')", '..\\..\\..' ],
299 [ "FakeWin32->abs2rel('/./','/t1/t2/t3')", '..\\..\\..' ],
300 [ "FakeWin32->abs2rel('\\\\a/t1/t2/t4','/t2/t3')", '\\\\a\\t1\\t2\\t4' ],
301 [ "FakeWin32->abs2rel('//a/t1/t2/t4','/t2/t3')", '\\\\a\\t1\\t2\\t4' ],
302 [ "FakeWin32->abs2rel('A:/t1/t2/t3','A:/t1/t2/t3')", '.' ],
303 [ "FakeWin32->abs2rel('A:/t1/t2/t3/t4','A:/t1/t2/t3')", 't4' ],
304 [ "FakeWin32->abs2rel('A:/t1/t2/t3','A:/t1/t2/t3/t4')", '..' ],
305 [ "FakeWin32->abs2rel('A:/t1/t2/t3','B:/t1/t2/t3')", 'A:\\t1\\t2\\t3' ],
306 [ "FakeWin32->abs2rel('A:/t1/t2/t3/t4','B:/t1/t2/t3')", 'A:\\t1\\t2\\t3\\t4' ],
307 [ "FakeWin32->abs2rel('E:/foo/bar/baz')", 'E:\\foo\\bar\\baz' ],
308 [ "FakeWin32->abs2rel('C:/one/two/three')", 'three' ],
309 [ "FakeWin32->abs2rel('C:\\Windows\\System32', 'C:\\')", 'Windows\System32' ],
310 [ "FakeWin32->abs2rel('\\\\computer2\\share3\\foo.txt', '\\\\computer2\\share3')", 'foo.txt' ],
311 [ "FakeWin32->abs2rel('C:\\one\\two\\t\\asd1\\', 't\\asd\\')", '..\\asd1' ],
312 [ "FakeWin32->abs2rel('\\one\\two', 'A:\\foo')", 'C:\\one\\two' ],
314 [ "FakeWin32->rel2abs('temp','C:/')", 'C:\\temp' ],
315 [ "FakeWin32->rel2abs('temp','C:/a')", 'C:\\a\\temp' ],
316 [ "FakeWin32->rel2abs('temp','C:/a/')", 'C:\\a\\temp' ],
317 [ "FakeWin32->rel2abs('../','C:/')", 'C:\\' ],
318 [ "FakeWin32->rel2abs('../','C:/a')", 'C:\\' ],
319 [ "FakeWin32->rel2abs('\\foo','C:/a')", 'C:\\foo' ],
320 [ "FakeWin32->rel2abs('temp','//prague_main/work/')", '\\\\prague_main\\work\\temp' ],
321 [ "FakeWin32->rel2abs('../temp','//prague_main/work/')", '\\\\prague_main\\work\\temp' ],
322 [ "FakeWin32->rel2abs('temp','//prague_main/work')", '\\\\prague_main\\work\\temp' ],
323 [ "FakeWin32->rel2abs('../','//prague_main/work')", '\\\\prague_main\\work' ],
324 [ "FakeWin32->rel2abs('D:foo.txt')", 'D:\\alpha\\beta\\foo.txt' ],
326 [ "VMS->case_tolerant()", '1' ],
328 [ "VMS->catfile('a','b','c')", $vms_unix_rpt ? 'a/b/c' : '[.a.b]c' ],
329 [ "VMS->catfile('a','b','[]c')", $vms_unix_rpt ? 'a/b/c' : '[.a.b]c' ],
330 [ "VMS->catfile('[.a]','b','c')", $vms_unix_rpt ? 'a/b/c' : '[.a.b]c' ],
331 [ "VMS->catfile('a/b/','c')", $vms_unix_rpt ? 'a/b/c' : '[.a.b]c' ],
332 [ "VMS->catfile('c')", 'c' ],
333 [ "VMS->catfile('[]c')", 'c' ],
335 [ "VMS->catfile('0','b','c')", $vms_unix_rpt ? '0/b/c' : '[.0.b]c' ],
336 [ "VMS->catfile('a','0','c')", $vms_unix_rpt ? 'a/0/c' : '[.a.0]c' ],
337 [ "VMS->catfile('a','b','0')", $vms_unix_rpt ? 'a/b/0' : '[.a.b]0' ],
338 [ "VMS->catfile('0','0','c')", $vms_unix_rpt ? '0/0/c' : '[.0.0]c' ],
339 [ "VMS->catfile('a','0','0')", $vms_unix_rpt ? 'a/0/0' : '[.a.0]0' ],
340 [ "VMS->catfile('0','b','0')", $vms_unix_rpt ? '0/b/0' : '[.0.b]0' ],
341 [ "VMS->catfile('0','0','0')", $vms_unix_rpt ? '0/0/0' : '[.0.0]0' ],
344 [ "VMS->splitpath('file')", ',,file' ],
345 [ "VMS->splitpath('[d1.d2.d3]')", ',[d1.d2.d3],' ],
346 [ "VMS->splitpath('[.d1.d2.d3]')", ',[.d1.d2.d3],' ],
347 [ "VMS->splitpath('[d1.d2.d3]file')", ',[d1.d2.d3],file' ],
348 [ "VMS->splitpath('d1/d2/d3/file')",
349 $vms_unix_rpt ? ',d1/d2/d3/,file' : ',[.d1.d2.d3],file' ],
350 [ "VMS->splitpath('/d1/d2/d3/file')",
351 $vms_unix_rpt ? ',/d1/d2/d3/,file' : 'd1:,[d2.d3],file' ],
352 [ "VMS->splitpath('[.d1.d2.d3]file')", ',[.d1.d2.d3],file' ],
353 [ "VMS->splitpath('node::volume:[d1.d2.d3]')", 'node::volume:,[d1.d2.d3],' ],
354 [ "VMS->splitpath('node::volume:[d1.d2.d3]file')", 'node::volume:,[d1.d2.d3],file' ],
355 [ "VMS->splitpath('node\"access_spec\"::volume:[d1.d2.d3]')", 'node"access_spec"::volume:,[d1.d2.d3],' ],
356 [ "VMS->splitpath('node\"access_spec\"::volume:[d1.d2.d3]file')", 'node"access_spec"::volume:,[d1.d2.d3],file' ],
358 [ "VMS->splitpath('[]')", ',[],' ],
359 [ "VMS->splitpath('[-]')", ',[-],' ],
360 [ "VMS->splitpath('[]file')", ',[],file' ],
361 [ "VMS->splitpath('[-]file')", ',[-],file' ],
362 [ "VMS->splitpath('')", ',,' ],
363 [ "VMS->splitpath('0')", ',,0' ],
364 [ "VMS->splitpath('[0]')", ',[0],' ],
365 [ "VMS->splitpath('[.0]')", ',[.0],' ],
366 [ "VMS->splitpath('[0.0.0]')", ',[0.0.0],' ],
367 [ "VMS->splitpath('[.0.0.0]')", ',[.0.0.0],' ],
368 [ "VMS->splitpath('[0]0')", ',[0],0' ],
369 [ "VMS->splitpath('[0.0.0]0')", ',[0.0.0],0' ],
370 [ "VMS->splitpath('[.0.0.0]0')", ',[.0.0.0],0' ],
371 [ "VMS->splitpath('0/0')", $vms_unix_rpt ? ',0/,0' : ',[.0],0' ],
372 [ "VMS->splitpath('0/0/0')", $vms_unix_rpt ? ',0/0/,0' : ',[.0.0],0' ],
373 [ "VMS->splitpath('/0/0')", $vms_unix_rpt ? ',/0/,0' : '0:,[000000],0' ],
374 [ "VMS->splitpath('/0/0/0')", $vms_unix_rpt ? ',/0/0/,0' : '0:,[0],0' ],
375 [ "VMS->splitpath('d1',1)", ',d1,' ],
377 [ "VMS->splitpath('[d1.d2.d3]',1)", ',[d1.d2.d3],' ],
378 [ "VMS->splitpath('[.d1.d2.d3]',1)", ',[.d1.d2.d3],' ],
379 [ "VMS->splitpath('d1/d2/d3',1)", $vms_unix_rpt ? ',d1/d2/d3,' : ',[.d1.d2.d3],' ],
380 [ "VMS->splitpath('/d1/d2/d3',1)", $vms_unix_rpt ? ',/d1/d2/d3,' : 'd1:,[d2.d3],' ],
381 [ "VMS->splitpath('node::volume:[d1.d2.d3]',1)", 'node::volume:,[d1.d2.d3],' ],
382 [ "VMS->splitpath('node\"access_spec\"::volume:[d1.d2.d3]',1)", 'node"access_spec"::volume:,[d1.d2.d3],' ],
383 [ "VMS->splitpath('[]',1)", ',[],' ],
384 [ "VMS->splitpath('[-]',1)", ',[-],' ],
385 [ "VMS->splitpath('',1)", ',,' ],
386 [ "VMS->splitpath('0',1)", ',0,' ],
387 [ "VMS->splitpath('[0]',1)", ',[0],' ],
388 [ "VMS->splitpath('[.0]',1)", ',[.0],' ],
389 [ "VMS->splitpath('[0.0.0]',1)", ',[0.0.0],' ],
390 [ "VMS->splitpath('[.0.0.0]',1)", ',[.0.0.0],' ],
391 [ "VMS->splitpath('0/0',1)", $vms_unix_rpt ? ',0/0,' : ',[.0.0],' ],
392 [ "VMS->splitpath('0/0/0',1)", $vms_unix_rpt ? ',0/0/0,' : ',[.0.0.0],' ],
393 [ "VMS->splitpath('/0/0',1)", $vms_unix_rpt ? ',/0/0,' : '0:,[000000.0],' ],
394 [ "VMS->splitpath('/0/0/0',1)", $vms_unix_rpt ? ',/0/0/0,' : '0:,[0.0],' ],
396 [ "VMS->catpath('','','file')", 'file' ],
397 [ "VMS->catpath('','[d1.d2.d3]','')", '[d1.d2.d3]' ],
398 [ "VMS->catpath('','[.d1.d2.d3]','')", '[.d1.d2.d3]' ],
399 [ "VMS->catpath('','[d1.d2.d3]','file')", '[d1.d2.d3]file' ],
400 [ "VMS->catpath('','[.d1.d2.d3]','file')", '[.d1.d2.d3]file' ],
401 [ "VMS->catpath('','d1/d2/d3','file')",
402 $vms_unix_rpt ? 'd1/d2/d3/file' : '[.d1.d2.d3]file' ],
403 [ "VMS->catpath('v','d1/d2/d3','file')", 'v:[.d1.d2.d3]file' ],
404 [ "VMS->catpath('v','','file')", 'v:file' ],
405 [ "VMS->catpath('v','w:[d1.d2.d3]','file')", 'v:[d1.d2.d3]file' ],
406 [ "VMS->catpath('node::volume:','[d1.d2.d3]','')", 'node::volume:[d1.d2.d3]' ],
407 [ "VMS->catpath('node::volume:','[d1.d2.d3]','file')", 'node::volume:[d1.d2.d3]file' ],
408 [ "VMS->catpath('node\"access_spec\"::volume:','[d1.d2.d3]','')", 'node"access_spec"::volume:[d1.d2.d3]' ],
409 [ "VMS->catpath('node\"access_spec\"::volume:','[d1.d2.d3]','file')", 'node"access_spec"::volume:[d1.d2.d3]file' ],
411 [ "VMS->canonpath('')", '' ],
412 [ "VMS->canonpath('volume:[d1]file')", $vms_unix_rpt ? '/volume/d1/file' : 'volume:[d1]file' ],
413 [ "VMS->canonpath('volume:[d1.-.d2.][d3.d4.-]')", $vms_unix_rpt ? '/volume/d2/d3/' : 'volume:[d2.d3]' ],
414 [ "VMS->canonpath('volume:[000000.d1]d2.dir;1')", $vms_unix_rpt ? '/volume/d1/d2.dir.1' : 'volume:[d1]d2.dir;1' ],
415 [ "VMS->canonpath('volume:[d1.d2.d3]file.txt')", $vms_unix_rpt ? '/volume/d1/d2/d3/file.txt' : 'volume:[d1.d2.d3]file.txt' ],
416 [ "VMS->canonpath('[d1.d2.d3]file.txt')", $vms_unix_rpt ? '/sys$disk/d1/d2/d3/file.txt' : '[d1.d2.d3]file.txt' ],
417 [ "VMS->canonpath('volume:[-.d1.d2.d3]file.txt')", $vms_unix_rpt ? '/volume/../d1/d2/d3/file.txt' : 'volume:[-.d1.d2.d3]file.txt' ],
418 [ "VMS->canonpath('[-.d1.d2.d3]file.txt')", $vms_unix_rpt ? '../d1/d2/d3/file.txt' : '[-.d1.d2.d3]file.txt' ],
419 [ "VMS->canonpath('volume:[--.d1.d2.d3]file.txt')", $vms_unix_rpt ? '/volume/../../d1/d2/d3/file.txt' : 'volume:[--.d1.d2.d3]file.txt' ],
420 [ "VMS->canonpath('[--.d1.d2.d3]file.txt')", $vms_unix_rpt ? '../../d1/d2/d3/file.txt' : '[--.d1.d2.d3]file.txt' ],
421 [ "VMS->canonpath('volume:[d1.-.d2.d3]file.txt')", $vms_unix_rpt ? '/volume/d2/d3/file.txt' : 'volume:[d2.d3]file.txt' ],
422 [ "VMS->canonpath('[d1.-.d2.d3]file.txt')", $vms_unix_rpt ? '/sys$disk/d2/d3/file.txt' : '[d2.d3]file.txt' ],
423 [ "VMS->canonpath('volume:[d1.--.d2.d3]file.txt')", $vms_unix_rpt ? '/volume/../d2/d3/file.txt' : 'volume:[-.d2.d3]file.txt' ],
424 [ "VMS->canonpath('[d1.--.d2.d3]file.txt')", $vms_unix_rpt ? '../d2/d3/file.txt' : '[-.d2.d3]file.txt' ],
425 [ "VMS->canonpath('volume:[d1.d2.-.d3]file.txt')", $vms_unix_rpt ? '/volume/d1/d3/file.txt' : 'volume:[d1.d3]file.txt' ],
426 [ "VMS->canonpath('[d1.d2.-.d3]file.txt')", $vms_unix_rpt ? '/sys$disk/d1/d3/file.txt' : '[d1.d3]file.txt' ],
427 [ "VMS->canonpath('volume:[d1.d2.--.d3]file.txt')", $vms_unix_rpt ? '/volume/d3/file.txt' : 'volume:[d3]file.txt' ],
428 [ "VMS->canonpath('[d1.d2.--.d3]file.txt')", $vms_unix_rpt ? '/sys$disk/d3/file.txt' : '[d3]file.txt' ],
429 [ "VMS->canonpath('volume:[d1.d2.d3.-]file.txt')", $vms_unix_rpt ? '/volume/d1/d2/file.txt' : 'volume:[d1.d2]file.txt' ],
430 [ "VMS->canonpath('[d1.d2.d3.-]file.txt')", $vms_unix_rpt ? '/sys$disk/d1/d2/file.txt' : '[d1.d2]file.txt' ],
431 [ "VMS->canonpath('volume:[d1.d2.d3.--]file.txt')", $vms_unix_rpt ? '/volume/d1/file.txt' : 'volume:[d1]file.txt' ],
432 [ "VMS->canonpath('[d1.d2.d3.--]file.txt')", $vms_unix_rpt ? '/sys$disk/d1/file.txt' : '[d1]file.txt' ],
433 [ "VMS->canonpath('volume:[d1.000000.][000000.][d3.--]file.txt')", $vms_unix_rpt ? '/volume/d1/file.txt'
434 : 'volume:[d1]file.txt' ],
435 [ "VMS->canonpath('[d1.000000.][000000.][d3.--]file.txt')", $vms_unix_rpt ? '/sys$disk/d1/file.txt'
437 [ "VMS->canonpath('volume:[d1.000000.][000000.][d2.000000]file.txt')", $vms_unix_rpt ? '/volume/d1/000000/d2/000000/file.txt'
438 : 'volume:[d1.000000.d2.000000]file.txt' ],
439 [ "VMS->canonpath('[d1.000000.][000000.][d2.000000]file.txt')", $vms_unix_rpt ? '/sys$disk/d1/000000/d2/000000/file.txt'
440 : '[d1.000000.d2.000000]file.txt' ],
441 [ "VMS->canonpath('volume:[d1.000000.][000000.][d3.--.000000]file.txt')", $vms_unix_rpt ? '/volume/d1/000000/file.txt'
442 : 'volume:[d1.000000]file.txt' ],
443 [ "VMS->canonpath('[d1.000000.][000000.][d3.--.000000]file.txt')", $vms_unix_rpt ? '/sys$disk/d1/000000/file.txt'
444 : '[d1.000000]file.txt' ],
445 [ "VMS->canonpath('volume:[d1.000000.][000000.][-.-.000000]file.txt')", $vms_unix_rpt ? '/volume/file.txt'
446 : 'volume:[000000]file.txt' ],
447 [ "VMS->canonpath('[d1.000000.][000000.][--.-.000000]file.txt')", $vms_unix_rpt ? '../file.txt' : '[-.000000]file.txt' ],
448 [ "VMS->canonpath('[d1.d2.--]file')", $vms_unix_rpt ? '../file.txt' : '[000000]file' ],
449 # During the Perl 5.8 era, FS::Unix stopped eliminating redundant path elements, so mimic that here.
450 [ "VMS->canonpath('a/../../b/c.dat')", $vms_unix_rpt ? 'a/../../b/c.dat' : '[-.b]c.dat' ],
451 [ "VMS->canonpath('^<test^.new.-.caret^ escapes^>')", $vms_unix_rpt ? '/<test.new.-.caret escapes>' : '^<test^.new.-.caret^ escapes^>' ],
452 # Check that directory specs with caret-dot component is treated correctly
453 [ "VMS->canonpath('foo:[bar.coo.kie.--]file.txt')", $vms_unix_rpt ? '/foo/bar/file.txt' : "foo:[bar]file.txt" ],
454 [ "VMS->canonpath('foo:[bar^.coo.kie.--]file.txt')", $vms_unix_rpt ? '/foo/file.txt' : "foo:[000000]file.txt" ],
455 [ "VMS->canonpath('foo:[bar.coo^.kie.--]file.txt')", $vms_unix_rpt ? '/foo/file.txt' : "foo:[000000]file.txt" ],
456 [ "VMS->canonpath('foo:[bar.coo.kie.-]file.txt')", $vms_unix_rpt ? '/foo/bar/coo/file.txt' : "foo:[bar.coo]file.txt" ],
457 [ "VMS->canonpath('foo:[bar^.coo.kie.-]file.txt')", $vms_unix_rpt ? '/foo/bar.coo/file.txt' : "foo:[bar^.coo]file.txt" ],
458 [ "VMS->canonpath('foo:[bar.coo^.kie.-]file.txt')", $vms_unix_rpt ? '/foo/bar/file.txt' : "foo:[bar]file.txt" ],
460 [ "VMS->splitdir('')", '' ],
461 [ "VMS->splitdir('[]')", '' ],
462 [ "VMS->splitdir('d1.d2.d3')", 'd1,d2,d3' ],
463 [ "VMS->splitdir('[d1.d2.d3]')", 'd1,d2,d3' ],
464 [ "VMS->splitdir('.d1.d2.d3')", 'd1,d2,d3' ],
465 [ "VMS->splitdir('[.d1.d2.d3]')", 'd1,d2,d3' ],
466 [ "VMS->splitdir('.-.d2.d3')", '-,d2,d3' ],
467 [ "VMS->splitdir('[.-.d2.d3]')", '-,d2,d3' ],
468 [ "VMS->splitdir('[d1.d2]')", 'd1,d2' ],
469 [ "VMS->splitdir('[d1-.--d2]')", 'd1-,--d2' ],
470 [ "VMS->splitdir('[d1---.-.d2]')", 'd1---,-,d2' ],
471 [ "VMS->splitdir('[d1.---.d2]')", 'd1,-,-,-,d2' ],
472 [ "VMS->splitdir('[d1---d2]')", 'd1---d2' ],
473 [ "VMS->splitdir('[d1.][000000.d2]')", 'd1,d2' ],
474 [ "VMS->splitdir('[.d1.d2^.d3]')", 'd1,d2^.d3' ],
476 [ "VMS->catdir('')", '' ],
477 [ "VMS->catdir('foo')", $vms_unix_rpt ? 'foo' : '[.foo]' ],
478 [ "VMS->catdir('d1','d2','d3')", $vms_unix_rpt ? 'd1/d2/d3' : '[.d1.d2.d3]' ],
479 [ "VMS->catdir('d1','d2/','d3')", $vms_unix_rpt ? 'd1/d2/d3' : '[.d1.d2.d3]' ],
480 [ "VMS->catdir('','d1','d2','d3')",$vms_unix_rpt ? '/d1/d2/d3' : '[.d1.d2.d3]' ],
481 [ "VMS->catdir('','-','d2','d3')", $vms_unix_rpt ? '-/d2/d3' : '[-.d2.d3]' ],
482 [ "VMS->catdir('','-','','d3')", $vms_unix_rpt ? '-/d3' : '[-.d3]' ],
483 [ "VMS->catdir('dir.dir','d2.dir','d3.dir')", $vms_unix_rpt ? 'dir/d2/d3'
485 [ "VMS->catdir('[.name]')", $vms_unix_rpt ? 'name/' : '[.name]' ],
486 [ "VMS->catdir('[.name]','[.name]')", $vms_unix_rpt ? 'name/name' :'[.name.name]' ],
487 [ "VMS->catdir('/a/b/c','[-]')", $vms_unix_rpt ? '/a/b/c/..' : 'a:[b]'],
488 [ "VMS->catdir('a:[b.c]','..')", $vms_unix_rpt ? '/a/b/c/..' : 'a:[b]'],
490 [ "VMS->abs2rel('node::volume:[t1.t2.t3]','node::volume:[t1.t2.t3]')", $vms_unix_rpt ? './' : '[]' ],
491 [ "VMS->abs2rel('node::volume:[t1.t2.t3]','[t1.t2.t3]')", $vms_unix_rpt ? '/node//volume/t1/t2/t3/' : 'node::volume:[t1.t2.t3]' ],
492 [ "VMS->abs2rel('node::volume:[t1.t2.t4]','node::volume:[t1.t2.t3]')", $vms_unix_rpt ? '../t4/' : '[-.t4]' ],
493 [ "VMS->abs2rel('node::volume:[t1.t2.t4]','[t1.t2.t3]')", $vms_unix_rpt ? '/node//volume/t1/t2/t4/' : 'node::volume:[t1.t2.t4]' ],
494 [ "VMS->abs2rel('/volume/t1/t2/t3','/volume/t1')", $vms_unix_rpt ? 't2/t3' : '[.t2]t3' ],
495 [ "VMS->abs2rel('/volume/t1/t2/t3/t4','/volume/t1/xyz')", $vms_unix_rpt ? '../t2/t3/t4' : '[-.t2.t3]t4' ],
496 [ "VMS->abs2rel('[t1.t2.t3]','[t1.t2.t3]')", $vms_unix_rpt ? './' : '[]' ],
497 [ "VMS->abs2rel('[t1.t2.t3]file','[t1.t2.t3]')", 'file' ],
498 [ "VMS->abs2rel('[t1.t2.t3]file','[t1.t2]')", $vms_unix_rpt ? 't3/file' : '[.t3]file' ],
499 [ "VMS->abs2rel('v:[t1.t2.t3]file','v:[t1.t2]')", $vms_unix_rpt ? 't3/file' : '[.t3]file' ],
500 [ "VMS->abs2rel('[t1.t2.t4]','[t1.t2.t3]')", $vms_unix_rpt ? '../t4/' : '[-.t4]' ],
501 [ "VMS->abs2rel('[t1.t2]file','[t1.t2.t3]')", $vms_unix_rpt ? '../file' : '[-]file' ],
502 [ "VMS->abs2rel('[t1.t2.t3.t4]','[t1.t2.t3]')", $vms_unix_rpt ? 't4/' : '[.t4]' ],
503 [ "VMS->abs2rel('[t4.t5.t6]','[t1.t2.t3]')", $vms_unix_rpt ? '../../../t4/t5/t6/' : '[---.t4.t5.t6]' ],
504 [ "VMS->abs2rel('[000000]','[t1.t2.t3]')", $vms_unix_rpt ? '../../../' : '[---]' ],
505 [ "VMS->abs2rel('a:[t1.t2.t4]','a:[t1.t2.t3]')", $vms_unix_rpt ? '../t4/' : '[-.t4]' ],
506 [ "VMS->abs2rel('a:[t1.t2.t4]','[t1.t2.t3]')", $vms_unix_rpt ? '/a/t1/t2/t4' : 'a:[t1.t2.t4]' ],
507 [ "VMS->abs2rel('[a.-.b.c.-]','[t1.t2.t3]')", $vms_unix_rpt ? '../../../b/' : '[---.b]' ],
509 [ "VMS->rel2abs('[.t4]','[t1.t2.t3]')", $vms_unix_rpt ? '/sys$disk/t1/t2/t3/t4/' : '[t1.t2.t3.t4]' ],
510 [ "VMS->rel2abs('[.t4.t5]','[t1.t2.t3]')", $vms_unix_rpt ? '/sys$disk/t1/t2/t3/t4/t5/' : '[t1.t2.t3.t4.t5]' ],
511 [ "VMS->rel2abs('[]','[t1.t2.t3]')", $vms_unix_rpt ? '/sys$disk/t1/t2/t3/' : '[t1.t2.t3]' ],
512 [ "VMS->rel2abs('[-]','[t1.t2.t3]')", $vms_unix_rpt ? '/sys$disk/t1/t2/' : '[t1.t2]' ],
513 [ "VMS->rel2abs('[-.t4]','[t1.t2.t3]')", $vms_unix_rpt ? '/sys$disk/t1/t2/t4/' : '[t1.t2.t4]' ],
514 [ "VMS->rel2abs('[t1]','[t1.t2.t3]')", $vms_unix_rpt ? '/sys$disk/t1/' : '[t1]' ],
516 [ "VMS->file_name_is_absolute('foo:')", '1' ],
517 [ "VMS->file_name_is_absolute('foo:bar.dat')", '1' ],
518 [ "VMS->file_name_is_absolute('foo:[000000]bar.dat')", '1' ],
520 [ "OS2->case_tolerant()", '1' ],
522 [ "OS2->catdir('A:/d1','B:/d2','d3','')", 'A:/d1/B:/d2/d3' ],
524 [ "OS2->catfile('a','b','c')", 'a/b/c' ],
525 [ "OS2->catfile('a','b','./c')", 'a/b/c' ],
526 [ "OS2->catfile('./a','b','c')", 'a/b/c' ],
527 [ "OS2->catfile('c')", 'c' ],
528 [ "OS2->catfile('./c')", 'c' ],
530 [ "OS2->catdir('/', '../')", '/' ],
531 [ "OS2->catdir('/', '..\\')", '/' ],
532 [ "OS2->catdir('\\', '../')", '/' ],
533 [ "OS2->catdir('\\', '..\\')", '/' ],
535 [ "Mac->case_tolerant()", '1' ],
537 [ "Mac->catpath('','','')", '' ],
538 [ "Mac->catpath('',':','')", ':' ],
539 [ "Mac->catpath('','::','')", '::' ],
541 [ "Mac->catpath('hd','','')", 'hd:' ],
542 [ "Mac->catpath('hd:','','')", 'hd:' ],
543 [ "Mac->catpath('hd:',':','')", 'hd:' ],
544 [ "Mac->catpath('hd:','::','')", 'hd::' ],
546 [ "Mac->catpath('hd','','file')", 'hd:file' ],
547 [ "Mac->catpath('hd',':','file')", 'hd:file' ],
548 [ "Mac->catpath('hd','::','file')", 'hd::file' ],
549 [ "Mac->catpath('hd',':::','file')", 'hd:::file' ],
551 [ "Mac->catpath('hd:','',':file')", 'hd:file' ],
552 [ "Mac->catpath('hd:',':',':file')", 'hd:file' ],
553 [ "Mac->catpath('hd:','::',':file')", 'hd::file' ],
554 [ "Mac->catpath('hd:',':::',':file')", 'hd:::file' ],
556 [ "Mac->catpath('hd:','d1','file')", 'hd:d1:file' ],
557 [ "Mac->catpath('hd:',':d1:',':file')", 'hd:d1:file' ],
558 [ "Mac->catpath('hd:','hd:d1','')", 'hd:d1:' ],
560 [ "Mac->catpath('','d1','')", ':d1:' ],
561 [ "Mac->catpath('',':d1','')", ':d1:' ],
562 [ "Mac->catpath('',':d1:','')", ':d1:' ],
564 [ "Mac->catpath('','d1','file')", ':d1:file' ],
565 [ "Mac->catpath('',':d1:',':file')", ':d1:file' ],
567 [ "Mac->catpath('','','file')", 'file' ],
568 [ "Mac->catpath('','',':file')", 'file' ], # !
569 [ "Mac->catpath('',':',':file')", ':file' ], # !
572 [ "Mac->splitpath(':')", ',:,' ],
573 [ "Mac->splitpath('::')", ',::,' ],
574 [ "Mac->splitpath(':::')", ',:::,' ],
576 [ "Mac->splitpath('file')", ',,file' ],
577 [ "Mac->splitpath(':file')", ',:,file' ],
579 [ "Mac->splitpath('d1',1)", ',:d1:,' ], # dir, not volume
580 [ "Mac->splitpath(':d1',1)", ',:d1:,' ],
581 [ "Mac->splitpath(':d1:',1)", ',:d1:,' ],
582 [ "Mac->splitpath(':d1:')", ',:d1:,' ],
583 [ "Mac->splitpath(':d1:d2:d3:')", ',:d1:d2:d3:,' ],
584 [ "Mac->splitpath(':d1:d2:d3:',1)", ',:d1:d2:d3:,' ],
585 [ "Mac->splitpath(':d1:file')", ',:d1:,file' ],
586 [ "Mac->splitpath('::d1:file')", ',::d1:,file' ],
588 [ "Mac->splitpath('hd:', 1)", 'hd:,,' ],
589 [ "Mac->splitpath('hd:')", 'hd:,,' ],
590 [ "Mac->splitpath('hd:d1:d2:')", 'hd:,:d1:d2:,' ],
591 [ "Mac->splitpath('hd:d1:d2',1)", 'hd:,:d1:d2:,' ],
592 [ "Mac->splitpath('hd:d1:d2:file')", 'hd:,:d1:d2:,file' ],
593 [ "Mac->splitpath('hd:d1:d2::file')", 'hd:,:d1:d2::,file' ],
594 [ "Mac->splitpath('hd::d1:d2:file')", 'hd:,::d1:d2:,file' ], # invalid path
595 [ "Mac->splitpath('hd:file')", 'hd:,,file' ],
597 [ "Mac->splitdir()", '' ],
598 [ "Mac->splitdir('')", '' ],
599 [ "Mac->splitdir(':')", ':' ],
600 [ "Mac->splitdir('::')", '::' ],
601 [ "Mac->splitdir(':::')", '::,::' ],
602 [ "Mac->splitdir(':::d1:d2')", '::,::,d1,d2' ],
604 [ "Mac->splitdir(':d1:d2:d3::')", 'd1,d2,d3,::'],
605 [ "Mac->splitdir(':d1:d2:d3:')", 'd1,d2,d3' ],
606 [ "Mac->splitdir(':d1:d2:d3')", 'd1,d2,d3' ],
608 # absolute paths in splitdir() work, but you'd better use splitpath()
609 [ "Mac->splitdir('hd:')", 'hd:' ],
610 [ "Mac->splitdir('hd::')", 'hd:,::' ], # invalid path, but it works
611 [ "Mac->splitdir('hd::d1:')", 'hd:,::,d1' ], # invalid path, but it works
612 [ "Mac->splitdir('hd:d1:d2:::')", 'hd:,d1,d2,::,::' ],
613 [ "Mac->splitdir('hd:d1:d2::')", 'hd:,d1,d2,::' ],
614 [ "Mac->splitdir('hd:d1:d2:')", 'hd:,d1,d2' ],
615 [ "Mac->splitdir('hd:d1:d2')", 'hd:,d1,d2' ],
616 [ "Mac->splitdir('hd:d1::d2::')", 'hd:,d1,::,d2,::' ],
618 [ "Mac->catdir()", '' ],
619 [ "Mac->catdir(':')", ':' ],
621 [ "Mac->catdir(':', ':')", ':' ],
622 [ "Mac->catdir(':', '')", ':' ],
624 [ "Mac->catdir(':', '::')", '::' ],
626 [ "Mac->catdir('::', '')", '::' ],
627 [ "Mac->catdir('::', ':')", '::' ],
629 [ "Mac->catdir('::', '::')", ':::' ],
631 [ "Mac->catdir(':d1')", ':d1:' ],
632 [ "Mac->catdir(':d1:')", ':d1:' ],
633 [ "Mac->catdir(':d1','d2')", ':d1:d2:' ],
634 [ "Mac->catdir(':d1',':d2')", ':d1:d2:' ],
635 [ "Mac->catdir(':d1',':d2:')", ':d1:d2:' ],
636 [ "Mac->catdir(':d1',':d2::')", ':d1:d2::' ],
637 [ "Mac->catdir(':',':d1',':d2')", ':d1:d2:' ],
638 [ "Mac->catdir('::',':d1',':d2')", '::d1:d2:' ],
639 [ "Mac->catdir('::','::',':d1',':d2')", ':::d1:d2:' ],
640 [ "Mac->catdir(':',':',':d1',':d2')", ':d1:d2:' ],
641 [ "Mac->catdir('::',':',':d1',':d2')", '::d1:d2:' ],
643 [ "Mac->catdir('d1')", ':d1:' ],
644 [ "Mac->catdir('d1','d2','d3')", ':d1:d2:d3:' ],
645 [ "Mac->catdir('d1','d2/','d3')", ':d1:d2/:d3:' ],
646 [ "Mac->catdir('d1','',':d2')", ':d1:d2:' ],
647 [ "Mac->catdir('d1',':',':d2')", ':d1:d2:' ],
648 [ "Mac->catdir('d1','::',':d2')", ':d1::d2:' ],
649 [ "Mac->catdir('d1',':::',':d2')", ':d1:::d2:' ],
650 [ "Mac->catdir('d1','::','::',':d2')", ':d1:::d2:' ],
651 [ "Mac->catdir('d1','d2')", ':d1:d2:' ],
652 [ "Mac->catdir('d1','d2', '')", ':d1:d2:' ],
653 [ "Mac->catdir('d1','d2', ':')", ':d1:d2:' ],
654 [ "Mac->catdir('d1','d2', '::')", ':d1:d2::' ],
655 [ "Mac->catdir('d1','d2','','')", ':d1:d2:' ],
656 [ "Mac->catdir('d1','d2',':','::')", ':d1:d2::' ],
657 [ "Mac->catdir('d1','d2','::','::')", ':d1:d2:::' ],
658 [ "Mac->catdir('d1',':d2')", ':d1:d2:' ],
659 [ "Mac->catdir('d1',':d2:')", ':d1:d2:' ],
661 [ "Mac->catdir('hd:',':d1')", 'hd:d1:' ],
662 [ "Mac->catdir('hd:d1:',':d2')", 'hd:d1:d2:' ],
663 [ "Mac->catdir('hd:','d1')", 'hd:d1:' ],
664 [ "Mac->catdir('hd:d1:',':d2')", 'hd:d1:d2:' ],
665 [ "Mac->catdir('hd:d1:',':d2:')", 'hd:d1:d2:' ],
667 [ "Mac->catfile()", '' ],
668 [ "Mac->catfile('')", '' ],
669 [ "Mac->catfile(':')", ':' ],
670 [ "Mac->catfile(':', '')", ':' ],
672 [ "Mac->catfile('d1','d2','file')", ':d1:d2:file' ],
673 [ "Mac->catfile('d1','d2',':file')", ':d1:d2:file' ],
674 [ "Mac->catfile('file')", 'file' ],
675 [ "Mac->catfile(':', 'file')", ':file' ],
677 [ "Mac->canonpath('')", '' ],
678 [ "Mac->canonpath(':')", ':' ],
679 [ "Mac->canonpath('::')", '::' ],
680 [ "Mac->canonpath('a::')", 'a::' ],
681 [ "Mac->canonpath(':a::')", ':a::' ],
683 [ "Mac->abs2rel('hd:d1:d2:','hd:d1:d2:')", ':' ],
684 [ "Mac->abs2rel('hd:d1:d2:','hd:d1:d2:file')", ':' ], # ignore base's file portion
685 [ "Mac->abs2rel('hd:d1:d2:file','hd:d1:d2:')", ':file' ],
686 [ "Mac->abs2rel('hd:d1:','hd:d1:d2:')", '::' ],
687 [ "Mac->abs2rel('hd:d3:','hd:d1:d2:')", ':::d3:' ],
688 [ "Mac->abs2rel('hd:d3:','hd:d1:d2::')", '::d3:' ],
689 [ "Mac->abs2rel('hd:d1:d4:d5:','hd:d1::d2:d3::')", '::d1:d4:d5:' ],
690 [ "Mac->abs2rel('hd:d1:d4:d5:','hd:d1::d2:d3:')", ':::d1:d4:d5:' ], # first, resolve updirs in base
691 [ "Mac->abs2rel('hd:d1:d3:','hd:d1:d2:')", '::d3:' ],
692 [ "Mac->abs2rel('hd:d1::d3:','hd:d1:d2:')", ':::d3:' ],
693 [ "Mac->abs2rel('hd:d3:','hd:d1:d2:')", ':::d3:' ], # same as above
694 [ "Mac->abs2rel('hd:d1:d2:d3:','hd:d1:d2:')", ':d3:' ],
695 [ "Mac->abs2rel('hd:d1:d2:d3::','hd:d1:d2:')", ':d3::' ],
696 [ "Mac->abs2rel('hd1:d3:d4:d5:','hd2:d1:d2:')", 'hd1:d3:d4:d5:'], # volume mismatch
697 [ "Mac->abs2rel('hd:','hd:d1:d2:')", ':::' ],
699 [ "Mac->rel2abs(':d3:','hd:d1:d2:')", 'hd:d1:d2:d3:' ],
700 [ "Mac->rel2abs(':d3:d4:','hd:d1:d2:')", 'hd:d1:d2:d3:d4:' ],
701 [ "Mac->rel2abs('','hd:d1:d2:')", '' ],
702 [ "Mac->rel2abs('::','hd:d1:d2:')", 'hd:d1:d2::' ],
703 [ "Mac->rel2abs('::','hd:d1:d2:file')", 'hd:d1:d2::' ],# ignore base's file portion
704 [ "Mac->rel2abs(':file','hd:d1:d2:')", 'hd:d1:d2:file' ],
705 [ "Mac->rel2abs('::file','hd:d1:d2:')", 'hd:d1:d2::file' ],
706 [ "Mac->rel2abs('::d3:','hd:d1:d2:')", 'hd:d1:d2::d3:' ],
707 [ "Mac->rel2abs('hd:','hd:d1:d2:')", 'hd:' ], # path already absolute
708 [ "Mac->rel2abs('hd:d3:file','hd:d1:d2:')", 'hd:d3:file' ],
709 [ "Mac->rel2abs('hd:d3:','hd:d1:file')", 'hd:d3:' ],
711 [ "Epoc->case_tolerant()", '1' ],
713 [ "Epoc->canonpath('')", '' ],
714 [ "Epoc->canonpath('///../../..//./././a//b/.././c/././')", '/a/b/../c' ],
715 [ "Epoc->canonpath('/./')", '/' ],
716 [ "Epoc->canonpath('/a/./')", '/a' ],
718 # XXX Todo, copied from Unix, but fail. Should they? 2003-07-07 Tels
719 #[ "Epoc->canonpath('/a/.')", '/a' ],
720 #[ "Epoc->canonpath('/.')", '/' ],
722 [ "Cygwin->case_tolerant()", '1' ],
723 [ "Cygwin->catfile('a','b','c')", 'a/b/c' ],
724 [ "Cygwin->catfile('a','b','./c')", 'a/b/c' ],
725 [ "Cygwin->catfile('./a','b','c')", 'a/b/c' ],
726 [ "Cygwin->catfile('c')", 'c' ],
727 [ "Cygwin->catfile('./c')", 'c' ],
729 [ "Cygwin->splitpath('file')", ',,file' ],
730 [ "Cygwin->splitpath('/d1/d2/d3/')", ',/d1/d2/d3/,' ],
731 [ "Cygwin->splitpath('d1/d2/d3/')", ',d1/d2/d3/,' ],
732 [ "Cygwin->splitpath('/d1/d2/d3/.')", ',/d1/d2/d3/.,' ],
733 [ "Cygwin->splitpath('/d1/d2/d3/..')", ',/d1/d2/d3/..,' ],
734 [ "Cygwin->splitpath('/d1/d2/d3/.file')", ',/d1/d2/d3/,.file' ],
735 [ "Cygwin->splitpath('d1/d2/d3/file')", ',d1/d2/d3/,file' ],
736 [ "Cygwin->splitpath('/../../d1/')", ',/../../d1/,' ],
737 [ "Cygwin->splitpath('/././d1/')", ',/././d1/,' ],
739 [ "Cygwin->catpath('','','file')", 'file' ],
740 [ "Cygwin->catpath('','/d1/d2/d3/','')", '/d1/d2/d3/' ],
741 [ "Cygwin->catpath('','d1/d2/d3/','')", 'd1/d2/d3/' ],
742 [ "Cygwin->catpath('','/d1/d2/d3/.','')", '/d1/d2/d3/.' ],
743 [ "Cygwin->catpath('','/d1/d2/d3/..','')", '/d1/d2/d3/..' ],
744 [ "Cygwin->catpath('','/d1/d2/d3/','.file')", '/d1/d2/d3/.file' ],
745 [ "Cygwin->catpath('','d1/d2/d3/','file')", 'd1/d2/d3/file' ],
746 [ "Cygwin->catpath('','/../../d1/','')", '/../../d1/' ],
747 [ "Cygwin->catpath('','/././d1/','')", '/././d1/' ],
748 [ "Cygwin->catpath('d1','d2/d3/','')", 'd2/d3/' ],
749 [ "Cygwin->catpath('d1','d2','d3/')", 'd2/d3/' ],
751 [ "Cygwin->splitdir('')", '' ],
752 [ "Cygwin->splitdir('/d1/d2/d3/')", ',d1,d2,d3,' ],
753 [ "Cygwin->splitdir('d1/d2/d3/')", 'd1,d2,d3,' ],
754 [ "Cygwin->splitdir('/d1/d2/d3')", ',d1,d2,d3' ],
755 [ "Cygwin->splitdir('d1/d2/d3')", 'd1,d2,d3' ],
757 [ "Cygwin->catdir()", '' ],
758 [ "Cygwin->catdir('/')", '/' ],
759 [ "Cygwin->catdir('','d1','d2','d3','')", '/d1/d2/d3' ],
760 [ "Cygwin->catdir('d1','d2','d3','')", 'd1/d2/d3' ],
761 [ "Cygwin->catdir('','d1','d2','d3')", '/d1/d2/d3' ],
762 [ "Cygwin->catdir('d1','d2','d3')", 'd1/d2/d3' ],
763 [ "Cygwin->catdir('/','d2/d3')", '/d2/d3' ],
765 [ "Cygwin->canonpath('///../../..//./././a//b/.././c/././')", '/a/b/../c' ],
766 [ "Cygwin->canonpath('')", '' ],
767 [ "Cygwin->canonpath('a/../../b/c')", 'a/../../b/c' ],
768 [ "Cygwin->canonpath('/.')", '/' ],
769 [ "Cygwin->canonpath('/./')", '/' ],
770 [ "Cygwin->canonpath('/a/./')", '/a' ],
771 [ "Cygwin->canonpath('/a/.')", '/a' ],
772 [ "Cygwin->canonpath('/../../')", '/' ],
773 [ "Cygwin->canonpath('/../..')", '/' ],
775 [ "Cygwin->abs2rel('/t1/t2/t3','/t1/t2/t3')", '.' ],
776 [ "Cygwin->abs2rel('/t1/t2/t4','/t1/t2/t3')", '../t4' ],
777 [ "Cygwin->abs2rel('/t1/t2','/t1/t2/t3')", '..' ],
778 [ "Cygwin->abs2rel('/t1/t2/t3/t4','/t1/t2/t3')", 't4' ],
779 [ "Cygwin->abs2rel('/t4/t5/t6','/t1/t2/t3')", '../../../t4/t5/t6' ],
780 #[ "Cygwin->abs2rel('../t4','/t1/t2/t3')", '../t4' ],
781 [ "Cygwin->abs2rel('/','/t1/t2/t3')", '../../..' ],
782 [ "Cygwin->abs2rel('///','/t1/t2/t3')", '../../..' ],
783 [ "Cygwin->abs2rel('/.','/t1/t2/t3')", '../../..' ],
784 [ "Cygwin->abs2rel('/./','/t1/t2/t3')", '../../..' ],
785 #[ "Cygwin->abs2rel('../t4','/t1/t2/t3')", '../t4' ],
786 [ "Cygwin->abs2rel('/t1/t2/t3', '/')", 't1/t2/t3' ],
787 [ "Cygwin->abs2rel('/t1/t2/t3', '/t1')", 't2/t3' ],
788 [ "Cygwin->abs2rel('t1/t2/t3', 't1')", 't2/t3' ],
789 [ "Cygwin->abs2rel('t1/t2/t3', 't4')", '../t1/t2/t3' ],
791 [ "Cygwin->rel2abs('t4','/t1/t2/t3')", '/t1/t2/t3/t4' ],
792 [ "Cygwin->rel2abs('t4/t5','/t1/t2/t3')", '/t1/t2/t3/t4/t5' ],
793 [ "Cygwin->rel2abs('.','/t1/t2/t3')", '/t1/t2/t3' ],
794 [ "Cygwin->rel2abs('..','/t1/t2/t3')", '/t1/t2/t3/..' ],
795 [ "Cygwin->rel2abs('../t4','/t1/t2/t3')", '/t1/t2/t3/../t4' ],
796 [ "Cygwin->rel2abs('/t1','/t1/t2/t3')", '/t1' ],
797 [ "Cygwin->rel2abs('//t1/t2/t3','/foo')", '//t1/t2/t3' ],
801 can_ok('File::Spec::Win32', '_cwd');
804 package File::Spec::FakeWin32;
805 our @ISA = qw(File::Spec::Win32);
807 sub _cwd { 'C:\\one\\two' }
809 # Some funky stuff to override Cwd::getdcwd() for testing purposes,
810 # in the limited scope of the rel2abs() method.
811 if ($Cwd::VERSION && $Cwd::VERSION gt '2.17') { # Avoid a 'used only once' warning
816 local *Cwd::getdcwd = sub {
817 return 'D:\alpha\beta' if $_[0] eq 'D:';
818 return 'C:\one\two' if $_[0] eq 'C:';
821 *Cwd::getdcwd = *Cwd::getdcwd; # Avoid a 'used only once' warning
822 return $self->SUPER::rel2abs(@_);
824 *rel2abs = *rel2abs; # Avoid a 'used only once' warning
828 # Tries a named function with the given args and compares the result against
829 # an expected result. Works with functions that return scalars or arrays.
831 my ($function, $expected) = @$_;
833 $function =~ s#\\#\\\\#g ;
834 $function =~ s/^([^\$].*->)/File::Spec::$1/;
835 my $got = join ',', eval $function;
839 skip "skip $function: $skip_exception", 1
840 if $@ =~ /^\Q$skip_exception/;
841 is($@, '', $function);
843 is($got, $expected, $function);
848 is +File::Spec::Unix->canonpath(), undef;