This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: Decreasing VMS tests in File::Spec::VMS?
[perl5.git] / lib / File / Spec / t / Spec.t
CommitLineData
e021ab8e
JH
1#!/usr/bin/perl -w
2
3use Test;
270d1e39 4
2586ba89
JH
5# Grab all of the plain routines from File::Spec
6use File::Spec @File::Spec::EXPORT_OK ;
7
8require File::Spec::Unix ;
9require File::Spec::Win32 ;
10
11eval {
12 require VMS::Filespec ;
13} ;
14
15my $skip_exception = "Install VMS::Filespec (from vms/ext)" ;
16
17if ( $@ ) {
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
21 # VMS paths.
22 eval qq-
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" }
26 - ;
27 $INC{"VMS/Filespec.pm"} = 1 ;
28}
29require File::Spec::VMS ;
30
31require File::Spec::OS2 ;
32require File::Spec::Mac ;
e021ab8e
JH
33require File::Spec::Epoc ;
34require File::Spec::Cygwin ;
2586ba89
JH
35
36# $root is only needed by Mac OS tests; these particular
37# tests are skipped on other OSs
e021ab8e 38my $root = '';
45657e91 39if ($^O eq 'MacOS') {
2586ba89
JH
40 $root = File::Spec::Mac->rootdir();
41}
270d1e39 42
0994714a
GS
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.
3149a8e4 46
0994714a 47@tests = (
2586ba89
JH
48# [ Function , Expected , Platform ]
49
e021ab8e
JH
50[ "Unix->case_tolerant()", '0' ],
51
02961b52
MS
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' ],
270d1e39 57
0994714a
GS
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/,' ],
270d1e39 67
0994714a
GS
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/' ],
270d1e39 79
0994714a
GS
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' ],
270d1e39 85
0994714a
GS
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' ],
92
0994714a
GS
93[ "Unix->canonpath('')", '' ],
94[ "Unix->canonpath('///../../..//./././a//b/.././c/././')", '/a/b/../c' ],
6bf11762
BS
95[ "Unix->canonpath('/.')", '/' ],
96[ "Unix->canonpath('/./')", '/' ],
97[ "Unix->canonpath('/a/./')", '/a' ],
98[ "Unix->canonpath('/a/.')", '/a' ],
0994714a
GS
99
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')", '../../..' ],
6bf11762 108[ "Unix->abs2rel('/.','/t1/t2/t3')", '../../..' ],
0994714a
GS
109[ "Unix->abs2rel('/./','/t1/t2/t3')", '../../..' ],
110#[ "Unix->abs2rel('../t4','/t1/t2/t3')", '../t4' ],
111
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' ],
118
e021ab8e
JH
119[ "Win32->case_tolerant()", '1' ],
120
0994714a
GS
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/,' ],
144
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' ],
164
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' ],
170
171[ "Win32->catdir()", '' ],
172[ "Win32->catdir('')", '\\' ],
173[ "Win32->catdir('/')", '\\' ],
174[ "Win32->catdir('//d1','d2')", '\\\\d1\\d2' ],
e021ab8e
JH
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' ],
0994714a
GS
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:\\' ],
193
02961b52
MS
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' ],
199
0994714a
GS
200
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('/.')", '\\.' ],
cc23144f 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' ],
e021ab8e 216[ "Win32->canonpath('\\../temp\\')", '\\temp' ],
14fb0816 217[ "Win32->can('_cwd')", qr/CODE/ ],
e021ab8e
JH
218
219# FakeWin32 subclass (see below) just sets CWD to C:\one\two
220
221[ "FakeWin32->abs2rel('/t1/t2/t3','/t1/t2/t3')", '' ],
222[ "FakeWin32->abs2rel('/t1/t2/t4','/t1/t2/t3')", '..\\t4' ],
223[ "FakeWin32->abs2rel('/t1/t2','/t1/t2/t3')", '..' ],
224[ "FakeWin32->abs2rel('/t1/t2/t3/t4','/t1/t2/t3')", 't4' ],
225[ "FakeWin32->abs2rel('/t4/t5/t6','/t1/t2/t3')", '..\\..\\..\\t4\\t5\\t6' ],
226[ "FakeWin32->abs2rel('../t4','/t1/t2/t3')", '..\\..\\..\\one\\t4' ],
227[ "FakeWin32->abs2rel('/','/t1/t2/t3')", '..\\..\\..' ],
228[ "FakeWin32->abs2rel('///','/t1/t2/t3')", '..\\..\\..' ],
229[ "FakeWin32->abs2rel('/.','/t1/t2/t3')", '..\\..\\..' ],
230[ "FakeWin32->abs2rel('/./','/t1/t2/t3')", '..\\..\\..' ],
231[ "FakeWin32->abs2rel('\\\\a/t1/t2/t4','/t2/t3')", '\\\\a\\t1\\t2\\t4' ],
232[ "FakeWin32->abs2rel('//a/t1/t2/t4','/t2/t3')", '\\\\a\\t1\\t2\\t4' ],
233[ "FakeWin32->abs2rel('A:/t1/t2/t3','A:/t1/t2/t3')", '' ],
234[ "FakeWin32->abs2rel('A:/t1/t2/t3/t4','A:/t1/t2/t3')", 't4' ],
235[ "FakeWin32->abs2rel('A:/t1/t2/t3','A:/t1/t2/t3/t4')", '..' ],
236[ "FakeWin32->abs2rel('A:/t1/t2/t3','B:/t1/t2/t3')", 'A:\\t1\\t2\\t3' ],
237[ "FakeWin32->abs2rel('A:/t1/t2/t3/t4','B:/t1/t2/t3')", 'A:\\t1\\t2\\t3\\t4' ],
238[ "FakeWin32->abs2rel('E:/foo/bar/baz')", 'E:\\foo\\bar\\baz' ],
239[ "FakeWin32->abs2rel('C:/one/two/three')", 'three' ],
240
241[ "FakeWin32->rel2abs('temp','C:/')", 'C:\\temp' ],
242[ "FakeWin32->rel2abs('temp','C:/a')", 'C:\\a\\temp' ],
243[ "FakeWin32->rel2abs('temp','C:/a/')", 'C:\\a\\temp' ],
244[ "FakeWin32->rel2abs('../','C:/')", 'C:\\' ],
245[ "FakeWin32->rel2abs('../','C:/a')", 'C:\\' ],
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('temp','//prague_main/work')", '\\\\prague_main\\work\\temp' ],
249[ "FakeWin32->rel2abs('../','//prague_main/work')", '\\\\prague_main\\work' ],
250
251[ "VMS->case_tolerant()", '1' ],
02961b52
MS
252
253[ "VMS->catfile('a','b','c')", '[.a.b]c' ],
254[ "VMS->catfile('a','b','[]c')", '[.a.b]c' ],
255[ "VMS->catfile('[.a]','b','c')", '[.a.b]c' ],
256[ "VMS->catfile('c')", 'c' ],
257[ "VMS->catfile('[]c')", 'c' ],
258
0994714a 259[ "VMS->splitpath('file')", ',,file' ],
08c7cbbb
GS
260[ "VMS->splitpath('[d1.d2.d3]')", ',[d1.d2.d3],' ],
261[ "VMS->splitpath('[.d1.d2.d3]')", ',[.d1.d2.d3],' ],
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('[.d1.d2.d3]file')", ',[.d1.d2.d3],file' ],
266[ "VMS->splitpath('node::volume:[d1.d2.d3]')", 'node::volume:,[d1.d2.d3],' ],
267[ "VMS->splitpath('node::volume:[d1.d2.d3]file')", 'node::volume:,[d1.d2.d3],file' ],
268[ "VMS->splitpath('node\"access_spec\"::volume:[d1.d2.d3]')", 'node"access_spec"::volume:,[d1.d2.d3],' ],
269[ "VMS->splitpath('node\"access_spec\"::volume:[d1.d2.d3]file')", 'node"access_spec"::volume:,[d1.d2.d3],file' ],
0994714a
GS
270
271[ "VMS->catpath('','','file')", 'file' ],
272[ "VMS->catpath('','[d1.d2.d3]','')", '[d1.d2.d3]' ],
273[ "VMS->catpath('','[.d1.d2.d3]','')", '[.d1.d2.d3]' ],
274[ "VMS->catpath('','[d1.d2.d3]','file')", '[d1.d2.d3]file' ],
275[ "VMS->catpath('','[.d1.d2.d3]','file')", '[.d1.d2.d3]file' ],
08c7cbbb
GS
276[ "VMS->catpath('','d1/d2/d3','file')", '[.d1.d2.d3]file' ],
277[ "VMS->catpath('v','d1/d2/d3','file')", 'v:[.d1.d2.d3]file' ],
0994714a
GS
278[ "VMS->catpath('node::volume:','[d1.d2.d3]','')", 'node::volume:[d1.d2.d3]' ],
279[ "VMS->catpath('node::volume:','[d1.d2.d3]','file')", 'node::volume:[d1.d2.d3]file' ],
280[ "VMS->catpath('node\"access_spec\"::volume:','[d1.d2.d3]','')", 'node"access_spec"::volume:[d1.d2.d3]' ],
281[ "VMS->catpath('node\"access_spec\"::volume:','[d1.d2.d3]','file')", 'node"access_spec"::volume:[d1.d2.d3]file' ],
282
283[ "VMS->canonpath('')", '' ],
178326fd 284[ "VMS->canonpath('volume:[d1]file')", 'volume:[d1]file' ],
08c7cbbb 285[ "VMS->canonpath('volume:[d1.-.d2.][d3.d4.-]')", 'volume:[d2.d3]' ],
178326fd 286[ "VMS->canonpath('volume:[000000.d1]d2.dir;1')", 'volume:[d1]d2.dir;1' ],
0994714a
GS
287
288[ "VMS->splitdir('')", '' ],
289[ "VMS->splitdir('[]')", '' ],
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('[.d1.d2.d3]')", ',d1,d2,d3' ],
294[ "VMS->splitdir('.-.d2.d3')", ',-,d2,d3' ],
295[ "VMS->splitdir('[.-.d2.d3]')", ',-,d2,d3' ],
296
08c7cbbb
GS
297[ "VMS->catdir('')", '' ],
298[ "VMS->catdir('d1','d2','d3')", '[.d1.d2.d3]' ],
299[ "VMS->catdir('d1','d2/','d3')", '[.d1.d2.d3]' ],
300[ "VMS->catdir('','d1','d2','d3')", '[.d1.d2.d3]' ],
301[ "VMS->catdir('','-','d2','d3')", '[-.d2.d3]' ],
302[ "VMS->catdir('','-','','d3')", '[-.d3]' ],
303[ "VMS->catdir('dir.dir','d2.dir','d3.dir')", '[.dir.d2.d3]' ],
304[ "VMS->catdir('[.name]')", '[.name]' ],
45657e91 305[ "VMS->catdir('[.name]','[.name]')", '[.name.name]'],
0994714a 306
416c0615 307[ "VMS->abs2rel('node::volume:[t1.t2.t3]','node::volume:[t1.t2.t3]')", '' ],
cda9bddd 308[ "VMS->abs2rel('node::volume:[t1.t2.t3]','[t1.t2.t3]')", 'node::volume:[t1.t2.t3]' ],
416c0615 309[ "VMS->abs2rel('node::volume:[t1.t2.t4]','node::volume:[t1.t2.t3]')", '[-.t4]' ],
cda9bddd 310[ "VMS->abs2rel('node::volume:[t1.t2.t4]','[t1.t2.t3]')", 'node::volume:[t1.t2.t4]' ],
0994714a
GS
311[ "VMS->abs2rel('[t1.t2.t3]','[t1.t2.t3]')", '' ],
312[ "VMS->abs2rel('[t1.t2.t3]file','[t1.t2.t3]')", 'file' ],
313[ "VMS->abs2rel('[t1.t2.t4]','[t1.t2.t3]')", '[-.t4]' ],
314[ "VMS->abs2rel('[t1.t2]file','[t1.t2.t3]')", '[-]file' ],
315[ "VMS->abs2rel('[t1.t2.t3.t4]','[t1.t2.t3]')", '[t4]' ],
08c7cbbb 316[ "VMS->abs2rel('[t4.t5.t6]','[t1.t2.t3]')", '[---.t4.t5.t6]' ],
737c380e 317[ "VMS->abs2rel('[000000]','[t1.t2.t3]')", '[---]' ],
416c0615 318[ "VMS->abs2rel('a:[t1.t2.t4]','a:[t1.t2.t3]')", '[-.t4]' ],
cda9bddd 319[ "VMS->abs2rel('a:[t1.t2.t4]','[t1.t2.t3]')", 'a:[t1.t2.t4]' ],
08c7cbbb 320[ "VMS->abs2rel('[a.-.b.c.-]','[t1.t2.t3]')", '[---.b]' ],
270d1e39 321
0994714a
GS
322[ "VMS->rel2abs('[.t4]','[t1.t2.t3]')", '[t1.t2.t3.t4]' ],
323[ "VMS->rel2abs('[.t4.t5]','[t1.t2.t3]')", '[t1.t2.t3.t4.t5]' ],
324[ "VMS->rel2abs('[]','[t1.t2.t3]')", '[t1.t2.t3]' ],
08c7cbbb
GS
325[ "VMS->rel2abs('[-]','[t1.t2.t3]')", '[t1.t2]' ],
326[ "VMS->rel2abs('[-.t4]','[t1.t2.t3]')", '[t1.t2.t4]' ],
0994714a 327[ "VMS->rel2abs('[t1]','[t1.t2.t3]')", '[t1]' ],
270d1e39 328
e021ab8e
JH
329[ "OS2->case_tolerant()", '1' ],
330
0994714a 331[ "OS2->catdir('A:/d1','B:/d2','d3','')", 'A:/d1/B:/d2/d3' ],
02961b52 332
0994714a 333[ "OS2->catfile('a','b','c')", 'a/b/c' ],
02961b52
MS
334[ "OS2->catfile('a','b','./c')", 'a/b/c' ],
335[ "OS2->catfile('./a','b','c')", 'a/b/c' ],
336[ "OS2->catfile('c')", 'c' ],
337[ "OS2->catfile('./c')", 'c' ],
0994714a 338
e021ab8e 339[ "Mac->case_tolerant()", '1' ],
be708cc0
JH
340
341[ "Mac->catpath('','','')", '' ],
342[ "Mac->catpath('',':','')", ':' ],
343[ "Mac->catpath('','::','')", '::' ],
344
345[ "Mac->catpath('hd','','')", 'hd:' ],
346[ "Mac->catpath('hd:','','')", 'hd:' ],
45657e91 347[ "Mac->catpath('hd:',':','')", 'hd:' ],
be708cc0
JH
348[ "Mac->catpath('hd:','::','')", 'hd::' ],
349
350[ "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
355[ "Mac->catpath('hd:','',':file')", 'hd:file' ],
356[ "Mac->catpath('hd:',':',':file')", 'hd:file' ],
357[ "Mac->catpath('hd:','::',':file')", 'hd::file' ],
358[ "Mac->catpath('hd:',':::',':file')", 'hd:::file' ],
359
360[ "Mac->catpath('hd:','d1','file')", 'hd:d1:file' ],
361[ "Mac->catpath('hd:',':d1:',':file')", 'hd:d1:file' ],
362
363[ "Mac->catpath('','d1','')", ':d1:' ],
364[ "Mac->catpath('',':d1','')", ':d1:' ],
365[ "Mac->catpath('',':d1:','')", ':d1:' ],
366
367[ "Mac->catpath('','d1','file')", ':d1:file' ],
368[ "Mac->catpath('',':d1:',':file')", ':d1:file' ],
369
370[ "Mac->catpath('','','file')", 'file' ],
371[ "Mac->catpath('','',':file')", 'file' ], # !
372[ "Mac->catpath('',':',':file')", ':file' ], # !
373
374
375[ "Mac->splitpath(':')", ',:,' ],
376[ "Mac->splitpath('::')", ',::,' ],
377[ "Mac->splitpath(':::')", ',:::,' ],
378
379[ "Mac->splitpath('file')", ',,file' ],
380[ "Mac->splitpath(':file')", ',:,file' ],
381
382[ "Mac->splitpath('d1',1)", ',:d1:,' ], # dir, not volume
383[ "Mac->splitpath(':d1',1)", ',:d1:,' ],
384[ "Mac->splitpath(':d1:',1)", ',:d1:,' ],
385[ "Mac->splitpath(':d1:')", ',:d1:,' ],
386[ "Mac->splitpath(':d1:d2:d3:')", ',:d1:d2:d3:,' ],
387[ "Mac->splitpath(':d1:d2:d3:',1)", ',:d1:d2:d3:,' ],
388[ "Mac->splitpath(':d1:file')", ',:d1:,file' ],
389[ "Mac->splitpath('::d1:file')", ',::d1:,file' ],
390
391[ "Mac->splitpath('hd:', 1)", 'hd:,,' ],
392[ "Mac->splitpath('hd:')", 'hd:,,' ],
393[ "Mac->splitpath('hd:d1:d2:')", 'hd:,:d1:d2:,' ],
394[ "Mac->splitpath('hd:d1:d2',1)", 'hd:,:d1:d2:,' ],
395[ "Mac->splitpath('hd:d1:d2:file')", 'hd:,:d1:d2:,file' ],
396[ "Mac->splitpath('hd:d1:d2::file')", 'hd:,:d1:d2::,file' ],
397[ "Mac->splitpath('hd::d1:d2:file')", 'hd:,::d1:d2:,file' ], # invalid path
398[ "Mac->splitpath('hd:file')", 'hd:,,file' ],
399
2586ba89 400[ "Mac->splitdir()", '' ],
be708cc0
JH
401[ "Mac->splitdir('')", '' ],
402[ "Mac->splitdir(':')", ':' ],
403[ "Mac->splitdir('::')", '::' ],
2586ba89
JH
404[ "Mac->splitdir(':::')", '::,::' ],
405[ "Mac->splitdir(':::d1:d2')", '::,::,d1,d2' ],
406
407[ "Mac->splitdir(':d1:d2:d3::')", 'd1,d2,d3,::'],
408[ "Mac->splitdir(':d1:d2:d3:')", 'd1,d2,d3' ],
409[ "Mac->splitdir(':d1:d2:d3')", 'd1,d2,d3' ],
410
411# absolute paths in splitdir() work, but you'd better use splitpath()
412[ "Mac->splitdir('hd:')", 'hd:' ],
413[ "Mac->splitdir('hd::')", 'hd:,::' ], # invalid path, but it works
414[ "Mac->splitdir('hd::d1:')", 'hd:,::,d1' ], # invalid path, but it works
415[ "Mac->splitdir('hd:d1:d2:::')", 'hd:,d1,d2,::,::' ],
416[ "Mac->splitdir('hd:d1:d2::')", 'hd:,d1,d2,::' ],
417[ "Mac->splitdir('hd:d1:d2:')", 'hd:,d1,d2' ],
418[ "Mac->splitdir('hd:d1:d2')", 'hd:,d1,d2' ],
419[ "Mac->splitdir('hd:d1::d2::')", 'hd:,d1,::,d2,::' ],
420
421[ "Mac->catdir()", '' ],
422[ "Mac->catdir('')", $root, 'MacOS' ], # skipped on other OS
423[ "Mac->catdir(':')", ':' ],
424
425[ "Mac->catdir('', '')", $root, 'MacOS' ], # skipped on other OS
45657e91
JH
426[ "Mac->catdir('', ':')", $root, 'MacOS' ], # skipped on other OS
427[ "Mac->catdir(':', ':')", ':' ],
428[ "Mac->catdir(':', '')", ':' ],
2586ba89
JH
429
430[ "Mac->catdir('', '::')", $root, 'MacOS' ], # skipped on other OS
45657e91 431[ "Mac->catdir(':', '::')", '::' ],
2586ba89 432
45657e91
JH
433[ "Mac->catdir('::', '')", '::' ],
434[ "Mac->catdir('::', ':')", '::' ],
2586ba89 435
45657e91 436[ "Mac->catdir('::', '::')", ':::' ],
2586ba89
JH
437
438[ "Mac->catdir(':d1')", ':d1:' ],
439[ "Mac->catdir(':d1:')", ':d1:' ],
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:' ],
445[ "Mac->catdir('::',':d1',':d2')", '::d1:d2:' ],
446[ "Mac->catdir('::','::',':d1',':d2')", ':::d1:d2:' ],
447[ "Mac->catdir(':',':',':d1',':d2')", ':d1:d2:' ],
448[ "Mac->catdir('::',':',':d1',':d2')", '::d1:d2:' ],
449
450[ "Mac->catdir('d1')", ':d1:' ],
451[ "Mac->catdir('d1','d2','d3')", ':d1:d2:d3:' ],
452[ "Mac->catdir('d1','d2/','d3')", ':d1:d2/:d3:' ],
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:' ],
463[ "Mac->catdir('d1','d2',':','::')", ':d1:d2::' ],
464[ "Mac->catdir('d1','d2','::','::')", ':d1:d2:::' ],
465[ "Mac->catdir('d1',':d2')", ':d1:d2:' ],
466[ "Mac->catdir('d1',':d2:')", ':d1:d2:' ],
467
468[ "Mac->catdir('','d1','d2','d3')", $root . 'd1:d2:d3:', 'MacOS' ], # skipped on other OS
469[ "Mac->catdir('',':','d1','d2')", $root . 'd1:d2:' , 'MacOS' ], # skipped on other OS
470[ "Mac->catdir('','::','d1','d2')", $root . 'd1:d2:' , 'MacOS' ], # skipped on other OS
471[ "Mac->catdir('',':','','d1')", $root . 'd1:' , 'MacOS' ], # skipped on other OS
472[ "Mac->catdir('', ':d1',':d2')", $root . 'd1:d2:' , 'MacOS' ], # skipped on other OS
473[ "Mac->catdir('','',':d1',':d2')", $root . 'd1:d2:' , 'MacOS' ], # skipped on other OS
be708cc0 474
be708cc0
JH
475[ "Mac->catdir('hd:',':d1')", 'hd:d1:' ],
476[ "Mac->catdir('hd:d1:',':d2')", 'hd:d1:d2:' ],
477[ "Mac->catdir('hd:','d1')", 'hd:d1:' ],
be708cc0
JH
478[ "Mac->catdir('hd:d1:',':d2')", 'hd:d1:d2:' ],
479[ "Mac->catdir('hd:d1:',':d2:')", 'hd:d1:d2:' ],
480
45657e91 481[ "Mac->catfile()", '' ],
2586ba89 482[ "Mac->catfile('')", '' ],
45657e91 483[ "Mac->catfile('', '')", $root , 'MacOS' ], # skipped on other OS
2586ba89
JH
484[ "Mac->catfile('', 'file')", $root . 'file', 'MacOS' ], # skipped on other OS
485[ "Mac->catfile(':')", ':' ],
486[ "Mac->catfile(':', '')", ':' ],
be708cc0 487
2586ba89
JH
488[ "Mac->catfile('d1','d2','file')", ':d1:d2:file' ],
489[ "Mac->catfile('d1','d2',':file')", ':d1:d2:file' ],
45657e91
JH
490[ "Mac->catfile('file')", 'file' ],
491[ "Mac->catfile(':', 'file')", ':file' ],
492
0994714a
GS
493[ "Mac->canonpath('')", '' ],
494[ "Mac->canonpath(':')", ':' ],
495[ "Mac->canonpath('::')", '::' ],
496[ "Mac->canonpath('a::')", 'a::' ],
497[ "Mac->canonpath(':a::')", ':a::' ],
498
be708cc0
JH
499[ "Mac->abs2rel('hd:d1:d2:','hd:d1:d2:')", ':' ],
500[ "Mac->abs2rel('hd:d1:d2:','hd:d1:d2:file')", ':' ], # ignore base's file portion
45657e91 501[ "Mac->abs2rel('hd:d1:d2:file','hd:d1:d2:')", ':file' ],
be708cc0
JH
502[ "Mac->abs2rel('hd:d1:','hd:d1:d2:')", '::' ],
503[ "Mac->abs2rel('hd:d3:','hd:d1:d2:')", ':::d3:' ],
504[ "Mac->abs2rel('hd:d3:','hd:d1:d2::')", '::d3:' ],
505[ "Mac->abs2rel('hd:d1:d4:d5:','hd:d1::d2:d3::')", '::d1:d4:d5:' ],
506[ "Mac->abs2rel('hd:d1:d4:d5:','hd:d1::d2:d3:')", ':::d1:d4:d5:' ], # first, resolve updirs in base
507[ "Mac->abs2rel('hd:d1:d3:','hd:d1:d2:')", '::d3:' ],
508[ "Mac->abs2rel('hd:d1::d3:','hd:d1:d2:')", ':::d3:' ],
509[ "Mac->abs2rel('hd:d3:','hd:d1:d2:')", ':::d3:' ], # same as above
510[ "Mac->abs2rel('hd:d1:d2:d3:','hd:d1:d2:')", ':d3:' ],
511[ "Mac->abs2rel('hd:d1:d2:d3::','hd:d1:d2:')", ':d3::' ],
2586ba89 512[ "Mac->abs2rel('hd1:d3:d4:d5:','hd2:d1:d2:')", ':::d3:d4:d5:' ], # ignore base's volume
be708cc0
JH
513[ "Mac->abs2rel('hd:','hd:d1:d2:')", ':::' ],
514
45657e91
JH
515[ "Mac->rel2abs(':d3:','hd:d1:d2:')", 'hd:d1:d2:d3:' ],
516[ "Mac->rel2abs(':d3:d4:','hd:d1:d2:')", 'hd:d1:d2:d3:d4:' ],
be708cc0
JH
517[ "Mac->rel2abs('','hd:d1:d2:')", '' ],
518[ "Mac->rel2abs('::','hd:d1:d2:')", 'hd:d1:d2::' ],
519[ "Mac->rel2abs('::','hd:d1:d2:file')", 'hd:d1:d2::' ],# ignore base's file portion
520[ "Mac->rel2abs(':file','hd:d1:d2:')", 'hd:d1:d2:file' ],
521[ "Mac->rel2abs('::file','hd:d1:d2:')", 'hd:d1:d2::file' ],
522[ "Mac->rel2abs('::d3:','hd:d1:d2:')", 'hd:d1:d2::d3:' ],
523[ "Mac->rel2abs('hd:','hd:d1:d2:')", 'hd:' ], # path already absolute
524[ "Mac->rel2abs('hd:d3:file','hd:d1:d2:')", 'hd:d3:file' ],
525[ "Mac->rel2abs('hd:d3:','hd:d1:file')", 'hd:d3:' ],
e021ab8e
JH
526
527[ "Epoc->case_tolerant()", '1' ],
528
529[ "Epoc->canonpath('')", '' ],
530[ "Epoc->canonpath('///../../..//./././a//b/.././c/././')", '/a/b/../c' ],
531[ "Epoc->canonpath('/./')", '/' ],
532[ "Epoc->canonpath('/a/./')", '/a' ],
533
534# XXX Todo, copied from Unix, but fail. Should they? 2003-07-07 Tels
535#[ "Epoc->canonpath('/a/.')", '/a' ],
536#[ "Epoc->canonpath('/.')", '/' ],
537
538[ "Cygwin->case_tolerant()", '0' ],
539
0994714a
GS
540) ;
541
e021ab8e 542plan tests => scalar @tests;
270d1e39 543
e021ab8e
JH
544{
545 @File::Spec::FakeWin32::ISA = qw(File::Spec::Win32);
14fb0816 546 sub File::Spec::FakeWin32::_cwd { 'C:\\one\\two' }
e021ab8e 547}
0994714a 548
0994714a 549
0994714a
GS
550# Test out the class methods
551for ( @tests ) {
552 tryfunc( @$_ ) ;
270d1e39
GS
553}
554
0994714a 555
0994714a
GS
556#
557# Tries a named function with the given args and compares the result against
558# an expected result. Works with functions that return scalars or arrays.
559#
560sub tryfunc {
561 my $function = shift ;
562 my $expected = shift ;
f6a53ef2
GS
563 my $platform = shift ;
564
565 if ($platform && $^O ne $platform) {
e021ab8e 566 skip("skip $function", 1);
f6a53ef2
GS
567 return;
568 }
0994714a
GS
569
570 $function =~ s#\\#\\\\#g ;
e021ab8e
JH
571 $function =~ s/^([^\$].*->)/File::Spec::$1/;
572 my $got = join ',', eval $function;
0994714a
GS
573
574 if ( $@ ) {
e021ab8e
JH
575 if ( $@ =~ /^\Q$skip_exception/ ) {
576 skip "skip $function: $skip_exception", 1;
577 }
578 else {
579 ok $@, '', $function;
580 }
581 return;
0994714a 582 }
e021ab8e
JH
583
584 ok $got, $expected, $function;
0994714a 585}