5 # Grab all of the plain routines from File::Spec
6 use File::Spec @File::Spec::EXPORT_OK ;
8 require File::Spec::Unix ;
9 require File::Spec::Win32 ;
13 require VMS::Filespec ;
16 my $skip_exception = "Install VMS::Filespec (from vms/ext)" ;
19 # Not pretty, but it allows testing of things not implemented soley
20 # on VMS. It might be better to change File::Spec::VMS to do this,
21 # making it more usable when running on (say) Unix but working with
24 sub File::Spec::VMS::vmsify { die "$skip_exception" }
25 sub File::Spec::VMS::unixify { die "$skip_exception" }
26 sub File::Spec::VMS::vmspath { die "$skip_exception" }
28 $INC{"VMS/Filespec.pm"} = 1 ;
30 require File::Spec::VMS ;
32 require File::Spec::OS2 ;
33 require File::Spec::Mac ;
34 require File::Spec::Epoc ;
35 require File::Spec::Cygwin ;
37 # $root is only needed by Mac OS tests; these particular
38 # tests are skipped on other OSs
41 $root = File::Spec::Mac->rootdir();
44 # Each element in this array is a single test. Storing them this way makes
45 # maintenance easy, and should be OK since perl should be pretty functional
46 # before these tests are run.
49 # [ Function , Expected , Platform ]
51 [ "Unix->case_tolerant()", '0' ],
53 [ "Unix->catfile('a','b','c')", 'a/b/c' ],
54 [ "Unix->catfile('a','b','./c')", 'a/b/c' ],
55 [ "Unix->catfile('./a','b','c')", 'a/b/c' ],
56 [ "Unix->catfile('c')", 'c' ],
57 [ "Unix->catfile('./c')", 'c' ],
59 [ "Unix->splitpath('file')", ',,file' ],
60 [ "Unix->splitpath('/d1/d2/d3/')", ',/d1/d2/d3/,' ],
61 [ "Unix->splitpath('d1/d2/d3/')", ',d1/d2/d3/,' ],
62 [ "Unix->splitpath('/d1/d2/d3/.')", ',/d1/d2/d3/.,' ],
63 [ "Unix->splitpath('/d1/d2/d3/..')", ',/d1/d2/d3/..,' ],
64 [ "Unix->splitpath('/d1/d2/d3/.file')", ',/d1/d2/d3/,.file' ],
65 [ "Unix->splitpath('d1/d2/d3/file')", ',d1/d2/d3/,file' ],
66 [ "Unix->splitpath('/../../d1/')", ',/../../d1/,' ],
67 [ "Unix->splitpath('/././d1/')", ',/././d1/,' ],
69 [ "Unix->catpath('','','file')", 'file' ],
70 [ "Unix->catpath('','/d1/d2/d3/','')", '/d1/d2/d3/' ],
71 [ "Unix->catpath('','d1/d2/d3/','')", 'd1/d2/d3/' ],
72 [ "Unix->catpath('','/d1/d2/d3/.','')", '/d1/d2/d3/.' ],
73 [ "Unix->catpath('','/d1/d2/d3/..','')", '/d1/d2/d3/..' ],
74 [ "Unix->catpath('','/d1/d2/d3/','.file')", '/d1/d2/d3/.file' ],
75 [ "Unix->catpath('','d1/d2/d3/','file')", 'd1/d2/d3/file' ],
76 [ "Unix->catpath('','/../../d1/','')", '/../../d1/' ],
77 [ "Unix->catpath('','/././d1/','')", '/././d1/' ],
78 [ "Unix->catpath('d1','d2/d3/','')", 'd2/d3/' ],
79 [ "Unix->catpath('d1','d2','d3/')", 'd2/d3/' ],
81 [ "Unix->splitdir('')", '' ],
82 [ "Unix->splitdir('/d1/d2/d3/')", ',d1,d2,d3,' ],
83 [ "Unix->splitdir('d1/d2/d3/')", 'd1,d2,d3,' ],
84 [ "Unix->splitdir('/d1/d2/d3')", ',d1,d2,d3' ],
85 [ "Unix->splitdir('d1/d2/d3')", 'd1,d2,d3' ],
87 [ "Unix->catdir()", '' ],
88 [ "Unix->catdir('/')", '/' ],
89 [ "Unix->catdir('','d1','d2','d3','')", '/d1/d2/d3' ],
90 [ "Unix->catdir('d1','d2','d3','')", 'd1/d2/d3' ],
91 [ "Unix->catdir('','d1','d2','d3')", '/d1/d2/d3' ],
92 [ "Unix->catdir('d1','d2','d3')", 'd1/d2/d3' ],
94 [ "Unix->canonpath('///../../..//./././a//b/.././c/././')", '/a/b/../c' ],
95 [ "Unix->canonpath('')", '' ],
97 [ "Unix->canonpath('a/../../b/c')", 'a/../../b/c' ],
98 [ "Unix->canonpath('/.')", '/' ],
99 [ "Unix->canonpath('/./')", '/' ],
100 [ "Unix->canonpath('/a/./')", '/a' ],
101 [ "Unix->canonpath('/a/.')", '/a' ],
102 [ "Unix->canonpath('/../../')", '/' ],
103 [ "Unix->canonpath('/../..')", '/' ],
105 [ "Unix->abs2rel('/t1/t2/t3','/t1/t2/t3')", '.' ],
106 [ "Unix->abs2rel('/t1/t2/t4','/t1/t2/t3')", '../t4' ],
107 [ "Unix->abs2rel('/t1/t2','/t1/t2/t3')", '..' ],
108 [ "Unix->abs2rel('/t1/t2/t3/t4','/t1/t2/t3')", 't4' ],
109 [ "Unix->abs2rel('/t4/t5/t6','/t1/t2/t3')", '../../../t4/t5/t6' ],
110 #[ "Unix->abs2rel('../t4','/t1/t2/t3')", '../t4' ],
111 [ "Unix->abs2rel('/','/t1/t2/t3')", '../../..' ],
112 [ "Unix->abs2rel('///','/t1/t2/t3')", '../../..' ],
113 [ "Unix->abs2rel('/.','/t1/t2/t3')", '../../..' ],
114 [ "Unix->abs2rel('/./','/t1/t2/t3')", '../../..' ],
115 #[ "Unix->abs2rel('../t4','/t1/t2/t3')", '../t4' ],
117 [ "Unix->rel2abs('t4','/t1/t2/t3')", '/t1/t2/t3/t4' ],
118 [ "Unix->rel2abs('t4/t5','/t1/t2/t3')", '/t1/t2/t3/t4/t5' ],
119 [ "Unix->rel2abs('.','/t1/t2/t3')", '/t1/t2/t3' ],
120 [ "Unix->rel2abs('..','/t1/t2/t3')", '/t1/t2/t3/..' ],
121 [ "Unix->rel2abs('../t4','/t1/t2/t3')", '/t1/t2/t3/../t4' ],
122 [ "Unix->rel2abs('/t1','/t1/t2/t3')", '/t1' ],
124 [ "Win32->case_tolerant()", '1' ],
125 [ "Win32->rootdir()", '\\' ],
127 [ "Win32->splitpath('file')", ',,file' ],
128 [ "Win32->splitpath('\\d1/d2\\d3/')", ',\\d1/d2\\d3/,' ],
129 [ "Win32->splitpath('d1/d2\\d3/')", ',d1/d2\\d3/,' ],
130 [ "Win32->splitpath('\\d1/d2\\d3/.')", ',\\d1/d2\\d3/.,' ],
131 [ "Win32->splitpath('\\d1/d2\\d3/..')", ',\\d1/d2\\d3/..,' ],
132 [ "Win32->splitpath('\\d1/d2\\d3/.file')", ',\\d1/d2\\d3/,.file' ],
133 [ "Win32->splitpath('\\d1/d2\\d3/file')", ',\\d1/d2\\d3/,file' ],
134 [ "Win32->splitpath('d1/d2\\d3/file')", ',d1/d2\\d3/,file' ],
135 [ "Win32->splitpath('C:\\d1/d2\\d3/')", 'C:,\\d1/d2\\d3/,' ],
136 [ "Win32->splitpath('C:d1/d2\\d3/')", 'C:,d1/d2\\d3/,' ],
137 [ "Win32->splitpath('C:\\d1/d2\\d3/file')", 'C:,\\d1/d2\\d3/,file' ],
138 [ "Win32->splitpath('C:d1/d2\\d3/file')", 'C:,d1/d2\\d3/,file' ],
139 [ "Win32->splitpath('C:\\../d2\\d3/file')", 'C:,\\../d2\\d3/,file' ],
140 [ "Win32->splitpath('C:../d2\\d3/file')", 'C:,../d2\\d3/,file' ],
141 [ "Win32->splitpath('\\../..\\d1/')", ',\\../..\\d1/,' ],
142 [ "Win32->splitpath('\\./.\\d1/')", ',\\./.\\d1/,' ],
143 [ "Win32->splitpath('\\\\node\\share\\d1/d2\\d3/')", '\\\\node\\share,\\d1/d2\\d3/,' ],
144 [ "Win32->splitpath('\\\\node\\share\\d1/d2\\d3/file')", '\\\\node\\share,\\d1/d2\\d3/,file' ],
145 [ "Win32->splitpath('\\\\node\\share\\d1/d2\\file')", '\\\\node\\share,\\d1/d2\\,file' ],
146 [ "Win32->splitpath('file',1)", ',file,' ],
147 [ "Win32->splitpath('\\d1/d2\\d3/',1)", ',\\d1/d2\\d3/,' ],
148 [ "Win32->splitpath('d1/d2\\d3/',1)", ',d1/d2\\d3/,' ],
149 [ "Win32->splitpath('\\\\node\\share\\d1/d2\\d3/',1)", '\\\\node\\share,\\d1/d2\\d3/,' ],
151 [ "Win32->catpath('','','file')", 'file' ],
152 [ "Win32->catpath('','\\d1/d2\\d3/','')", '\\d1/d2\\d3/' ],
153 [ "Win32->catpath('','d1/d2\\d3/','')", 'd1/d2\\d3/' ],
154 [ "Win32->catpath('','\\d1/d2\\d3/.','')", '\\d1/d2\\d3/.' ],
155 [ "Win32->catpath('','\\d1/d2\\d3/..','')", '\\d1/d2\\d3/..' ],
156 [ "Win32->catpath('','\\d1/d2\\d3/','.file')", '\\d1/d2\\d3/.file' ],
157 [ "Win32->catpath('','\\d1/d2\\d3/','file')", '\\d1/d2\\d3/file' ],
158 [ "Win32->catpath('','d1/d2\\d3/','file')", 'd1/d2\\d3/file' ],
159 [ "Win32->catpath('C:','\\d1/d2\\d3/','')", 'C:\\d1/d2\\d3/' ],
160 [ "Win32->catpath('C:','d1/d2\\d3/','')", 'C:d1/d2\\d3/' ],
161 [ "Win32->catpath('C:','\\d1/d2\\d3/','file')", 'C:\\d1/d2\\d3/file' ],
162 [ "Win32->catpath('C:','d1/d2\\d3/','file')", 'C:d1/d2\\d3/file' ],
163 [ "Win32->catpath('C:','\\../d2\\d3/','file')", 'C:\\../d2\\d3/file' ],
164 [ "Win32->catpath('C:','../d2\\d3/','file')", 'C:../d2\\d3/file' ],
165 [ "Win32->catpath('','\\../..\\d1/','')", '\\../..\\d1/' ],
166 [ "Win32->catpath('','\\./.\\d1/','')", '\\./.\\d1/' ],
167 [ "Win32->catpath('\\\\node\\share','\\d1/d2\\d3/','')", '\\\\node\\share\\d1/d2\\d3/' ],
168 [ "Win32->catpath('\\\\node\\share','\\d1/d2\\d3/','file')", '\\\\node\\share\\d1/d2\\d3/file' ],
169 [ "Win32->catpath('\\\\node\\share','\\d1/d2\\','file')", '\\\\node\\share\\d1/d2\\file' ],
171 [ "Win32->splitdir('')", '' ],
172 [ "Win32->splitdir('\\d1/d2\\d3/')", ',d1,d2,d3,' ],
173 [ "Win32->splitdir('d1/d2\\d3/')", 'd1,d2,d3,' ],
174 [ "Win32->splitdir('\\d1/d2\\d3')", ',d1,d2,d3' ],
175 [ "Win32->splitdir('d1/d2\\d3')", 'd1,d2,d3' ],
177 [ "Win32->catdir()", '' ],
178 [ "Win32->catdir('')", '\\' ],
179 [ "Win32->catdir('/')", '\\' ],
180 [ "Win32->catdir('/', '../')", '\\' ],
181 [ "Win32->catdir('/', '..\\')", '\\' ],
182 [ "Win32->catdir('\\', '../')", '\\' ],
183 [ "Win32->catdir('\\', '..\\')", '\\' ],
184 [ "Win32->catdir('//d1','d2')", '\\\\d1\\d2' ],
185 [ "Win32->catdir('\\d1\\','d2')", '\\d1\\d2' ],
186 [ "Win32->catdir('\\d1','d2')", '\\d1\\d2' ],
187 [ "Win32->catdir('\\d1','\\d2')", '\\d1\\d2' ],
188 [ "Win32->catdir('\\d1','\\d2\\')", '\\d1\\d2' ],
189 [ "Win32->catdir('','/d1','d2')", '\\\\d1\\d2' ],
190 [ "Win32->catdir('','','/d1','d2')", '\\\\\\d1\\d2' ],
191 [ "Win32->catdir('','//d1','d2')", '\\\\\\d1\\d2' ],
192 [ "Win32->catdir('','','//d1','d2')", '\\\\\\\\d1\\d2' ],
193 [ "Win32->catdir('','d1','','d2','')", '\\d1\\d2' ],
194 [ "Win32->catdir('','d1','d2','d3','')", '\\d1\\d2\\d3' ],
195 [ "Win32->catdir('d1','d2','d3','')", 'd1\\d2\\d3' ],
196 [ "Win32->catdir('','d1','d2','d3')", '\\d1\\d2\\d3' ],
197 [ "Win32->catdir('d1','d2','d3')", 'd1\\d2\\d3' ],
198 [ "Win32->catdir('A:/d1','d2','d3')", 'A:\\d1\\d2\\d3' ],
199 [ "Win32->catdir('A:/d1','d2','d3','')", 'A:\\d1\\d2\\d3' ],
200 #[ "Win32->catdir('A:/d1','B:/d2','d3','')", 'A:\\d1\\d2\\d3' ],
201 [ "Win32->catdir('A:/d1','B:/d2','d3','')", 'A:\\d1\\B:\\d2\\d3' ],
202 [ "Win32->catdir('A:/')", 'A:\\' ],
203 [ "Win32->catdir('\\', 'foo')", '\\foo' ],
205 [ "Win32->catfile('a','b','c')", 'a\\b\\c' ],
206 [ "Win32->catfile('a','b','.\\c')", 'a\\b\\c' ],
207 [ "Win32->catfile('.\\a','b','c')", 'a\\b\\c' ],
208 [ "Win32->catfile('c')", 'c' ],
209 [ "Win32->catfile('.\\c')", 'c' ],
212 [ "Win32->canonpath('')", '' ],
213 [ "Win32->canonpath('a:')", 'A:' ],
214 [ "Win32->canonpath('A:f')", 'A:f' ],
215 [ "Win32->canonpath('A:/')", 'A:\\' ],
217 [ "Win32->canonpath('a\\..\\..\\b\\c')", '..\\b\\c' ],
218 [ "Win32->canonpath('//a\\b//c')", '\\\\a\\b\\c' ],
219 [ "Win32->canonpath('/a/..../c')", '\\a\\....\\c' ],
220 [ "Win32->canonpath('//a/b\\c')", '\\\\a\\b\\c' ],
221 [ "Win32->canonpath('////')", '\\\\\\' ],
222 [ "Win32->canonpath('//')", '\\' ],
223 [ "Win32->canonpath('/.')", '\\.' ],
224 [ "Win32->canonpath('//a/b/../../c')", '\\\\a\\b\\c' ],
225 [ "Win32->canonpath('//a/b/c/../d')", '\\\\a\\b\\d' ],
226 [ "Win32->canonpath('//a/b/c/../../d')",'\\\\a\\b\\d' ],
227 [ "Win32->canonpath('//a/b/c/.../d')", '\\\\a\\b\\d' ],
228 [ "Win32->canonpath('/a/b/c/../../d')", '\\a\\d' ],
229 [ "Win32->canonpath('/a/b/c/.../d')", '\\a\\d' ],
230 [ "Win32->canonpath('\\../temp\\')", '\\temp' ],
231 [ "Win32->canonpath('\\../')", '\\' ],
232 [ "Win32->canonpath('\\..\\')", '\\' ],
233 [ "Win32->canonpath('/../')", '\\' ],
234 [ "Win32->canonpath('/..\\')", '\\' ],
235 [ "Win32->can('_cwd')", '/CODE/' ],
237 # FakeWin32 subclass (see below) just sets CWD to C:\one\two and getdcwd('D') to D:\alpha\beta
239 [ "FakeWin32->abs2rel('/t1/t2/t3','/t1/t2/t3')", '.' ],
240 [ "FakeWin32->abs2rel('/t1/t2/t4','/t1/t2/t3')", '..\\t4' ],
241 [ "FakeWin32->abs2rel('/t1/t2','/t1/t2/t3')", '..' ],
242 [ "FakeWin32->abs2rel('/t1/t2/t3/t4','/t1/t2/t3')", 't4' ],
243 [ "FakeWin32->abs2rel('/t4/t5/t6','/t1/t2/t3')", '..\\..\\..\\t4\\t5\\t6' ],
244 [ "FakeWin32->abs2rel('../t4','/t1/t2/t3')", '..\\..\\..\\one\\t4' ], # Uses _cwd()
245 [ "FakeWin32->abs2rel('/','/t1/t2/t3')", '..\\..\\..' ],
246 [ "FakeWin32->abs2rel('///','/t1/t2/t3')", '..\\..\\..' ],
247 [ "FakeWin32->abs2rel('/.','/t1/t2/t3')", '..\\..\\..' ],
248 [ "FakeWin32->abs2rel('/./','/t1/t2/t3')", '..\\..\\..' ],
249 [ "FakeWin32->abs2rel('\\\\a/t1/t2/t4','/t2/t3')", '\\\\a\\t1\\t2\\t4' ],
250 [ "FakeWin32->abs2rel('//a/t1/t2/t4','/t2/t3')", '\\\\a\\t1\\t2\\t4' ],
251 [ "FakeWin32->abs2rel('A:/t1/t2/t3','A:/t1/t2/t3')", '.' ],
252 [ "FakeWin32->abs2rel('A:/t1/t2/t3/t4','A:/t1/t2/t3')", 't4' ],
253 [ "FakeWin32->abs2rel('A:/t1/t2/t3','A:/t1/t2/t3/t4')", '..' ],
254 [ "FakeWin32->abs2rel('A:/t1/t2/t3','B:/t1/t2/t3')", 'A:\\t1\\t2\\t3' ],
255 [ "FakeWin32->abs2rel('A:/t1/t2/t3/t4','B:/t1/t2/t3')", 'A:\\t1\\t2\\t3\\t4' ],
256 [ "FakeWin32->abs2rel('E:/foo/bar/baz')", 'E:\\foo\\bar\\baz' ],
257 [ "FakeWin32->abs2rel('C:/one/two/three')", 'three' ],
259 [ "FakeWin32->rel2abs('temp','C:/')", 'C:\\temp' ],
260 [ "FakeWin32->rel2abs('temp','C:/a')", 'C:\\a\\temp' ],
261 [ "FakeWin32->rel2abs('temp','C:/a/')", 'C:\\a\\temp' ],
262 [ "FakeWin32->rel2abs('../','C:/')", 'C:\\' ],
263 [ "FakeWin32->rel2abs('../','C:/a')", 'C:\\' ],
264 [ "FakeWin32->rel2abs('temp','//prague_main/work/')", '\\\\prague_main\\work\\temp' ],
265 [ "FakeWin32->rel2abs('../temp','//prague_main/work/')", '\\\\prague_main\\work\\temp' ],
266 [ "FakeWin32->rel2abs('temp','//prague_main/work')", '\\\\prague_main\\work\\temp' ],
267 [ "FakeWin32->rel2abs('../','//prague_main/work')", '\\\\prague_main\\work' ],
269 [ "VMS->case_tolerant()", '1' ],
271 [ "VMS->catfile('a','b','c')", '[.a.b]c' ],
272 [ "VMS->catfile('a','b','[]c')", '[.a.b]c' ],
273 [ "VMS->catfile('[.a]','b','c')", '[.a.b]c' ],
274 [ "VMS->catfile('c')", 'c' ],
275 [ "VMS->catfile('[]c')", 'c' ],
277 [ "VMS->splitpath('file')", ',,file' ],
278 [ "VMS->splitpath('[d1.d2.d3]')", ',[d1.d2.d3],' ],
279 [ "VMS->splitpath('[.d1.d2.d3]')", ',[.d1.d2.d3],' ],
280 [ "VMS->splitpath('[d1.d2.d3]file')", ',[d1.d2.d3],file' ],
281 [ "VMS->splitpath('d1/d2/d3/file')", ',[.d1.d2.d3],file' ],
282 [ "VMS->splitpath('/d1/d2/d3/file')", 'd1:,[d2.d3],file' ],
283 [ "VMS->splitpath('[.d1.d2.d3]file')", ',[.d1.d2.d3],file' ],
284 [ "VMS->splitpath('node::volume:[d1.d2.d3]')", 'node::volume:,[d1.d2.d3],' ],
285 [ "VMS->splitpath('node::volume:[d1.d2.d3]file')", 'node::volume:,[d1.d2.d3],file' ],
286 [ "VMS->splitpath('node\"access_spec\"::volume:[d1.d2.d3]')", 'node"access_spec"::volume:,[d1.d2.d3],' ],
287 [ "VMS->splitpath('node\"access_spec\"::volume:[d1.d2.d3]file')", 'node"access_spec"::volume:,[d1.d2.d3],file' ],
289 [ "VMS->catpath('','','file')", 'file' ],
290 [ "VMS->catpath('','[d1.d2.d3]','')", '[d1.d2.d3]' ],
291 [ "VMS->catpath('','[.d1.d2.d3]','')", '[.d1.d2.d3]' ],
292 [ "VMS->catpath('','[d1.d2.d3]','file')", '[d1.d2.d3]file' ],
293 [ "VMS->catpath('','[.d1.d2.d3]','file')", '[.d1.d2.d3]file' ],
294 [ "VMS->catpath('','d1/d2/d3','file')", '[.d1.d2.d3]file' ],
295 [ "VMS->catpath('v','d1/d2/d3','file')", 'v:[.d1.d2.d3]file' ],
296 [ "VMS->catpath('v','w:[d1.d2.d3]','file')", 'v:[d1.d2.d3]file' ],
297 [ "VMS->catpath('node::volume:','[d1.d2.d3]','')", 'node::volume:[d1.d2.d3]' ],
298 [ "VMS->catpath('node::volume:','[d1.d2.d3]','file')", 'node::volume:[d1.d2.d3]file' ],
299 [ "VMS->catpath('node\"access_spec\"::volume:','[d1.d2.d3]','')", 'node"access_spec"::volume:[d1.d2.d3]' ],
300 [ "VMS->catpath('node\"access_spec\"::volume:','[d1.d2.d3]','file')", 'node"access_spec"::volume:[d1.d2.d3]file' ],
302 [ "VMS->canonpath('')", '' ],
303 [ "VMS->canonpath('volume:[d1]file')", 'volume:[d1]file' ],
304 [ "VMS->canonpath('volume:[d1.-.d2.][d3.d4.-]')", 'volume:[d2.d3]' ],
305 [ "VMS->canonpath('volume:[000000.d1]d2.dir;1')", 'volume:[d1]d2.dir;1' ],
306 [ "VMS->canonpath('volume:[d1.d2.d3]file.txt')", 'volume:[d1.d2.d3]file.txt' ],
307 [ "VMS->canonpath('[d1.d2.d3]file.txt')", '[d1.d2.d3]file.txt' ],
308 [ "VMS->canonpath('volume:[-.d1.d2.d3]file.txt')", 'volume:[-.d1.d2.d3]file.txt' ],
309 [ "VMS->canonpath('[-.d1.d2.d3]file.txt')", '[-.d1.d2.d3]file.txt' ],
310 [ "VMS->canonpath('volume:[--.d1.d2.d3]file.txt')", 'volume:[--.d1.d2.d3]file.txt' ],
311 [ "VMS->canonpath('[--.d1.d2.d3]file.txt')", '[--.d1.d2.d3]file.txt' ],
312 [ "VMS->canonpath('volume:[d1.-.d2.d3]file.txt')", 'volume:[d2.d3]file.txt' ],
313 [ "VMS->canonpath('[d1.-.d2.d3]file.txt')", '[d2.d3]file.txt' ],
314 [ "VMS->canonpath('volume:[d1.--.d2.d3]file.txt')", 'volume:[-.d2.d3]file.txt' ],
315 [ "VMS->canonpath('[d1.--.d2.d3]file.txt')", '[-.d2.d3]file.txt' ],
316 [ "VMS->canonpath('volume:[d1.d2.-.d3]file.txt')", 'volume:[d1.d3]file.txt' ],
317 [ "VMS->canonpath('[d1.d2.-.d3]file.txt')", '[d1.d3]file.txt' ],
318 [ "VMS->canonpath('volume:[d1.d2.--.d3]file.txt')", 'volume:[d3]file.txt' ],
319 [ "VMS->canonpath('[d1.d2.--.d3]file.txt')", '[d3]file.txt' ],
320 [ "VMS->canonpath('volume:[d1.d2.d3.-]file.txt')", 'volume:[d1.d2]file.txt' ],
321 [ "VMS->canonpath('[d1.d2.d3.-]file.txt')", '[d1.d2]file.txt' ],
322 [ "VMS->canonpath('volume:[d1.d2.d3.--]file.txt')", 'volume:[d1]file.txt' ],
323 [ "VMS->canonpath('[d1.d2.d3.--]file.txt')", '[d1]file.txt' ],
324 [ "VMS->canonpath('volume:[d1.000000.][000000.][d3.--]file.txt')", 'volume:[d1]file.txt' ],
325 [ "VMS->canonpath('[d1.000000.][000000.][d3.--]file.txt')", '[d1]file.txt' ],
326 [ "VMS->canonpath('volume:[d1.000000.][000000.][d2.000000]file.txt')", 'volume:[d1.000000.d2.000000]file.txt' ],
327 [ "VMS->canonpath('[d1.000000.][000000.][d2.000000]file.txt')", '[d1.000000.d2.000000]file.txt' ],
328 [ "VMS->canonpath('volume:[d1.000000.][000000.][d3.--.000000]file.txt')",'volume:[d1.000000]file.txt' ],
329 [ "VMS->canonpath('[d1.000000.][000000.][d3.--.000000]file.txt')", '[d1.000000]file.txt' ],
330 [ "VMS->canonpath('volume:[d1.000000.][000000.][-.-.000000]file.txt')", 'volume:[000000]file.txt' ],
331 [ "VMS->canonpath('[d1.000000.][000000.][--.-.000000]file.txt')", '[-.000000]file.txt' ],
332 [ "VMS->canonpath('[d1.d2.--]file')", '[000000]file' ],
334 [ "VMS->splitdir('')", '' ],
335 [ "VMS->splitdir('[]')", '' ],
336 [ "VMS->splitdir('d1.d2.d3')", 'd1,d2,d3' ],
337 [ "VMS->splitdir('[d1.d2.d3]')", 'd1,d2,d3' ],
338 [ "VMS->splitdir('.d1.d2.d3')", ',d1,d2,d3' ],
339 [ "VMS->splitdir('[.d1.d2.d3]')", ',d1,d2,d3' ],
340 [ "VMS->splitdir('.-.d2.d3')", ',-,d2,d3' ],
341 [ "VMS->splitdir('[.-.d2.d3]')", ',-,d2,d3' ],
342 [ "VMS->splitdir('[d1.d2]')", 'd1,d2' ],
343 [ "VMS->splitdir('[d1-.--d2]')", 'd1-,--d2' ],
344 [ "VMS->splitdir('[d1---.-.d2]')", 'd1---,-,d2' ],
345 [ "VMS->splitdir('[d1.---.d2]')", 'd1,-,-,-,d2' ],
346 [ "VMS->splitdir('[d1---d2]')", 'd1---d2' ],
347 [ "VMS->splitdir('[d1.][000000.d2]')", 'd1,d2' ],
349 [ "VMS->catdir('')", '' ],
350 [ "VMS->catdir('d1','d2','d3')", '[.d1.d2.d3]' ],
351 [ "VMS->catdir('d1','d2/','d3')", '[.d1.d2.d3]' ],
352 [ "VMS->catdir('','d1','d2','d3')", '[.d1.d2.d3]' ],
353 [ "VMS->catdir('','-','d2','d3')", '[-.d2.d3]' ],
354 [ "VMS->catdir('','-','','d3')", '[-.d3]' ],
355 [ "VMS->catdir('dir.dir','d2.dir','d3.dir')", '[.dir.d2.d3]' ],
356 [ "VMS->catdir('[.name]')", '[.name]' ],
357 [ "VMS->catdir('[.name]','[.name]')", '[.name.name]'],
359 [ "VMS->abs2rel('node::volume:[t1.t2.t3]','node::volume:[t1.t2.t3]')", '[]' ],
360 [ "VMS->abs2rel('node::volume:[t1.t2.t3]','[t1.t2.t3]')", 'node::volume:[t1.t2.t3]' ],
361 [ "VMS->abs2rel('node::volume:[t1.t2.t4]','node::volume:[t1.t2.t3]')", '[-.t4]' ],
362 [ "VMS->abs2rel('node::volume:[t1.t2.t4]','[t1.t2.t3]')", 'node::volume:[t1.t2.t4]' ],
363 [ "VMS->abs2rel('[t1.t2.t3]','[t1.t2.t3]')", '[]' ],
364 [ "VMS->abs2rel('[t1.t2.t3]file','[t1.t2.t3]')", 'file' ],
365 [ "VMS->abs2rel('[t1.t2.t3]file','[t1.t2]')", '[.t3]file' ],
366 [ "VMS->abs2rel('v:[t1.t2.t3]file','v:[t1.t2]')", '[.t3]file' ],
367 [ "VMS->abs2rel('[t1.t2.t4]','[t1.t2.t3]')", '[-.t4]' ],
368 [ "VMS->abs2rel('[t1.t2]file','[t1.t2.t3]')", '[-]file' ],
369 [ "VMS->abs2rel('[t1.t2.t3.t4]','[t1.t2.t3]')", '[.t4]' ],
370 [ "VMS->abs2rel('[t4.t5.t6]','[t1.t2.t3]')", '[---.t4.t5.t6]' ],
371 [ "VMS->abs2rel('[000000]','[t1.t2.t3]')", '[---]' ],
372 [ "VMS->abs2rel('a:[t1.t2.t4]','a:[t1.t2.t3]')", '[-.t4]' ],
373 [ "VMS->abs2rel('a:[t1.t2.t4]','[t1.t2.t3]')", 'a:[t1.t2.t4]' ],
374 [ "VMS->abs2rel('[a.-.b.c.-]','[t1.t2.t3]')", '[---.b]' ],
376 [ "VMS->rel2abs('[.t4]','[t1.t2.t3]')", '[t1.t2.t3.t4]' ],
377 [ "VMS->rel2abs('[.t4.t5]','[t1.t2.t3]')", '[t1.t2.t3.t4.t5]' ],
378 [ "VMS->rel2abs('[]','[t1.t2.t3]')", '[t1.t2.t3]' ],
379 [ "VMS->rel2abs('[-]','[t1.t2.t3]')", '[t1.t2]' ],
380 [ "VMS->rel2abs('[-.t4]','[t1.t2.t3]')", '[t1.t2.t4]' ],
381 [ "VMS->rel2abs('[t1]','[t1.t2.t3]')", '[t1]' ],
383 [ "OS2->case_tolerant()", '1' ],
385 [ "OS2->catdir('A:/d1','B:/d2','d3','')", 'A:/d1/B:/d2/d3' ],
387 [ "OS2->catfile('a','b','c')", 'a/b/c' ],
388 [ "OS2->catfile('a','b','./c')", 'a/b/c' ],
389 [ "OS2->catfile('./a','b','c')", 'a/b/c' ],
390 [ "OS2->catfile('c')", 'c' ],
391 [ "OS2->catfile('./c')", 'c' ],
393 [ "OS2->catdir('/', '../')", '/' ],
394 [ "OS2->catdir('/', '..\\')", '/' ],
395 [ "OS2->catdir('\\', '../')", '/' ],
396 [ "OS2->catdir('\\', '..\\')", '/' ],
398 [ "Mac->case_tolerant()", '1' ],
400 [ "Mac->catpath('','','')", '' ],
401 [ "Mac->catpath('',':','')", ':' ],
402 [ "Mac->catpath('','::','')", '::' ],
404 [ "Mac->catpath('hd','','')", 'hd:' ],
405 [ "Mac->catpath('hd:','','')", 'hd:' ],
406 [ "Mac->catpath('hd:',':','')", 'hd:' ],
407 [ "Mac->catpath('hd:','::','')", 'hd::' ],
409 [ "Mac->catpath('hd','','file')", 'hd:file' ],
410 [ "Mac->catpath('hd',':','file')", 'hd:file' ],
411 [ "Mac->catpath('hd','::','file')", 'hd::file' ],
412 [ "Mac->catpath('hd',':::','file')", 'hd:::file' ],
414 [ "Mac->catpath('hd:','',':file')", 'hd:file' ],
415 [ "Mac->catpath('hd:',':',':file')", 'hd:file' ],
416 [ "Mac->catpath('hd:','::',':file')", 'hd::file' ],
417 [ "Mac->catpath('hd:',':::',':file')", 'hd:::file' ],
419 [ "Mac->catpath('hd:','d1','file')", 'hd:d1:file' ],
420 [ "Mac->catpath('hd:',':d1:',':file')", 'hd:d1:file' ],
421 [ "Mac->catpath('hd:','hd:d1','')", 'hd:d1:' ],
423 [ "Mac->catpath('','d1','')", ':d1:' ],
424 [ "Mac->catpath('',':d1','')", ':d1:' ],
425 [ "Mac->catpath('',':d1:','')", ':d1:' ],
427 [ "Mac->catpath('','d1','file')", ':d1:file' ],
428 [ "Mac->catpath('',':d1:',':file')", ':d1:file' ],
430 [ "Mac->catpath('','','file')", 'file' ],
431 [ "Mac->catpath('','',':file')", 'file' ], # !
432 [ "Mac->catpath('',':',':file')", ':file' ], # !
435 [ "Mac->splitpath(':')", ',:,' ],
436 [ "Mac->splitpath('::')", ',::,' ],
437 [ "Mac->splitpath(':::')", ',:::,' ],
439 [ "Mac->splitpath('file')", ',,file' ],
440 [ "Mac->splitpath(':file')", ',:,file' ],
442 [ "Mac->splitpath('d1',1)", ',:d1:,' ], # dir, not volume
443 [ "Mac->splitpath(':d1',1)", ',:d1:,' ],
444 [ "Mac->splitpath(':d1:',1)", ',:d1:,' ],
445 [ "Mac->splitpath(':d1:')", ',:d1:,' ],
446 [ "Mac->splitpath(':d1:d2:d3:')", ',:d1:d2:d3:,' ],
447 [ "Mac->splitpath(':d1:d2:d3:',1)", ',:d1:d2:d3:,' ],
448 [ "Mac->splitpath(':d1:file')", ',:d1:,file' ],
449 [ "Mac->splitpath('::d1:file')", ',::d1:,file' ],
451 [ "Mac->splitpath('hd:', 1)", 'hd:,,' ],
452 [ "Mac->splitpath('hd:')", 'hd:,,' ],
453 [ "Mac->splitpath('hd:d1:d2:')", 'hd:,:d1:d2:,' ],
454 [ "Mac->splitpath('hd:d1:d2',1)", 'hd:,:d1:d2:,' ],
455 [ "Mac->splitpath('hd:d1:d2:file')", 'hd:,:d1:d2:,file' ],
456 [ "Mac->splitpath('hd:d1:d2::file')", 'hd:,:d1:d2::,file' ],
457 [ "Mac->splitpath('hd::d1:d2:file')", 'hd:,::d1:d2:,file' ], # invalid path
458 [ "Mac->splitpath('hd:file')", 'hd:,,file' ],
460 [ "Mac->splitdir()", '' ],
461 [ "Mac->splitdir('')", '' ],
462 [ "Mac->splitdir(':')", ':' ],
463 [ "Mac->splitdir('::')", '::' ],
464 [ "Mac->splitdir(':::')", '::,::' ],
465 [ "Mac->splitdir(':::d1:d2')", '::,::,d1,d2' ],
467 [ "Mac->splitdir(':d1:d2:d3::')", 'd1,d2,d3,::'],
468 [ "Mac->splitdir(':d1:d2:d3:')", 'd1,d2,d3' ],
469 [ "Mac->splitdir(':d1:d2:d3')", 'd1,d2,d3' ],
471 # absolute paths in splitdir() work, but you'd better use splitpath()
472 [ "Mac->splitdir('hd:')", 'hd:' ],
473 [ "Mac->splitdir('hd::')", 'hd:,::' ], # invalid path, but it works
474 [ "Mac->splitdir('hd::d1:')", 'hd:,::,d1' ], # invalid path, but it works
475 [ "Mac->splitdir('hd:d1:d2:::')", 'hd:,d1,d2,::,::' ],
476 [ "Mac->splitdir('hd:d1:d2::')", 'hd:,d1,d2,::' ],
477 [ "Mac->splitdir('hd:d1:d2:')", 'hd:,d1,d2' ],
478 [ "Mac->splitdir('hd:d1:d2')", 'hd:,d1,d2' ],
479 [ "Mac->splitdir('hd:d1::d2::')", 'hd:,d1,::,d2,::' ],
481 [ "Mac->catdir()", '' ],
482 [ "Mac->catdir('')", $root, 'MacOS' ], # skipped on other OS
483 [ "Mac->catdir(':')", ':' ],
485 [ "Mac->catdir('', '')", $root, 'MacOS' ], # skipped on other OS
486 [ "Mac->catdir('', ':')", $root, 'MacOS' ], # skipped on other OS
487 [ "Mac->catdir(':', ':')", ':' ],
488 [ "Mac->catdir(':', '')", ':' ],
490 [ "Mac->catdir('', '::')", $root, 'MacOS' ], # skipped on other OS
491 [ "Mac->catdir(':', '::')", '::' ],
493 [ "Mac->catdir('::', '')", '::' ],
494 [ "Mac->catdir('::', ':')", '::' ],
496 [ "Mac->catdir('::', '::')", ':::' ],
498 [ "Mac->catdir(':d1')", ':d1:' ],
499 [ "Mac->catdir(':d1:')", ':d1:' ],
500 [ "Mac->catdir(':d1','d2')", ':d1:d2:' ],
501 [ "Mac->catdir(':d1',':d2')", ':d1:d2:' ],
502 [ "Mac->catdir(':d1',':d2:')", ':d1:d2:' ],
503 [ "Mac->catdir(':d1',':d2::')", ':d1:d2::' ],
504 [ "Mac->catdir(':',':d1',':d2')", ':d1:d2:' ],
505 [ "Mac->catdir('::',':d1',':d2')", '::d1:d2:' ],
506 [ "Mac->catdir('::','::',':d1',':d2')", ':::d1:d2:' ],
507 [ "Mac->catdir(':',':',':d1',':d2')", ':d1:d2:' ],
508 [ "Mac->catdir('::',':',':d1',':d2')", '::d1:d2:' ],
510 [ "Mac->catdir('d1')", ':d1:' ],
511 [ "Mac->catdir('d1','d2','d3')", ':d1:d2:d3:' ],
512 [ "Mac->catdir('d1','d2/','d3')", ':d1:d2/:d3:' ],
513 [ "Mac->catdir('d1','',':d2')", ':d1:d2:' ],
514 [ "Mac->catdir('d1',':',':d2')", ':d1:d2:' ],
515 [ "Mac->catdir('d1','::',':d2')", ':d1::d2:' ],
516 [ "Mac->catdir('d1',':::',':d2')", ':d1:::d2:' ],
517 [ "Mac->catdir('d1','::','::',':d2')", ':d1:::d2:' ],
518 [ "Mac->catdir('d1','d2')", ':d1:d2:' ],
519 [ "Mac->catdir('d1','d2', '')", ':d1:d2:' ],
520 [ "Mac->catdir('d1','d2', ':')", ':d1:d2:' ],
521 [ "Mac->catdir('d1','d2', '::')", ':d1:d2::' ],
522 [ "Mac->catdir('d1','d2','','')", ':d1:d2:' ],
523 [ "Mac->catdir('d1','d2',':','::')", ':d1:d2::' ],
524 [ "Mac->catdir('d1','d2','::','::')", ':d1:d2:::' ],
525 [ "Mac->catdir('d1',':d2')", ':d1:d2:' ],
526 [ "Mac->catdir('d1',':d2:')", ':d1:d2:' ],
528 [ "Mac->catdir('','d1','d2','d3')", $root . 'd1:d2:d3:', 'MacOS' ], # skipped on other OS
529 [ "Mac->catdir('',':','d1','d2')", $root . 'd1:d2:' , 'MacOS' ], # skipped on other OS
530 [ "Mac->catdir('','::','d1','d2')", $root . 'd1:d2:' , 'MacOS' ], # skipped on other OS
531 [ "Mac->catdir('',':','','d1')", $root . 'd1:' , 'MacOS' ], # skipped on other OS
532 [ "Mac->catdir('', ':d1',':d2')", $root . 'd1:d2:' , 'MacOS' ], # skipped on other OS
533 [ "Mac->catdir('','',':d1',':d2')", $root . 'd1:d2:' , 'MacOS' ], # skipped on other OS
535 [ "Mac->catdir('hd:',':d1')", 'hd:d1:' ],
536 [ "Mac->catdir('hd:d1:',':d2')", 'hd:d1:d2:' ],
537 [ "Mac->catdir('hd:','d1')", 'hd:d1:' ],
538 [ "Mac->catdir('hd:d1:',':d2')", 'hd:d1:d2:' ],
539 [ "Mac->catdir('hd:d1:',':d2:')", 'hd:d1:d2:' ],
541 [ "Mac->catfile()", '' ],
542 [ "Mac->catfile('')", '' ],
543 [ "Mac->catfile('', '')", $root , 'MacOS' ], # skipped on other OS
544 [ "Mac->catfile('', 'file')", $root . 'file', 'MacOS' ], # skipped on other OS
545 [ "Mac->catfile(':')", ':' ],
546 [ "Mac->catfile(':', '')", ':' ],
548 [ "Mac->catfile('d1','d2','file')", ':d1:d2:file' ],
549 [ "Mac->catfile('d1','d2',':file')", ':d1:d2:file' ],
550 [ "Mac->catfile('file')", 'file' ],
551 [ "Mac->catfile(':', 'file')", ':file' ],
553 [ "Mac->canonpath('')", '' ],
554 [ "Mac->canonpath(':')", ':' ],
555 [ "Mac->canonpath('::')", '::' ],
556 [ "Mac->canonpath('a::')", 'a::' ],
557 [ "Mac->canonpath(':a::')", ':a::' ],
559 [ "Mac->abs2rel('hd:d1:d2:','hd:d1:d2:')", ':' ],
560 [ "Mac->abs2rel('hd:d1:d2:','hd:d1:d2:file')", ':' ], # ignore base's file portion
561 [ "Mac->abs2rel('hd:d1:d2:file','hd:d1:d2:')", ':file' ],
562 [ "Mac->abs2rel('hd:d1:','hd:d1:d2:')", '::' ],
563 [ "Mac->abs2rel('hd:d3:','hd:d1:d2:')", ':::d3:' ],
564 [ "Mac->abs2rel('hd:d3:','hd:d1:d2::')", '::d3:' ],
565 [ "Mac->abs2rel('hd:d1:d4:d5:','hd:d1::d2:d3::')", '::d1:d4:d5:' ],
566 [ "Mac->abs2rel('hd:d1:d4:d5:','hd:d1::d2:d3:')", ':::d1:d4:d5:' ], # first, resolve updirs in base
567 [ "Mac->abs2rel('hd:d1:d3:','hd:d1:d2:')", '::d3:' ],
568 [ "Mac->abs2rel('hd:d1::d3:','hd:d1:d2:')", ':::d3:' ],
569 [ "Mac->abs2rel('hd:d3:','hd:d1:d2:')", ':::d3:' ], # same as above
570 [ "Mac->abs2rel('hd:d1:d2:d3:','hd:d1:d2:')", ':d3:' ],
571 [ "Mac->abs2rel('hd:d1:d2:d3::','hd:d1:d2:')", ':d3::' ],
572 [ "Mac->abs2rel('hd1:d3:d4:d5:','hd2:d1:d2:')", 'hd1:d3:d4:d5:'], # volume mismatch
573 [ "Mac->abs2rel('hd:','hd:d1:d2:')", ':::' ],
575 [ "Mac->rel2abs(':d3:','hd:d1:d2:')", 'hd:d1:d2:d3:' ],
576 [ "Mac->rel2abs(':d3:d4:','hd:d1:d2:')", 'hd:d1:d2:d3:d4:' ],
577 [ "Mac->rel2abs('','hd:d1:d2:')", '' ],
578 [ "Mac->rel2abs('::','hd:d1:d2:')", 'hd:d1:d2::' ],
579 [ "Mac->rel2abs('::','hd:d1:d2:file')", 'hd:d1:d2::' ],# ignore base's file portion
580 [ "Mac->rel2abs(':file','hd:d1:d2:')", 'hd:d1:d2:file' ],
581 [ "Mac->rel2abs('::file','hd:d1:d2:')", 'hd:d1:d2::file' ],
582 [ "Mac->rel2abs('::d3:','hd:d1:d2:')", 'hd:d1:d2::d3:' ],
583 [ "Mac->rel2abs('hd:','hd:d1:d2:')", 'hd:' ], # path already absolute
584 [ "Mac->rel2abs('hd:d3:file','hd:d1:d2:')", 'hd:d3:file' ],
585 [ "Mac->rel2abs('hd:d3:','hd:d1:file')", 'hd:d3:' ],
587 [ "Epoc->case_tolerant()", '1' ],
589 [ "Epoc->canonpath('')", '' ],
590 [ "Epoc->canonpath('///../../..//./././a//b/.././c/././')", '/a/b/../c' ],
591 [ "Epoc->canonpath('/./')", '/' ],
592 [ "Epoc->canonpath('/a/./')", '/a' ],
594 # XXX Todo, copied from Unix, but fail. Should they? 2003-07-07 Tels
595 #[ "Epoc->canonpath('/a/.')", '/a' ],
596 #[ "Epoc->canonpath('/.')", '/' ],
598 [ "Cygwin->case_tolerant()", '0' ],
602 if ($^O eq 'MSWin32') {
603 push @tests, [ "FakeWin32->rel2abs('D:foo.txt')", 'D:\\alpha\\beta\\foo.txt' ];
607 plan tests => scalar @tests;
610 package File::Spec::FakeWin32;
612 @ISA = qw(File::Spec::Win32);
614 sub _cwd { 'C:\\one\\two' }
616 # Some funky stuff to override Cwd::getdcwd() for testing purposes,
617 # in the limited scope of the rel2abs() method.
618 if ($Cwd::VERSION && $Cwd::VERSION gt '2.17') { # Avoid a 'used only once' warning
623 local *Cwd::getdcwd = sub {
624 return 'D:\alpha\beta' if $_[0] eq 'D:';
625 return 'C:\one\two' if $_[0] eq 'C:';
628 *Cwd::getdcwd = *Cwd::getdcwd; # Avoid a 'used only once' warning
629 return $self->SUPER::rel2abs(@_);
631 *rel2abs = *rel2abs; # Avoid a 'used only once' warning
636 # Test out the class methods
643 # Tries a named function with the given args and compares the result against
644 # an expected result. Works with functions that return scalars or arrays.
647 my $function = shift ;
648 my $expected = shift ;
649 my $platform = shift ;
651 if ($platform && $^O ne $platform) {
652 skip("skip $function", 1);
656 $function =~ s#\\#\\\\#g ;
657 $function =~ s/^([^\$].*->)/File::Spec::$1/;
658 my $got = join ',', eval $function;
661 if ( $@ =~ /^\Q$skip_exception/ ) {
662 skip "skip $function: $skip_exception", 1;
665 ok $@, '', $function;
670 ok $got, $expected, $function;