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 ;
12 require VMS::Filespec ;
15 my $skip_exception = "Install VMS::Filespec (from vms/ext)" ;
18 # Not pretty, but it allows testing of things not implemented soley
19 # on VMS. It might be better to change File::Spec::VMS to do this,
20 # making it more usable when running on (say) Unix but working with
23 sub File::Spec::VMS::vmsify { die "$skip_exception" }
24 sub File::Spec::VMS::unixify { die "$skip_exception" }
25 sub File::Spec::VMS::vmspath { die "$skip_exception" }
27 $INC{"VMS/Filespec.pm"} = 1 ;
29 require File::Spec::VMS ;
31 require File::Spec::OS2 ;
32 require File::Spec::Mac ;
33 require File::Spec::Epoc ;
34 require File::Spec::Cygwin ;
36 # $root is only needed by Mac OS tests; these particular
37 # tests are skipped on other OSs
40 $root = File::Spec::Mac->rootdir();
43 # Each element in this array is a single test. Storing them this way makes
44 # maintenance easy, and should be OK since perl should be pretty functional
45 # before these tests are run.
48 # [ Function , Expected , Platform ]
50 [ "Unix->case_tolerant()", '0' ],
52 [ "Unix->catfile('a','b','c')", 'a/b/c' ],
53 [ "Unix->catfile('a','b','./c')", 'a/b/c' ],
54 [ "Unix->catfile('./a','b','c')", 'a/b/c' ],
55 [ "Unix->catfile('c')", 'c' ],
56 [ "Unix->catfile('./c')", 'c' ],
58 [ "Unix->splitpath('file')", ',,file' ],
59 [ "Unix->splitpath('/d1/d2/d3/')", ',/d1/d2/d3/,' ],
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/.file')", ',/d1/d2/d3/,.file' ],
64 [ "Unix->splitpath('d1/d2/d3/file')", ',d1/d2/d3/,file' ],
65 [ "Unix->splitpath('/../../d1/')", ',/../../d1/,' ],
66 [ "Unix->splitpath('/././d1/')", ',/././d1/,' ],
68 [ "Unix->catpath('','','file')", 'file' ],
69 [ "Unix->catpath('','/d1/d2/d3/','')", '/d1/d2/d3/' ],
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/','.file')", '/d1/d2/d3/.file' ],
74 [ "Unix->catpath('','d1/d2/d3/','file')", 'd1/d2/d3/file' ],
75 [ "Unix->catpath('','/../../d1/','')", '/../../d1/' ],
76 [ "Unix->catpath('','/././d1/','')", '/././d1/' ],
77 [ "Unix->catpath('d1','d2/d3/','')", 'd2/d3/' ],
78 [ "Unix->catpath('d1','d2','d3/')", 'd2/d3/' ],
80 [ "Unix->splitdir('')", '' ],
81 [ "Unix->splitdir('/d1/d2/d3/')", ',d1,d2,d3,' ],
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' ],
86 [ "Unix->catdir()", '' ],
87 [ "Unix->catdir('/')", '/' ],
88 [ "Unix->catdir('','d1','d2','d3','')", '/d1/d2/d3' ],
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' ],
93 [ "Unix->canonpath('')", '' ],
94 [ "Unix->canonpath('///../../..//./././a//b/.././c/././')", '/a/b/../c' ],
95 [ "Unix->canonpath('/.')", '/' ],
96 [ "Unix->canonpath('/./')", '/' ],
97 [ "Unix->canonpath('/a/./')", '/a' ],
98 [ "Unix->canonpath('/a/.')", '/a' ],
100 [ "Unix->abs2rel('/t1/t2/t3','/t1/t2/t3')", '' ],
101 [ "Unix->abs2rel('/t1/t2/t4','/t1/t2/t3')", '../t4' ],
102 [ "Unix->abs2rel('/t1/t2','/t1/t2/t3')", '..' ],
103 [ "Unix->abs2rel('/t1/t2/t3/t4','/t1/t2/t3')", 't4' ],
104 [ "Unix->abs2rel('/t4/t5/t6','/t1/t2/t3')", '../../../t4/t5/t6' ],
105 #[ "Unix->abs2rel('../t4','/t1/t2/t3')", '../t4' ],
106 [ "Unix->abs2rel('/','/t1/t2/t3')", '../../..' ],
107 [ "Unix->abs2rel('///','/t1/t2/t3')", '../../..' ],
108 [ "Unix->abs2rel('/.','/t1/t2/t3')", '../../..' ],
109 [ "Unix->abs2rel('/./','/t1/t2/t3')", '../../..' ],
110 #[ "Unix->abs2rel('../t4','/t1/t2/t3')", '../t4' ],
112 [ "Unix->rel2abs('t4','/t1/t2/t3')", '/t1/t2/t3/t4' ],
113 [ "Unix->rel2abs('t4/t5','/t1/t2/t3')", '/t1/t2/t3/t4/t5' ],
114 [ "Unix->rel2abs('.','/t1/t2/t3')", '/t1/t2/t3' ],
115 [ "Unix->rel2abs('..','/t1/t2/t3')", '/t1/t2/t3/..' ],
116 [ "Unix->rel2abs('../t4','/t1/t2/t3')", '/t1/t2/t3/../t4' ],
117 [ "Unix->rel2abs('/t1','/t1/t2/t3')", '/t1' ],
119 [ "Win32->case_tolerant()", '1' ],
121 [ "Win32->splitpath('file')", ',,file' ],
122 [ "Win32->splitpath('\\d1/d2\\d3/')", ',\\d1/d2\\d3/,' ],
123 [ "Win32->splitpath('d1/d2\\d3/')", ',d1/d2\\d3/,' ],
124 [ "Win32->splitpath('\\d1/d2\\d3/.')", ',\\d1/d2\\d3/.,' ],
125 [ "Win32->splitpath('\\d1/d2\\d3/..')", ',\\d1/d2\\d3/..,' ],
126 [ "Win32->splitpath('\\d1/d2\\d3/.file')", ',\\d1/d2\\d3/,.file' ],
127 [ "Win32->splitpath('\\d1/d2\\d3/file')", ',\\d1/d2\\d3/,file' ],
128 [ "Win32->splitpath('d1/d2\\d3/file')", ',d1/d2\\d3/,file' ],
129 [ "Win32->splitpath('C:\\d1/d2\\d3/')", 'C:,\\d1/d2\\d3/,' ],
130 [ "Win32->splitpath('C:d1/d2\\d3/')", 'C:,d1/d2\\d3/,' ],
131 [ "Win32->splitpath('C:\\d1/d2\\d3/file')", 'C:,\\d1/d2\\d3/,file' ],
132 [ "Win32->splitpath('C:d1/d2\\d3/file')", 'C:,d1/d2\\d3/,file' ],
133 [ "Win32->splitpath('C:\\../d2\\d3/file')", 'C:,\\../d2\\d3/,file' ],
134 [ "Win32->splitpath('C:../d2\\d3/file')", 'C:,../d2\\d3/,file' ],
135 [ "Win32->splitpath('\\../..\\d1/')", ',\\../..\\d1/,' ],
136 [ "Win32->splitpath('\\./.\\d1/')", ',\\./.\\d1/,' ],
137 [ "Win32->splitpath('\\\\node\\share\\d1/d2\\d3/')", '\\\\node\\share,\\d1/d2\\d3/,' ],
138 [ "Win32->splitpath('\\\\node\\share\\d1/d2\\d3/file')", '\\\\node\\share,\\d1/d2\\d3/,file' ],
139 [ "Win32->splitpath('\\\\node\\share\\d1/d2\\file')", '\\\\node\\share,\\d1/d2\\,file' ],
140 [ "Win32->splitpath('file',1)", ',file,' ],
141 [ "Win32->splitpath('\\d1/d2\\d3/',1)", ',\\d1/d2\\d3/,' ],
142 [ "Win32->splitpath('d1/d2\\d3/',1)", ',d1/d2\\d3/,' ],
143 [ "Win32->splitpath('\\\\node\\share\\d1/d2\\d3/',1)", '\\\\node\\share,\\d1/d2\\d3/,' ],
145 [ "Win32->catpath('','','file')", 'file' ],
146 [ "Win32->catpath('','\\d1/d2\\d3/','')", '\\d1/d2\\d3/' ],
147 [ "Win32->catpath('','d1/d2\\d3/','')", 'd1/d2\\d3/' ],
148 [ "Win32->catpath('','\\d1/d2\\d3/.','')", '\\d1/d2\\d3/.' ],
149 [ "Win32->catpath('','\\d1/d2\\d3/..','')", '\\d1/d2\\d3/..' ],
150 [ "Win32->catpath('','\\d1/d2\\d3/','.file')", '\\d1/d2\\d3/.file' ],
151 [ "Win32->catpath('','\\d1/d2\\d3/','file')", '\\d1/d2\\d3/file' ],
152 [ "Win32->catpath('','d1/d2\\d3/','file')", 'd1/d2\\d3/file' ],
153 [ "Win32->catpath('C:','\\d1/d2\\d3/','')", 'C:\\d1/d2\\d3/' ],
154 [ "Win32->catpath('C:','d1/d2\\d3/','')", 'C:d1/d2\\d3/' ],
155 [ "Win32->catpath('C:','\\d1/d2\\d3/','file')", 'C:\\d1/d2\\d3/file' ],
156 [ "Win32->catpath('C:','d1/d2\\d3/','file')", 'C:d1/d2\\d3/file' ],
157 [ "Win32->catpath('C:','\\../d2\\d3/','file')", 'C:\\../d2\\d3/file' ],
158 [ "Win32->catpath('C:','../d2\\d3/','file')", 'C:../d2\\d3/file' ],
159 [ "Win32->catpath('','\\../..\\d1/','')", '\\../..\\d1/' ],
160 [ "Win32->catpath('','\\./.\\d1/','')", '\\./.\\d1/' ],
161 [ "Win32->catpath('\\\\node\\share','\\d1/d2\\d3/','')", '\\\\node\\share\\d1/d2\\d3/' ],
162 [ "Win32->catpath('\\\\node\\share','\\d1/d2\\d3/','file')", '\\\\node\\share\\d1/d2\\d3/file' ],
163 [ "Win32->catpath('\\\\node\\share','\\d1/d2\\','file')", '\\\\node\\share\\d1/d2\\file' ],
165 [ "Win32->splitdir('')", '' ],
166 [ "Win32->splitdir('\\d1/d2\\d3/')", ',d1,d2,d3,' ],
167 [ "Win32->splitdir('d1/d2\\d3/')", 'd1,d2,d3,' ],
168 [ "Win32->splitdir('\\d1/d2\\d3')", ',d1,d2,d3' ],
169 [ "Win32->splitdir('d1/d2\\d3')", 'd1,d2,d3' ],
171 [ "Win32->catdir()", '' ],
172 [ "Win32->catdir('')", '\\' ],
173 [ "Win32->catdir('/')", '\\' ],
174 [ "Win32->catdir('//d1','d2')", '\\\\d1\\d2' ],
175 [ "Win32->catdir('\\d1\\','d2')", '\\d1\\d2' ],
176 [ "Win32->catdir('\\d1','d2')", '\\d1\\d2' ],
177 [ "Win32->catdir('\\d1','\\d2')", '\\d1\\d2' ],
178 [ "Win32->catdir('\\d1','\\d2\\')", '\\d1\\d2' ],
179 [ "Win32->catdir('','/d1','d2')", '\\\\d1\\d2' ],
180 [ "Win32->catdir('','','/d1','d2')", '\\\\\\d1\\d2' ],
181 [ "Win32->catdir('','//d1','d2')", '\\\\\\d1\\d2' ],
182 [ "Win32->catdir('','','//d1','d2')", '\\\\\\\\d1\\d2' ],
183 [ "Win32->catdir('','d1','','d2','')", '\\d1\\d2' ],
184 [ "Win32->catdir('','d1','d2','d3','')", '\\d1\\d2\\d3' ],
185 [ "Win32->catdir('d1','d2','d3','')", 'd1\\d2\\d3' ],
186 [ "Win32->catdir('','d1','d2','d3')", '\\d1\\d2\\d3' ],
187 [ "Win32->catdir('d1','d2','d3')", 'd1\\d2\\d3' ],
188 [ "Win32->catdir('A:/d1','d2','d3')", 'A:\\d1\\d2\\d3' ],
189 [ "Win32->catdir('A:/d1','d2','d3','')", 'A:\\d1\\d2\\d3' ],
190 #[ "Win32->catdir('A:/d1','B:/d2','d3','')", 'A:\\d1\\d2\\d3' ],
191 [ "Win32->catdir('A:/d1','B:/d2','d3','')", 'A:\\d1\\B:\\d2\\d3' ],
192 [ "Win32->catdir('A:/')", 'A:\\' ],
194 [ "Win32->catfile('a','b','c')", 'a\\b\\c' ],
195 [ "Win32->catfile('a','b','.\\c')", 'a\\b\\c' ],
196 [ "Win32->catfile('.\\a','b','c')", 'a\\b\\c' ],
197 [ "Win32->catfile('c')", 'c' ],
198 [ "Win32->catfile('.\\c')", 'c' ],
201 [ "Win32->canonpath('')", '' ],
202 [ "Win32->canonpath('a:')", 'A:' ],
203 [ "Win32->canonpath('A:f')", 'A:f' ],
204 [ "Win32->canonpath('//a\\b//c')", '\\\\a\\b\\c' ],
205 [ "Win32->canonpath('/a/..../c')", '\\a\\....\\c' ],
206 [ "Win32->canonpath('//a/b\\c')", '\\\\a\\b\\c' ],
207 [ "Win32->canonpath('////')", '\\\\\\' ],
208 [ "Win32->canonpath('//')", '\\' ],
209 [ "Win32->canonpath('/.')", '\\.' ],
210 [ "Win32->canonpath('//a/b/../../c')", '\\\\a\\b\\c' ],
211 [ "Win32->canonpath('//a/b/c/../d')", '\\\\a\\b\\d' ],
212 [ "Win32->canonpath('//a/b/c/../../d')",'\\\\a\\b\\d' ],
213 [ "Win32->canonpath('//a/b/c/.../d')", '\\\\a\\b\\d' ],
214 [ "Win32->canonpath('/a/b/c/../../d')", '\\a\\d' ],
215 [ "Win32->canonpath('/a/b/c/.../d')", '\\a\\d' ],
216 [ "Win32->canonpath('\\../temp\\')", '\\temp' ],
218 # FakeWin32 subclass (see below) just sets CWD to C:\one\two
220 [ "FakeWin32->abs2rel('/t1/t2/t3','/t1/t2/t3')", '' ],
221 [ "FakeWin32->abs2rel('/t1/t2/t4','/t1/t2/t3')", '..\\t4' ],
222 [ "FakeWin32->abs2rel('/t1/t2','/t1/t2/t3')", '..' ],
223 [ "FakeWin32->abs2rel('/t1/t2/t3/t4','/t1/t2/t3')", 't4' ],
224 [ "FakeWin32->abs2rel('/t4/t5/t6','/t1/t2/t3')", '..\\..\\..\\t4\\t5\\t6' ],
225 [ "FakeWin32->abs2rel('../t4','/t1/t2/t3')", '..\\..\\..\\one\\t4' ],
226 [ "FakeWin32->abs2rel('/','/t1/t2/t3')", '..\\..\\..' ],
227 [ "FakeWin32->abs2rel('///','/t1/t2/t3')", '..\\..\\..' ],
228 [ "FakeWin32->abs2rel('/.','/t1/t2/t3')", '..\\..\\..' ],
229 [ "FakeWin32->abs2rel('/./','/t1/t2/t3')", '..\\..\\..' ],
230 [ "FakeWin32->abs2rel('\\\\a/t1/t2/t4','/t2/t3')", '\\\\a\\t1\\t2\\t4' ],
231 [ "FakeWin32->abs2rel('//a/t1/t2/t4','/t2/t3')", '\\\\a\\t1\\t2\\t4' ],
232 [ "FakeWin32->abs2rel('A:/t1/t2/t3','A:/t1/t2/t3')", '' ],
233 [ "FakeWin32->abs2rel('A:/t1/t2/t3/t4','A:/t1/t2/t3')", 't4' ],
234 [ "FakeWin32->abs2rel('A:/t1/t2/t3','A:/t1/t2/t3/t4')", '..' ],
235 [ "FakeWin32->abs2rel('A:/t1/t2/t3','B:/t1/t2/t3')", 'A:\\t1\\t2\\t3' ],
236 [ "FakeWin32->abs2rel('A:/t1/t2/t3/t4','B:/t1/t2/t3')", 'A:\\t1\\t2\\t3\\t4' ],
237 [ "FakeWin32->abs2rel('E:/foo/bar/baz')", 'E:\\foo\\bar\\baz' ],
238 [ "FakeWin32->abs2rel('C:/one/two/three')", 'three' ],
240 [ "FakeWin32->rel2abs('temp','C:/')", 'C:\\temp' ],
241 [ "FakeWin32->rel2abs('temp','C:/a')", 'C:\\a\\temp' ],
242 [ "FakeWin32->rel2abs('temp','C:/a/')", 'C:\\a\\temp' ],
243 [ "FakeWin32->rel2abs('../','C:/')", 'C:\\' ],
244 [ "FakeWin32->rel2abs('../','C:/a')", 'C:\\' ],
245 [ "FakeWin32->rel2abs('temp','//prague_main/work/')", '\\\\prague_main\\work\\temp' ],
246 [ "FakeWin32->rel2abs('../temp','//prague_main/work/')", '\\\\prague_main\\work\\temp' ],
247 [ "FakeWin32->rel2abs('temp','//prague_main/work')", '\\\\prague_main\\work\\temp' ],
248 [ "FakeWin32->rel2abs('../','//prague_main/work')", '\\\\prague_main\\work' ],
250 [ "VMS->case_tolerant()", '1' ],
252 [ "VMS->catfile('a','b','c')", '[.a.b]c' ],
253 [ "VMS->catfile('a','b','[]c')", '[.a.b]c' ],
254 [ "VMS->catfile('[.a]','b','c')", '[.a.b]c' ],
255 [ "VMS->catfile('c')", 'c' ],
256 [ "VMS->catfile('[]c')", 'c' ],
258 [ "VMS->splitpath('file')", ',,file' ],
259 [ "VMS->splitpath('[d1.d2.d3]')", ',[d1.d2.d3],' ],
260 [ "VMS->splitpath('[.d1.d2.d3]')", ',[.d1.d2.d3],' ],
261 [ "VMS->splitpath('[d1.d2.d3]file')", ',[d1.d2.d3],file' ],
262 [ "VMS->splitpath('d1/d2/d3/file')", ',[.d1.d2.d3],file' ],
263 [ "VMS->splitpath('/d1/d2/d3/file')", 'd1:,[d2.d3],file' ],
264 [ "VMS->splitpath('[.d1.d2.d3]file')", ',[.d1.d2.d3],file' ],
265 [ "VMS->splitpath('node::volume:[d1.d2.d3]')", 'node::volume:,[d1.d2.d3],' ],
266 [ "VMS->splitpath('node::volume:[d1.d2.d3]file')", 'node::volume:,[d1.d2.d3],file' ],
267 [ "VMS->splitpath('node\"access_spec\"::volume:[d1.d2.d3]')", 'node"access_spec"::volume:,[d1.d2.d3],' ],
268 [ "VMS->splitpath('node\"access_spec\"::volume:[d1.d2.d3]file')", 'node"access_spec"::volume:,[d1.d2.d3],file' ],
270 [ "VMS->catpath('','','file')", 'file' ],
271 [ "VMS->catpath('','[d1.d2.d3]','')", '[d1.d2.d3]' ],
272 [ "VMS->catpath('','[.d1.d2.d3]','')", '[.d1.d2.d3]' ],
273 [ "VMS->catpath('','[d1.d2.d3]','file')", '[d1.d2.d3]file' ],
274 [ "VMS->catpath('','[.d1.d2.d3]','file')", '[.d1.d2.d3]file' ],
275 [ "VMS->catpath('','d1/d2/d3','file')", '[.d1.d2.d3]file' ],
276 [ "VMS->catpath('v','d1/d2/d3','file')", 'v:[.d1.d2.d3]file' ],
277 [ "VMS->catpath('node::volume:','[d1.d2.d3]','')", 'node::volume:[d1.d2.d3]' ],
278 [ "VMS->catpath('node::volume:','[d1.d2.d3]','file')", 'node::volume:[d1.d2.d3]file' ],
279 [ "VMS->catpath('node\"access_spec\"::volume:','[d1.d2.d3]','')", 'node"access_spec"::volume:[d1.d2.d3]' ],
280 [ "VMS->catpath('node\"access_spec\"::volume:','[d1.d2.d3]','file')", 'node"access_spec"::volume:[d1.d2.d3]file' ],
282 [ "VMS->canonpath('')", '' ],
283 [ "VMS->canonpath('volume:[d1]file')", 'volume:[d1]file' ],
284 [ "VMS->canonpath('volume:[d1.-.d2.][d3.d4.-]')", 'volume:[d2.d3]' ],
285 [ "VMS->canonpath('volume:[000000.d1]d2.dir;1')", 'volume:[d1]d2.dir;1' ],
287 [ "VMS->splitdir('')", '' ],
288 [ "VMS->splitdir('[]')", '' ],
289 [ "VMS->splitdir('d1.d2.d3')", 'd1,d2,d3' ],
290 [ "VMS->splitdir('[d1.d2.d3]')", 'd1,d2,d3' ],
291 [ "VMS->splitdir('.d1.d2.d3')", ',d1,d2,d3' ],
292 [ "VMS->splitdir('[.d1.d2.d3]')", ',d1,d2,d3' ],
293 [ "VMS->splitdir('.-.d2.d3')", ',-,d2,d3' ],
294 [ "VMS->splitdir('[.-.d2.d3]')", ',-,d2,d3' ],
296 [ "VMS->catdir('')", '' ],
297 [ "VMS->catdir('d1','d2','d3')", '[.d1.d2.d3]' ],
298 [ "VMS->catdir('d1','d2/','d3')", '[.d1.d2.d3]' ],
299 [ "VMS->catdir('','d1','d2','d3')", '[.d1.d2.d3]' ],
300 [ "VMS->catdir('','-','d2','d3')", '[-.d2.d3]' ],
301 [ "VMS->catdir('','-','','d3')", '[-.d3]' ],
302 [ "VMS->catdir('dir.dir','d2.dir','d3.dir')", '[.dir.d2.d3]' ],
303 [ "VMS->catdir('[.name]')", '[.name]' ],
304 [ "VMS->catdir('[.name]','[.name]')", '[.name.name]'],
306 [ "VMS->abs2rel('node::volume:[t1.t2.t3]','[t1.t2.t3]')", '' ],
307 [ "VMS->abs2rel('node::volume:[t1.t2.t4]','[t1.t2.t3]')", '[-.t4]' ],
308 [ "VMS->abs2rel('[t1.t2.t3]','[t1.t2.t3]')", '' ],
309 [ "VMS->abs2rel('[t1.t2.t3]file','[t1.t2.t3]')", 'file' ],
310 [ "VMS->abs2rel('[t1.t2.t4]','[t1.t2.t3]')", '[-.t4]' ],
311 [ "VMS->abs2rel('[t1.t2]file','[t1.t2.t3]')", '[-]file' ],
312 [ "VMS->abs2rel('[t1.t2.t3.t4]','[t1.t2.t3]')", '[t4]' ],
313 [ "VMS->abs2rel('[t4.t5.t6]','[t1.t2.t3]')", '[---.t4.t5.t6]' ],
314 [ "VMS->abs2rel('[000000]','[t1.t2.t3]')", '[---]' ],
315 [ "VMS->abs2rel('a:[t1.t2.t4]','[t1.t2.t3]')", '[-.t4]' ],
316 [ "VMS->abs2rel('[a.-.b.c.-]','[t1.t2.t3]')", '[---.b]' ],
318 [ "VMS->rel2abs('[.t4]','[t1.t2.t3]')", '[t1.t2.t3.t4]' ],
319 [ "VMS->rel2abs('[.t4.t5]','[t1.t2.t3]')", '[t1.t2.t3.t4.t5]' ],
320 [ "VMS->rel2abs('[]','[t1.t2.t3]')", '[t1.t2.t3]' ],
321 [ "VMS->rel2abs('[-]','[t1.t2.t3]')", '[t1.t2]' ],
322 [ "VMS->rel2abs('[-.t4]','[t1.t2.t3]')", '[t1.t2.t4]' ],
323 [ "VMS->rel2abs('[t1]','[t1.t2.t3]')", '[t1]' ],
325 [ "OS2->case_tolerant()", '1' ],
327 [ "OS2->catdir('A:/d1','B:/d2','d3','')", 'A:/d1/B:/d2/d3' ],
329 [ "OS2->catfile('a','b','c')", 'a/b/c' ],
330 [ "OS2->catfile('a','b','./c')", 'a/b/c' ],
331 [ "OS2->catfile('./a','b','c')", 'a/b/c' ],
332 [ "OS2->catfile('c')", 'c' ],
333 [ "OS2->catfile('./c')", 'c' ],
335 [ "Mac->case_tolerant()", '1' ],
337 [ "Mac->catpath('','','')", '' ],
338 [ "Mac->catpath('',':','')", ':' ],
339 [ "Mac->catpath('','::','')", '::' ],
341 [ "Mac->catpath('hd','','')", 'hd:' ],
342 [ "Mac->catpath('hd:','','')", 'hd:' ],
343 [ "Mac->catpath('hd:',':','')", 'hd:' ],
344 [ "Mac->catpath('hd:','::','')", 'hd::' ],
346 [ "Mac->catpath('hd','','file')", 'hd:file' ],
347 [ "Mac->catpath('hd',':','file')", 'hd:file' ],
348 [ "Mac->catpath('hd','::','file')", 'hd::file' ],
349 [ "Mac->catpath('hd',':::','file')", 'hd:::file' ],
351 [ "Mac->catpath('hd:','',':file')", 'hd:file' ],
352 [ "Mac->catpath('hd:',':',':file')", 'hd:file' ],
353 [ "Mac->catpath('hd:','::',':file')", 'hd::file' ],
354 [ "Mac->catpath('hd:',':::',':file')", 'hd:::file' ],
356 [ "Mac->catpath('hd:','d1','file')", 'hd:d1:file' ],
357 [ "Mac->catpath('hd:',':d1:',':file')", 'hd:d1:file' ],
359 [ "Mac->catpath('','d1','')", ':d1:' ],
360 [ "Mac->catpath('',':d1','')", ':d1:' ],
361 [ "Mac->catpath('',':d1:','')", ':d1:' ],
363 [ "Mac->catpath('','d1','file')", ':d1:file' ],
364 [ "Mac->catpath('',':d1:',':file')", ':d1:file' ],
366 [ "Mac->catpath('','','file')", 'file' ],
367 [ "Mac->catpath('','',':file')", 'file' ], # !
368 [ "Mac->catpath('',':',':file')", ':file' ], # !
371 [ "Mac->splitpath(':')", ',:,' ],
372 [ "Mac->splitpath('::')", ',::,' ],
373 [ "Mac->splitpath(':::')", ',:::,' ],
375 [ "Mac->splitpath('file')", ',,file' ],
376 [ "Mac->splitpath(':file')", ',:,file' ],
378 [ "Mac->splitpath('d1',1)", ',:d1:,' ], # dir, not volume
379 [ "Mac->splitpath(':d1',1)", ',:d1:,' ],
380 [ "Mac->splitpath(':d1:',1)", ',:d1:,' ],
381 [ "Mac->splitpath(':d1:')", ',:d1:,' ],
382 [ "Mac->splitpath(':d1:d2:d3:')", ',:d1:d2:d3:,' ],
383 [ "Mac->splitpath(':d1:d2:d3:',1)", ',:d1:d2:d3:,' ],
384 [ "Mac->splitpath(':d1:file')", ',:d1:,file' ],
385 [ "Mac->splitpath('::d1:file')", ',::d1:,file' ],
387 [ "Mac->splitpath('hd:', 1)", 'hd:,,' ],
388 [ "Mac->splitpath('hd:')", 'hd:,,' ],
389 [ "Mac->splitpath('hd:d1:d2:')", 'hd:,:d1:d2:,' ],
390 [ "Mac->splitpath('hd:d1:d2',1)", 'hd:,:d1:d2:,' ],
391 [ "Mac->splitpath('hd:d1:d2:file')", 'hd:,:d1:d2:,file' ],
392 [ "Mac->splitpath('hd:d1:d2::file')", 'hd:,:d1:d2::,file' ],
393 [ "Mac->splitpath('hd::d1:d2:file')", 'hd:,::d1:d2:,file' ], # invalid path
394 [ "Mac->splitpath('hd:file')", 'hd:,,file' ],
396 [ "Mac->splitdir()", '' ],
397 [ "Mac->splitdir('')", '' ],
398 [ "Mac->splitdir(':')", ':' ],
399 [ "Mac->splitdir('::')", '::' ],
400 [ "Mac->splitdir(':::')", '::,::' ],
401 [ "Mac->splitdir(':::d1:d2')", '::,::,d1,d2' ],
403 [ "Mac->splitdir(':d1:d2:d3::')", 'd1,d2,d3,::'],
404 [ "Mac->splitdir(':d1:d2:d3:')", 'd1,d2,d3' ],
405 [ "Mac->splitdir(':d1:d2:d3')", 'd1,d2,d3' ],
407 # absolute paths in splitdir() work, but you'd better use splitpath()
408 [ "Mac->splitdir('hd:')", 'hd:' ],
409 [ "Mac->splitdir('hd::')", 'hd:,::' ], # invalid path, but it works
410 [ "Mac->splitdir('hd::d1:')", 'hd:,::,d1' ], # invalid path, but it works
411 [ "Mac->splitdir('hd:d1:d2:::')", 'hd:,d1,d2,::,::' ],
412 [ "Mac->splitdir('hd:d1:d2::')", 'hd:,d1,d2,::' ],
413 [ "Mac->splitdir('hd:d1:d2:')", 'hd:,d1,d2' ],
414 [ "Mac->splitdir('hd:d1:d2')", 'hd:,d1,d2' ],
415 [ "Mac->splitdir('hd:d1::d2::')", 'hd:,d1,::,d2,::' ],
417 [ "Mac->catdir()", '' ],
418 [ "Mac->catdir('')", $root, 'MacOS' ], # skipped on other OS
419 [ "Mac->catdir(':')", ':' ],
421 [ "Mac->catdir('', '')", $root, 'MacOS' ], # skipped on other OS
422 [ "Mac->catdir('', ':')", $root, 'MacOS' ], # skipped on other OS
423 [ "Mac->catdir(':', ':')", ':' ],
424 [ "Mac->catdir(':', '')", ':' ],
426 [ "Mac->catdir('', '::')", $root, 'MacOS' ], # skipped on other OS
427 [ "Mac->catdir(':', '::')", '::' ],
429 [ "Mac->catdir('::', '')", '::' ],
430 [ "Mac->catdir('::', ':')", '::' ],
432 [ "Mac->catdir('::', '::')", ':::' ],
434 [ "Mac->catdir(':d1')", ':d1:' ],
435 [ "Mac->catdir(':d1:')", ':d1:' ],
436 [ "Mac->catdir(':d1','d2')", ':d1:d2:' ],
437 [ "Mac->catdir(':d1',':d2')", ':d1:d2:' ],
438 [ "Mac->catdir(':d1',':d2:')", ':d1:d2:' ],
439 [ "Mac->catdir(':d1',':d2::')", ':d1:d2::' ],
440 [ "Mac->catdir(':',':d1',':d2')", ':d1:d2:' ],
441 [ "Mac->catdir('::',':d1',':d2')", '::d1:d2:' ],
442 [ "Mac->catdir('::','::',':d1',':d2')", ':::d1:d2:' ],
443 [ "Mac->catdir(':',':',':d1',':d2')", ':d1:d2:' ],
444 [ "Mac->catdir('::',':',':d1',':d2')", '::d1:d2:' ],
446 [ "Mac->catdir('d1')", ':d1:' ],
447 [ "Mac->catdir('d1','d2','d3')", ':d1:d2:d3:' ],
448 [ "Mac->catdir('d1','d2/','d3')", ':d1:d2/:d3:' ],
449 [ "Mac->catdir('d1','',':d2')", ':d1:d2:' ],
450 [ "Mac->catdir('d1',':',':d2')", ':d1:d2:' ],
451 [ "Mac->catdir('d1','::',':d2')", ':d1::d2:' ],
452 [ "Mac->catdir('d1',':::',':d2')", ':d1:::d2:' ],
453 [ "Mac->catdir('d1','::','::',':d2')", ':d1:::d2:' ],
454 [ "Mac->catdir('d1','d2')", ':d1:d2:' ],
455 [ "Mac->catdir('d1','d2', '')", ':d1:d2:' ],
456 [ "Mac->catdir('d1','d2', ':')", ':d1:d2:' ],
457 [ "Mac->catdir('d1','d2', '::')", ':d1:d2::' ],
458 [ "Mac->catdir('d1','d2','','')", ':d1:d2:' ],
459 [ "Mac->catdir('d1','d2',':','::')", ':d1:d2::' ],
460 [ "Mac->catdir('d1','d2','::','::')", ':d1:d2:::' ],
461 [ "Mac->catdir('d1',':d2')", ':d1:d2:' ],
462 [ "Mac->catdir('d1',':d2:')", ':d1:d2:' ],
464 [ "Mac->catdir('','d1','d2','d3')", $root . 'd1:d2:d3:', 'MacOS' ], # skipped on other OS
465 [ "Mac->catdir('',':','d1','d2')", $root . 'd1:d2:' , 'MacOS' ], # skipped on other OS
466 [ "Mac->catdir('','::','d1','d2')", $root . 'd1:d2:' , 'MacOS' ], # skipped on other OS
467 [ "Mac->catdir('',':','','d1')", $root . 'd1:' , 'MacOS' ], # skipped on other OS
468 [ "Mac->catdir('', ':d1',':d2')", $root . 'd1:d2:' , 'MacOS' ], # skipped on other OS
469 [ "Mac->catdir('','',':d1',':d2')", $root . 'd1:d2:' , 'MacOS' ], # skipped on other OS
471 [ "Mac->catdir('hd:',':d1')", 'hd:d1:' ],
472 [ "Mac->catdir('hd:d1:',':d2')", 'hd:d1:d2:' ],
473 [ "Mac->catdir('hd:','d1')", 'hd:d1:' ],
474 [ "Mac->catdir('hd:d1:',':d2')", 'hd:d1:d2:' ],
475 [ "Mac->catdir('hd:d1:',':d2:')", 'hd:d1:d2:' ],
477 [ "Mac->catfile()", '' ],
478 [ "Mac->catfile('')", '' ],
479 [ "Mac->catfile('', '')", $root , 'MacOS' ], # skipped on other OS
480 [ "Mac->catfile('', 'file')", $root . 'file', 'MacOS' ], # skipped on other OS
481 [ "Mac->catfile(':')", ':' ],
482 [ "Mac->catfile(':', '')", ':' ],
484 [ "Mac->catfile('d1','d2','file')", ':d1:d2:file' ],
485 [ "Mac->catfile('d1','d2',':file')", ':d1:d2:file' ],
486 [ "Mac->catfile('file')", 'file' ],
487 [ "Mac->catfile(':', 'file')", ':file' ],
489 [ "Mac->canonpath('')", '' ],
490 [ "Mac->canonpath(':')", ':' ],
491 [ "Mac->canonpath('::')", '::' ],
492 [ "Mac->canonpath('a::')", 'a::' ],
493 [ "Mac->canonpath(':a::')", ':a::' ],
495 [ "Mac->abs2rel('hd:d1:d2:','hd:d1:d2:')", ':' ],
496 [ "Mac->abs2rel('hd:d1:d2:','hd:d1:d2:file')", ':' ], # ignore base's file portion
497 [ "Mac->abs2rel('hd:d1:d2:file','hd:d1:d2:')", ':file' ],
498 [ "Mac->abs2rel('hd:d1:','hd:d1:d2:')", '::' ],
499 [ "Mac->abs2rel('hd:d3:','hd:d1:d2:')", ':::d3:' ],
500 [ "Mac->abs2rel('hd:d3:','hd:d1:d2::')", '::d3:' ],
501 [ "Mac->abs2rel('hd:d1:d4:d5:','hd:d1::d2:d3::')", '::d1:d4:d5:' ],
502 [ "Mac->abs2rel('hd:d1:d4:d5:','hd:d1::d2:d3:')", ':::d1:d4:d5:' ], # first, resolve updirs in base
503 [ "Mac->abs2rel('hd:d1:d3:','hd:d1:d2:')", '::d3:' ],
504 [ "Mac->abs2rel('hd:d1::d3:','hd:d1:d2:')", ':::d3:' ],
505 [ "Mac->abs2rel('hd:d3:','hd:d1:d2:')", ':::d3:' ], # same as above
506 [ "Mac->abs2rel('hd:d1:d2:d3:','hd:d1:d2:')", ':d3:' ],
507 [ "Mac->abs2rel('hd:d1:d2:d3::','hd:d1:d2:')", ':d3::' ],
508 [ "Mac->abs2rel('hd1:d3:d4:d5:','hd2:d1:d2:')", ':::d3:d4:d5:' ], # ignore base's volume
509 [ "Mac->abs2rel('hd:','hd:d1:d2:')", ':::' ],
511 [ "Mac->rel2abs(':d3:','hd:d1:d2:')", 'hd:d1:d2:d3:' ],
512 [ "Mac->rel2abs(':d3:d4:','hd:d1:d2:')", 'hd:d1:d2:d3:d4:' ],
513 [ "Mac->rel2abs('','hd:d1:d2:')", '' ],
514 [ "Mac->rel2abs('::','hd:d1:d2:')", 'hd:d1:d2::' ],
515 [ "Mac->rel2abs('::','hd:d1:d2:file')", 'hd:d1:d2::' ],# ignore base's file portion
516 [ "Mac->rel2abs(':file','hd:d1:d2:')", 'hd:d1:d2:file' ],
517 [ "Mac->rel2abs('::file','hd:d1:d2:')", 'hd:d1:d2::file' ],
518 [ "Mac->rel2abs('::d3:','hd:d1:d2:')", 'hd:d1:d2::d3:' ],
519 [ "Mac->rel2abs('hd:','hd:d1:d2:')", 'hd:' ], # path already absolute
520 [ "Mac->rel2abs('hd:d3:file','hd:d1:d2:')", 'hd:d3:file' ],
521 [ "Mac->rel2abs('hd:d3:','hd:d1:file')", 'hd:d3:' ],
523 [ "Epoc->case_tolerant()", '1' ],
525 [ "Epoc->canonpath('')", '' ],
526 [ "Epoc->canonpath('///../../..//./././a//b/.././c/././')", '/a/b/../c' ],
527 [ "Epoc->canonpath('/./')", '/' ],
528 [ "Epoc->canonpath('/a/./')", '/a' ],
530 # XXX Todo, copied from Unix, but fail. Should they? 2003-07-07 Tels
531 #[ "Epoc->canonpath('/a/.')", '/a' ],
532 #[ "Epoc->canonpath('/.')", '/' ],
534 [ "Cygwin->case_tolerant()", '0' ],
538 plan tests => scalar @tests;
541 @File::Spec::FakeWin32::ISA = qw(File::Spec::Win32);
542 sub File::Spec::FakeWin32::cwd { 'C:\\one\\two' }
546 # Test out the class methods
553 # Tries a named function with the given args and compares the result against
554 # an expected result. Works with functions that return scalars or arrays.
557 my $function = shift ;
558 my $expected = shift ;
559 my $platform = shift ;
561 if ($platform && $^O ne $platform) {
562 skip("skip $function", 1);
566 $function =~ s#\\#\\\\#g ;
567 $function =~ s/^([^\$].*->)/File::Spec::$1/;
568 my $got = join ',', eval $function;
571 if ( $@ =~ /^\Q$skip_exception/ ) {
572 skip "skip $function: $skip_exception", 1;
575 ok $@, '', $function;
580 ok $got, $expected, $function;