This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Merge changes from PathTools: 'Update to support VMS in Unix compatible mode and...
[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 ;
5b287435 10require Cwd;
2586ba89
JH
11
12eval {
13 require VMS::Filespec ;
14} ;
15
16my $skip_exception = "Install VMS::Filespec (from vms/ext)" ;
17
18if ( $@ ) {
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
22 # VMS paths.
23 eval qq-
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" }
27 - ;
28 $INC{"VMS/Filespec.pm"} = 1 ;
29}
30require File::Spec::VMS ;
31
32require File::Spec::OS2 ;
33require File::Spec::Mac ;
e021ab8e
JH
34require File::Spec::Epoc ;
35require File::Spec::Cygwin ;
2586ba89
JH
36
37# $root is only needed by Mac OS tests; these particular
38# tests are skipped on other OSs
e021ab8e 39my $root = '';
45657e91 40if ($^O eq 'MacOS') {
2586ba89
JH
41 $root = File::Spec::Mac->rootdir();
42}
270d1e39 43
0994714a
GS
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.
3149a8e4 47
0994714a 48@tests = (
2586ba89
JH
49# [ Function , Expected , Platform ]
50
e021ab8e
JH
51[ "Unix->case_tolerant()", '0' ],
52
02961b52
MS
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' ],
270d1e39 58
0994714a
GS
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/,' ],
270d1e39 68
0994714a
GS
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/' ],
270d1e39 80
0994714a
GS
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' ],
270d1e39 86
0994714a
GS
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' ],
ff235dd6 93[ "Unix->catdir('/','d2/d3')", '/d2/d3' ],
0994714a 94
0994714a 95[ "Unix->canonpath('///../../..//./././a//b/.././c/././')", '/a/b/../c' ],
9596c75c
RGS
96[ "Unix->canonpath('')", '' ],
97# rt.perl.org 27052
98[ "Unix->canonpath('a/../../b/c')", 'a/../../b/c' ],
99[ "Unix->canonpath('/.')", '/' ],
100[ "Unix->canonpath('/./')", '/' ],
101[ "Unix->canonpath('/a/./')", '/a' ],
102[ "Unix->canonpath('/a/.')", '/a' ],
103[ "Unix->canonpath('/../../')", '/' ],
104[ "Unix->canonpath('/../..')", '/' ],
0994714a 105
9d5071ba 106[ "Unix->abs2rel('/t1/t2/t3','/t1/t2/t3')", '.' ],
0994714a
GS
107[ "Unix->abs2rel('/t1/t2/t4','/t1/t2/t3')", '../t4' ],
108[ "Unix->abs2rel('/t1/t2','/t1/t2/t3')", '..' ],
109[ "Unix->abs2rel('/t1/t2/t3/t4','/t1/t2/t3')", 't4' ],
110[ "Unix->abs2rel('/t4/t5/t6','/t1/t2/t3')", '../../../t4/t5/t6' ],
111#[ "Unix->abs2rel('../t4','/t1/t2/t3')", '../t4' ],
112[ "Unix->abs2rel('/','/t1/t2/t3')", '../../..' ],
113[ "Unix->abs2rel('///','/t1/t2/t3')", '../../..' ],
6bf11762 114[ "Unix->abs2rel('/.','/t1/t2/t3')", '../../..' ],
0994714a
GS
115[ "Unix->abs2rel('/./','/t1/t2/t3')", '../../..' ],
116#[ "Unix->abs2rel('../t4','/t1/t2/t3')", '../t4' ],
ff235dd6
SP
117[ "Unix->abs2rel('/t1/t2/t3', '/')", 't1/t2/t3' ],
118[ "Unix->abs2rel('/t1/t2/t3', '/t1')", 't2/t3' ],
c47834cd
RGS
119[ "Unix->abs2rel('t1/t2/t3', 't1')", 't2/t3' ],
120[ "Unix->abs2rel('t1/t2/t3', 't4')", '../t1/t2/t3' ],
0994714a
GS
121
122[ "Unix->rel2abs('t4','/t1/t2/t3')", '/t1/t2/t3/t4' ],
123[ "Unix->rel2abs('t4/t5','/t1/t2/t3')", '/t1/t2/t3/t4/t5' ],
124[ "Unix->rel2abs('.','/t1/t2/t3')", '/t1/t2/t3' ],
125[ "Unix->rel2abs('..','/t1/t2/t3')", '/t1/t2/t3/..' ],
126[ "Unix->rel2abs('../t4','/t1/t2/t3')", '/t1/t2/t3/../t4' ],
127[ "Unix->rel2abs('/t1','/t1/t2/t3')", '/t1' ],
128
e021ab8e 129[ "Win32->case_tolerant()", '1' ],
60598624 130[ "Win32->rootdir()", '\\' ],
e021ab8e 131
0994714a
GS
132[ "Win32->splitpath('file')", ',,file' ],
133[ "Win32->splitpath('\\d1/d2\\d3/')", ',\\d1/d2\\d3/,' ],
134[ "Win32->splitpath('d1/d2\\d3/')", ',d1/d2\\d3/,' ],
135[ "Win32->splitpath('\\d1/d2\\d3/.')", ',\\d1/d2\\d3/.,' ],
136[ "Win32->splitpath('\\d1/d2\\d3/..')", ',\\d1/d2\\d3/..,' ],
137[ "Win32->splitpath('\\d1/d2\\d3/.file')", ',\\d1/d2\\d3/,.file' ],
138[ "Win32->splitpath('\\d1/d2\\d3/file')", ',\\d1/d2\\d3/,file' ],
139[ "Win32->splitpath('d1/d2\\d3/file')", ',d1/d2\\d3/,file' ],
140[ "Win32->splitpath('C:\\d1/d2\\d3/')", 'C:,\\d1/d2\\d3/,' ],
141[ "Win32->splitpath('C:d1/d2\\d3/')", 'C:,d1/d2\\d3/,' ],
142[ "Win32->splitpath('C:\\d1/d2\\d3/file')", 'C:,\\d1/d2\\d3/,file' ],
143[ "Win32->splitpath('C:d1/d2\\d3/file')", 'C:,d1/d2\\d3/,file' ],
144[ "Win32->splitpath('C:\\../d2\\d3/file')", 'C:,\\../d2\\d3/,file' ],
145[ "Win32->splitpath('C:../d2\\d3/file')", 'C:,../d2\\d3/,file' ],
146[ "Win32->splitpath('\\../..\\d1/')", ',\\../..\\d1/,' ],
147[ "Win32->splitpath('\\./.\\d1/')", ',\\./.\\d1/,' ],
148[ "Win32->splitpath('\\\\node\\share\\d1/d2\\d3/')", '\\\\node\\share,\\d1/d2\\d3/,' ],
149[ "Win32->splitpath('\\\\node\\share\\d1/d2\\d3/file')", '\\\\node\\share,\\d1/d2\\d3/,file' ],
150[ "Win32->splitpath('\\\\node\\share\\d1/d2\\file')", '\\\\node\\share,\\d1/d2\\,file' ],
151[ "Win32->splitpath('file',1)", ',file,' ],
152[ "Win32->splitpath('\\d1/d2\\d3/',1)", ',\\d1/d2\\d3/,' ],
153[ "Win32->splitpath('d1/d2\\d3/',1)", ',d1/d2\\d3/,' ],
154[ "Win32->splitpath('\\\\node\\share\\d1/d2\\d3/',1)", '\\\\node\\share,\\d1/d2\\d3/,' ],
155
156[ "Win32->catpath('','','file')", 'file' ],
157[ "Win32->catpath('','\\d1/d2\\d3/','')", '\\d1/d2\\d3/' ],
158[ "Win32->catpath('','d1/d2\\d3/','')", 'd1/d2\\d3/' ],
159[ "Win32->catpath('','\\d1/d2\\d3/.','')", '\\d1/d2\\d3/.' ],
160[ "Win32->catpath('','\\d1/d2\\d3/..','')", '\\d1/d2\\d3/..' ],
161[ "Win32->catpath('','\\d1/d2\\d3/','.file')", '\\d1/d2\\d3/.file' ],
162[ "Win32->catpath('','\\d1/d2\\d3/','file')", '\\d1/d2\\d3/file' ],
163[ "Win32->catpath('','d1/d2\\d3/','file')", 'd1/d2\\d3/file' ],
164[ "Win32->catpath('C:','\\d1/d2\\d3/','')", 'C:\\d1/d2\\d3/' ],
165[ "Win32->catpath('C:','d1/d2\\d3/','')", 'C:d1/d2\\d3/' ],
166[ "Win32->catpath('C:','\\d1/d2\\d3/','file')", 'C:\\d1/d2\\d3/file' ],
167[ "Win32->catpath('C:','d1/d2\\d3/','file')", 'C:d1/d2\\d3/file' ],
168[ "Win32->catpath('C:','\\../d2\\d3/','file')", 'C:\\../d2\\d3/file' ],
169[ "Win32->catpath('C:','../d2\\d3/','file')", 'C:../d2\\d3/file' ],
170[ "Win32->catpath('','\\../..\\d1/','')", '\\../..\\d1/' ],
171[ "Win32->catpath('','\\./.\\d1/','')", '\\./.\\d1/' ],
172[ "Win32->catpath('\\\\node\\share','\\d1/d2\\d3/','')", '\\\\node\\share\\d1/d2\\d3/' ],
173[ "Win32->catpath('\\\\node\\share','\\d1/d2\\d3/','file')", '\\\\node\\share\\d1/d2\\d3/file' ],
174[ "Win32->catpath('\\\\node\\share','\\d1/d2\\','file')", '\\\\node\\share\\d1/d2\\file' ],
175
176[ "Win32->splitdir('')", '' ],
177[ "Win32->splitdir('\\d1/d2\\d3/')", ',d1,d2,d3,' ],
178[ "Win32->splitdir('d1/d2\\d3/')", 'd1,d2,d3,' ],
179[ "Win32->splitdir('\\d1/d2\\d3')", ',d1,d2,d3' ],
180[ "Win32->splitdir('d1/d2\\d3')", 'd1,d2,d3' ],
181
182[ "Win32->catdir()", '' ],
183[ "Win32->catdir('')", '\\' ],
184[ "Win32->catdir('/')", '\\' ],
638113eb
JH
185[ "Win32->catdir('/', '../')", '\\' ],
186[ "Win32->catdir('/', '..\\')", '\\' ],
187[ "Win32->catdir('\\', '../')", '\\' ],
188[ "Win32->catdir('\\', '..\\')", '\\' ],
0994714a 189[ "Win32->catdir('//d1','d2')", '\\\\d1\\d2' ],
e021ab8e
JH
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' ],
bf7c0a3d
SP
194[ "Win32->catdir('','/d1','d2')", '\\d1\\d2' ],
195[ "Win32->catdir('','','/d1','d2')", '\\d1\\d2' ],
196[ "Win32->catdir('','//d1','d2')", '\\d1\\d2' ],
197[ "Win32->catdir('','','//d1','d2')", '\\d1\\d2' ],
0994714a
GS
198[ "Win32->catdir('','d1','','d2','')", '\\d1\\d2' ],
199[ "Win32->catdir('','d1','d2','d3','')", '\\d1\\d2\\d3' ],
200[ "Win32->catdir('d1','d2','d3','')", 'd1\\d2\\d3' ],
201[ "Win32->catdir('','d1','d2','d3')", '\\d1\\d2\\d3' ],
202[ "Win32->catdir('d1','d2','d3')", 'd1\\d2\\d3' ],
203[ "Win32->catdir('A:/d1','d2','d3')", 'A:\\d1\\d2\\d3' ],
204[ "Win32->catdir('A:/d1','d2','d3','')", 'A:\\d1\\d2\\d3' ],
205#[ "Win32->catdir('A:/d1','B:/d2','d3','')", 'A:\\d1\\d2\\d3' ],
206[ "Win32->catdir('A:/d1','B:/d2','d3','')", 'A:\\d1\\B:\\d2\\d3' ],
207[ "Win32->catdir('A:/')", 'A:\\' ],
638113eb 208[ "Win32->catdir('\\', 'foo')", '\\foo' ],
bf7c0a3d 209[ "Win32->catdir('','','..')", '\\' ],
795ee885 210[ "Win32->catdir('A:', 'foo')", 'A:\\foo' ],
c47834cd 211
02961b52
MS
212[ "Win32->catfile('a','b','c')", 'a\\b\\c' ],
213[ "Win32->catfile('a','b','.\\c')", 'a\\b\\c' ],
214[ "Win32->catfile('.\\a','b','c')", 'a\\b\\c' ],
215[ "Win32->catfile('c')", 'c' ],
216[ "Win32->catfile('.\\c')", 'c' ],
bf7c0a3d 217[ "Win32->catfile('a/..','../b')", '..\\b' ],
795ee885 218[ "Win32->catfile('A:', 'foo')", 'A:\\foo' ],
02961b52 219
0994714a
GS
220
221[ "Win32->canonpath('')", '' ],
222[ "Win32->canonpath('a:')", 'A:' ],
223[ "Win32->canonpath('A:f')", 'A:f' ],
638113eb 224[ "Win32->canonpath('A:/')", 'A:\\' ],
9596c75c
RGS
225# rt.perl.org 27052
226[ "Win32->canonpath('a\\..\\..\\b\\c')", '..\\b\\c' ],
0994714a
GS
227[ "Win32->canonpath('//a\\b//c')", '\\\\a\\b\\c' ],
228[ "Win32->canonpath('/a/..../c')", '\\a\\....\\c' ],
229[ "Win32->canonpath('//a/b\\c')", '\\\\a\\b\\c' ],
bf7c0a3d 230[ "Win32->canonpath('////')", '\\' ],
0994714a 231[ "Win32->canonpath('//')", '\\' ],
bf7c0a3d 232[ "Win32->canonpath('/.')", '\\' ],
cc23144f
IS
233[ "Win32->canonpath('//a/b/../../c')", '\\\\a\\b\\c' ],
234[ "Win32->canonpath('//a/b/c/../d')", '\\\\a\\b\\d' ],
235[ "Win32->canonpath('//a/b/c/../../d')",'\\\\a\\b\\d' ],
236[ "Win32->canonpath('//a/b/c/.../d')", '\\\\a\\b\\d' ],
237[ "Win32->canonpath('/a/b/c/../../d')", '\\a\\d' ],
238[ "Win32->canonpath('/a/b/c/.../d')", '\\a\\d' ],
e021ab8e 239[ "Win32->canonpath('\\../temp\\')", '\\temp' ],
638113eb
JH
240[ "Win32->canonpath('\\../')", '\\' ],
241[ "Win32->canonpath('\\..\\')", '\\' ],
242[ "Win32->canonpath('/../')", '\\' ],
243[ "Win32->canonpath('/..\\')", '\\' ],
c47834cd
RGS
244[ "Win32->canonpath('d1/../foo')", 'foo' ],
245
4fdb5a70 246[ "Win32->can('_cwd')", '/CODE/' ],
e021ab8e 247
5b287435 248# FakeWin32 subclass (see below) just sets CWD to C:\one\two and getdcwd('D') to D:\alpha\beta
e021ab8e 249
9d5071ba 250[ "FakeWin32->abs2rel('/t1/t2/t3','/t1/t2/t3')", '.' ],
e021ab8e
JH
251[ "FakeWin32->abs2rel('/t1/t2/t4','/t1/t2/t3')", '..\\t4' ],
252[ "FakeWin32->abs2rel('/t1/t2','/t1/t2/t3')", '..' ],
253[ "FakeWin32->abs2rel('/t1/t2/t3/t4','/t1/t2/t3')", 't4' ],
254[ "FakeWin32->abs2rel('/t4/t5/t6','/t1/t2/t3')", '..\\..\\..\\t4\\t5\\t6' ],
5b287435 255[ "FakeWin32->abs2rel('../t4','/t1/t2/t3')", '..\\..\\..\\one\\t4' ], # Uses _cwd()
e021ab8e
JH
256[ "FakeWin32->abs2rel('/','/t1/t2/t3')", '..\\..\\..' ],
257[ "FakeWin32->abs2rel('///','/t1/t2/t3')", '..\\..\\..' ],
258[ "FakeWin32->abs2rel('/.','/t1/t2/t3')", '..\\..\\..' ],
259[ "FakeWin32->abs2rel('/./','/t1/t2/t3')", '..\\..\\..' ],
260[ "FakeWin32->abs2rel('\\\\a/t1/t2/t4','/t2/t3')", '\\\\a\\t1\\t2\\t4' ],
261[ "FakeWin32->abs2rel('//a/t1/t2/t4','/t2/t3')", '\\\\a\\t1\\t2\\t4' ],
9d5071ba 262[ "FakeWin32->abs2rel('A:/t1/t2/t3','A:/t1/t2/t3')", '.' ],
e021ab8e
JH
263[ "FakeWin32->abs2rel('A:/t1/t2/t3/t4','A:/t1/t2/t3')", 't4' ],
264[ "FakeWin32->abs2rel('A:/t1/t2/t3','A:/t1/t2/t3/t4')", '..' ],
265[ "FakeWin32->abs2rel('A:/t1/t2/t3','B:/t1/t2/t3')", 'A:\\t1\\t2\\t3' ],
266[ "FakeWin32->abs2rel('A:/t1/t2/t3/t4','B:/t1/t2/t3')", 'A:\\t1\\t2\\t3\\t4' ],
267[ "FakeWin32->abs2rel('E:/foo/bar/baz')", 'E:\\foo\\bar\\baz' ],
268[ "FakeWin32->abs2rel('C:/one/two/three')", 'three' ],
fa52125f
SP
269[ "FakeWin32->abs2rel('C:\\Windows\\System32', 'C:\\')", 'Windows\System32' ],
270[ "FakeWin32->abs2rel('\\\\computer2\\share3\\foo.txt', '\\\\computer2\\share3')", 'foo.txt' ],
110c90cc 271[ "FakeWin32->abs2rel('C:\\one\\two\\t\\asd1\\', 't\\asd\\')", '..\\asd1' ],
81a4c762 272[ "FakeWin32->abs2rel('\\one\\two', 'A:\\foo')", 'C:\\one\\two' ],
e021ab8e
JH
273
274[ "FakeWin32->rel2abs('temp','C:/')", 'C:\\temp' ],
275[ "FakeWin32->rel2abs('temp','C:/a')", 'C:\\a\\temp' ],
276[ "FakeWin32->rel2abs('temp','C:/a/')", 'C:\\a\\temp' ],
277[ "FakeWin32->rel2abs('../','C:/')", 'C:\\' ],
278[ "FakeWin32->rel2abs('../','C:/a')", 'C:\\' ],
110c90cc 279[ "FakeWin32->rel2abs('\\foo','C:/a')", 'C:\\foo' ],
e021ab8e
JH
280[ "FakeWin32->rel2abs('temp','//prague_main/work/')", '\\\\prague_main\\work\\temp' ],
281[ "FakeWin32->rel2abs('../temp','//prague_main/work/')", '\\\\prague_main\\work\\temp' ],
282[ "FakeWin32->rel2abs('temp','//prague_main/work')", '\\\\prague_main\\work\\temp' ],
283[ "FakeWin32->rel2abs('../','//prague_main/work')", '\\\\prague_main\\work' ],
c1e8580e 284[ "FakeWin32->rel2abs('D:foo.txt')", 'D:\\alpha\\beta\\foo.txt' ],
e021ab8e
JH
285
286[ "VMS->case_tolerant()", '1' ],
02961b52
MS
287
288[ "VMS->catfile('a','b','c')", '[.a.b]c' ],
289[ "VMS->catfile('a','b','[]c')", '[.a.b]c' ],
290[ "VMS->catfile('[.a]','b','c')", '[.a.b]c' ],
291[ "VMS->catfile('c')", 'c' ],
292[ "VMS->catfile('[]c')", 'c' ],
293
ff235dd6
SP
294[ "VMS->catfile('0','b','c')", '[.0.b]c' ],
295[ "VMS->catfile('a','0','c')", '[.a.0]c' ],
296[ "VMS->catfile('a','b','0')", '[.a.b]0' ],
297[ "VMS->catfile('0','0','c')", '[.0.0]c' ],
298[ "VMS->catfile('a','0','0')", '[.a.0]0' ],
299[ "VMS->catfile('0','b','0')", '[.0.b]0' ],
300[ "VMS->catfile('0','0','0')", '[.0.0]0' ],
301
302
0994714a 303[ "VMS->splitpath('file')", ',,file' ],
08c7cbbb
GS
304[ "VMS->splitpath('[d1.d2.d3]')", ',[d1.d2.d3],' ],
305[ "VMS->splitpath('[.d1.d2.d3]')", ',[.d1.d2.d3],' ],
306[ "VMS->splitpath('[d1.d2.d3]file')", ',[d1.d2.d3],file' ],
307[ "VMS->splitpath('d1/d2/d3/file')", ',[.d1.d2.d3],file' ],
308[ "VMS->splitpath('/d1/d2/d3/file')", 'd1:,[d2.d3],file' ],
309[ "VMS->splitpath('[.d1.d2.d3]file')", ',[.d1.d2.d3],file' ],
310[ "VMS->splitpath('node::volume:[d1.d2.d3]')", 'node::volume:,[d1.d2.d3],' ],
311[ "VMS->splitpath('node::volume:[d1.d2.d3]file')", 'node::volume:,[d1.d2.d3],file' ],
312[ "VMS->splitpath('node\"access_spec\"::volume:[d1.d2.d3]')", 'node"access_spec"::volume:,[d1.d2.d3],' ],
313[ "VMS->splitpath('node\"access_spec\"::volume:[d1.d2.d3]file')", 'node"access_spec"::volume:,[d1.d2.d3],file' ],
0994714a 314
486bcc50
NC
315[ "VMS->splitpath('[]')", ',[],' ],
316[ "VMS->splitpath('[-]')", ',[-],' ],
317[ "VMS->splitpath('[]file')", ',[],file' ],
318[ "VMS->splitpath('[-]file')", ',[-],file' ],
319[ "VMS->splitpath('')", ',,' ],
320[ "VMS->splitpath('0')", ',,0' ],
321[ "VMS->splitpath('[0]')", ',[0],' ],
322[ "VMS->splitpath('[.0]')", ',[.0],' ],
323[ "VMS->splitpath('[0.0.0]')", ',[0.0.0],' ],
324[ "VMS->splitpath('[.0.0.0]')", ',[.0.0.0],' ],
325[ "VMS->splitpath('[0]0')", ',[0],0' ],
326[ "VMS->splitpath('[0.0.0]0')", ',[0.0.0],0' ],
327[ "VMS->splitpath('[.0.0.0]0')", ',[.0.0.0],0' ],
328[ "VMS->splitpath('0/0')", ',[.0],0' ],
329[ "VMS->splitpath('0/0/0')", ',[.0.0],0' ],
330[ "VMS->splitpath('/0/0')", '0:,[000000],0' ],
331[ "VMS->splitpath('/0/0/0')", '0:,[0],0' ],
332[ "VMS->splitpath('d1',1)", ',d1,' ],
333# $no_file tests
334[ "VMS->splitpath('[d1.d2.d3]',1)", ',[d1.d2.d3],' ],
335[ "VMS->splitpath('[.d1.d2.d3]',1)", ',[.d1.d2.d3],' ],
336[ "VMS->splitpath('d1/d2/d3',1)", ',[.d1.d2.d3],' ],
337[ "VMS->splitpath('/d1/d2/d3',1)", 'd1:,[d2.d3],' ],
338[ "VMS->splitpath('node::volume:[d1.d2.d3]',1)", 'node::volume:,[d1.d2.d3],' ],
339[ "VMS->splitpath('node\"access_spec\"::volume:[d1.d2.d3]',1)", 'node"access_spec"::volume:,[d1.d2.d3],' ],
340[ "VMS->splitpath('[]',1)", ',[],' ],
341[ "VMS->splitpath('[-]',1)", ',[-],' ],
342[ "VMS->splitpath('',1)", ',,' ],
343[ "VMS->splitpath('0',1)", ',0,' ],
344[ "VMS->splitpath('[0]',1)", ',[0],' ],
345[ "VMS->splitpath('[.0]',1)", ',[.0],' ],
346[ "VMS->splitpath('[0.0.0]',1)", ',[0.0.0],' ],
347[ "VMS->splitpath('[.0.0.0]',1)", ',[.0.0.0],' ],
348[ "VMS->splitpath('0/0',1)", ',[.0.0],' ],
349[ "VMS->splitpath('0/0/0',1)", ',[.0.0.0],' ],
350[ "VMS->splitpath('/0/0',1)", '0:,[000000.0],' ],
351[ "VMS->splitpath('/0/0/0',1)", '0:,[0.0],' ],
352
0994714a
GS
353[ "VMS->catpath('','','file')", 'file' ],
354[ "VMS->catpath('','[d1.d2.d3]','')", '[d1.d2.d3]' ],
355[ "VMS->catpath('','[.d1.d2.d3]','')", '[.d1.d2.d3]' ],
356[ "VMS->catpath('','[d1.d2.d3]','file')", '[d1.d2.d3]file' ],
357[ "VMS->catpath('','[.d1.d2.d3]','file')", '[.d1.d2.d3]file' ],
08c7cbbb
GS
358[ "VMS->catpath('','d1/d2/d3','file')", '[.d1.d2.d3]file' ],
359[ "VMS->catpath('v','d1/d2/d3','file')", 'v:[.d1.d2.d3]file' ],
638113eb 360[ "VMS->catpath('v','w:[d1.d2.d3]','file')", 'v:[d1.d2.d3]file' ],
0994714a
GS
361[ "VMS->catpath('node::volume:','[d1.d2.d3]','')", 'node::volume:[d1.d2.d3]' ],
362[ "VMS->catpath('node::volume:','[d1.d2.d3]','file')", 'node::volume:[d1.d2.d3]file' ],
363[ "VMS->catpath('node\"access_spec\"::volume:','[d1.d2.d3]','')", 'node"access_spec"::volume:[d1.d2.d3]' ],
364[ "VMS->catpath('node\"access_spec\"::volume:','[d1.d2.d3]','file')", 'node"access_spec"::volume:[d1.d2.d3]file' ],
365
366[ "VMS->canonpath('')", '' ],
178326fd 367[ "VMS->canonpath('volume:[d1]file')", 'volume:[d1]file' ],
08c7cbbb 368[ "VMS->canonpath('volume:[d1.-.d2.][d3.d4.-]')", 'volume:[d2.d3]' ],
178326fd 369[ "VMS->canonpath('volume:[000000.d1]d2.dir;1')", 'volume:[d1]d2.dir;1' ],
bdc74e5c
CB
370[ "VMS->canonpath('volume:[d1.d2.d3]file.txt')", 'volume:[d1.d2.d3]file.txt' ],
371[ "VMS->canonpath('[d1.d2.d3]file.txt')", '[d1.d2.d3]file.txt' ],
372[ "VMS->canonpath('volume:[-.d1.d2.d3]file.txt')", 'volume:[-.d1.d2.d3]file.txt' ],
373[ "VMS->canonpath('[-.d1.d2.d3]file.txt')", '[-.d1.d2.d3]file.txt' ],
374[ "VMS->canonpath('volume:[--.d1.d2.d3]file.txt')", 'volume:[--.d1.d2.d3]file.txt' ],
375[ "VMS->canonpath('[--.d1.d2.d3]file.txt')", '[--.d1.d2.d3]file.txt' ],
376[ "VMS->canonpath('volume:[d1.-.d2.d3]file.txt')", 'volume:[d2.d3]file.txt' ],
377[ "VMS->canonpath('[d1.-.d2.d3]file.txt')", '[d2.d3]file.txt' ],
378[ "VMS->canonpath('volume:[d1.--.d2.d3]file.txt')", 'volume:[-.d2.d3]file.txt' ],
379[ "VMS->canonpath('[d1.--.d2.d3]file.txt')", '[-.d2.d3]file.txt' ],
380[ "VMS->canonpath('volume:[d1.d2.-.d3]file.txt')", 'volume:[d1.d3]file.txt' ],
381[ "VMS->canonpath('[d1.d2.-.d3]file.txt')", '[d1.d3]file.txt' ],
382[ "VMS->canonpath('volume:[d1.d2.--.d3]file.txt')", 'volume:[d3]file.txt' ],
383[ "VMS->canonpath('[d1.d2.--.d3]file.txt')", '[d3]file.txt' ],
384[ "VMS->canonpath('volume:[d1.d2.d3.-]file.txt')", 'volume:[d1.d2]file.txt' ],
385[ "VMS->canonpath('[d1.d2.d3.-]file.txt')", '[d1.d2]file.txt' ],
386[ "VMS->canonpath('volume:[d1.d2.d3.--]file.txt')", 'volume:[d1]file.txt' ],
387[ "VMS->canonpath('[d1.d2.d3.--]file.txt')", '[d1]file.txt' ],
388[ "VMS->canonpath('volume:[d1.000000.][000000.][d3.--]file.txt')", 'volume:[d1]file.txt' ],
389[ "VMS->canonpath('[d1.000000.][000000.][d3.--]file.txt')", '[d1]file.txt' ],
390[ "VMS->canonpath('volume:[d1.000000.][000000.][d2.000000]file.txt')", 'volume:[d1.000000.d2.000000]file.txt' ],
391[ "VMS->canonpath('[d1.000000.][000000.][d2.000000]file.txt')", '[d1.000000.d2.000000]file.txt' ],
392[ "VMS->canonpath('volume:[d1.000000.][000000.][d3.--.000000]file.txt')",'volume:[d1.000000]file.txt' ],
393[ "VMS->canonpath('[d1.000000.][000000.][d3.--.000000]file.txt')", '[d1.000000]file.txt' ],
394[ "VMS->canonpath('volume:[d1.000000.][000000.][-.-.000000]file.txt')", 'volume:[000000]file.txt' ],
395[ "VMS->canonpath('[d1.000000.][000000.][--.-.000000]file.txt')", '[-.000000]file.txt' ],
99f36a73 396[ "VMS->canonpath('[d1.d2.--]file')", '[000000]file' ],
0994714a
GS
397
398[ "VMS->splitdir('')", '' ],
399[ "VMS->splitdir('[]')", '' ],
400[ "VMS->splitdir('d1.d2.d3')", 'd1,d2,d3' ],
401[ "VMS->splitdir('[d1.d2.d3]')", 'd1,d2,d3' ],
2e74f398
CB
402[ "VMS->splitdir('.d1.d2.d3')", 'd1,d2,d3' ],
403[ "VMS->splitdir('[.d1.d2.d3]')", 'd1,d2,d3' ],
404[ "VMS->splitdir('.-.d2.d3')", '-,d2,d3' ],
405[ "VMS->splitdir('[.-.d2.d3]')", '-,d2,d3' ],
bdc74e5c
CB
406[ "VMS->splitdir('[d1.d2]')", 'd1,d2' ],
407[ "VMS->splitdir('[d1-.--d2]')", 'd1-,--d2' ],
408[ "VMS->splitdir('[d1---.-.d2]')", 'd1---,-,d2' ],
409[ "VMS->splitdir('[d1.---.d2]')", 'd1,-,-,-,d2' ],
410[ "VMS->splitdir('[d1---d2]')", 'd1---d2' ],
411[ "VMS->splitdir('[d1.][000000.d2]')", 'd1,d2' ],
2e74f398 412[ "VMS->splitdir('[.d1.d2^.d3]')", 'd1,d2^.d3' ],
0994714a 413
08c7cbbb
GS
414[ "VMS->catdir('')", '' ],
415[ "VMS->catdir('d1','d2','d3')", '[.d1.d2.d3]' ],
416[ "VMS->catdir('d1','d2/','d3')", '[.d1.d2.d3]' ],
417[ "VMS->catdir('','d1','d2','d3')", '[.d1.d2.d3]' ],
418[ "VMS->catdir('','-','d2','d3')", '[-.d2.d3]' ],
419[ "VMS->catdir('','-','','d3')", '[-.d3]' ],
420[ "VMS->catdir('dir.dir','d2.dir','d3.dir')", '[.dir.d2.d3]' ],
421[ "VMS->catdir('[.name]')", '[.name]' ],
45657e91 422[ "VMS->catdir('[.name]','[.name]')", '[.name.name]'],
0994714a 423
9d5071ba 424[ "VMS->abs2rel('node::volume:[t1.t2.t3]','node::volume:[t1.t2.t3]')", '[]' ],
cda9bddd 425[ "VMS->abs2rel('node::volume:[t1.t2.t3]','[t1.t2.t3]')", 'node::volume:[t1.t2.t3]' ],
416c0615 426[ "VMS->abs2rel('node::volume:[t1.t2.t4]','node::volume:[t1.t2.t3]')", '[-.t4]' ],
cda9bddd 427[ "VMS->abs2rel('node::volume:[t1.t2.t4]','[t1.t2.t3]')", 'node::volume:[t1.t2.t4]' ],
9d5071ba 428[ "VMS->abs2rel('[t1.t2.t3]','[t1.t2.t3]')", '[]' ],
0994714a 429[ "VMS->abs2rel('[t1.t2.t3]file','[t1.t2.t3]')", 'file' ],
638113eb
JH
430[ "VMS->abs2rel('[t1.t2.t3]file','[t1.t2]')", '[.t3]file' ],
431[ "VMS->abs2rel('v:[t1.t2.t3]file','v:[t1.t2]')", '[.t3]file' ],
0994714a
GS
432[ "VMS->abs2rel('[t1.t2.t4]','[t1.t2.t3]')", '[-.t4]' ],
433[ "VMS->abs2rel('[t1.t2]file','[t1.t2.t3]')", '[-]file' ],
638113eb 434[ "VMS->abs2rel('[t1.t2.t3.t4]','[t1.t2.t3]')", '[.t4]' ],
08c7cbbb 435[ "VMS->abs2rel('[t4.t5.t6]','[t1.t2.t3]')", '[---.t4.t5.t6]' ],
737c380e 436[ "VMS->abs2rel('[000000]','[t1.t2.t3]')", '[---]' ],
9d5071ba 437[ "VMS->abs2rel('a:[t1.t2.t4]','a:[t1.t2.t3]')", '[-.t4]' ],
cda9bddd 438[ "VMS->abs2rel('a:[t1.t2.t4]','[t1.t2.t3]')", 'a:[t1.t2.t4]' ],
08c7cbbb 439[ "VMS->abs2rel('[a.-.b.c.-]','[t1.t2.t3]')", '[---.b]' ],
270d1e39 440
0994714a
GS
441[ "VMS->rel2abs('[.t4]','[t1.t2.t3]')", '[t1.t2.t3.t4]' ],
442[ "VMS->rel2abs('[.t4.t5]','[t1.t2.t3]')", '[t1.t2.t3.t4.t5]' ],
443[ "VMS->rel2abs('[]','[t1.t2.t3]')", '[t1.t2.t3]' ],
08c7cbbb
GS
444[ "VMS->rel2abs('[-]','[t1.t2.t3]')", '[t1.t2]' ],
445[ "VMS->rel2abs('[-.t4]','[t1.t2.t3]')", '[t1.t2.t4]' ],
0994714a 446[ "VMS->rel2abs('[t1]','[t1.t2.t3]')", '[t1]' ],
270d1e39 447
e021ab8e
JH
448[ "OS2->case_tolerant()", '1' ],
449
0994714a 450[ "OS2->catdir('A:/d1','B:/d2','d3','')", 'A:/d1/B:/d2/d3' ],
02961b52 451
0994714a 452[ "OS2->catfile('a','b','c')", 'a/b/c' ],
02961b52
MS
453[ "OS2->catfile('a','b','./c')", 'a/b/c' ],
454[ "OS2->catfile('./a','b','c')", 'a/b/c' ],
455[ "OS2->catfile('c')", 'c' ],
456[ "OS2->catfile('./c')", 'c' ],
0994714a 457
638113eb
JH
458[ "OS2->catdir('/', '../')", '/' ],
459[ "OS2->catdir('/', '..\\')", '/' ],
460[ "OS2->catdir('\\', '../')", '/' ],
461[ "OS2->catdir('\\', '..\\')", '/' ],
462
e021ab8e 463[ "Mac->case_tolerant()", '1' ],
be708cc0
JH
464
465[ "Mac->catpath('','','')", '' ],
466[ "Mac->catpath('',':','')", ':' ],
467[ "Mac->catpath('','::','')", '::' ],
468
469[ "Mac->catpath('hd','','')", 'hd:' ],
470[ "Mac->catpath('hd:','','')", 'hd:' ],
45657e91 471[ "Mac->catpath('hd:',':','')", 'hd:' ],
be708cc0
JH
472[ "Mac->catpath('hd:','::','')", 'hd::' ],
473
474[ "Mac->catpath('hd','','file')", 'hd:file' ],
475[ "Mac->catpath('hd',':','file')", 'hd:file' ],
476[ "Mac->catpath('hd','::','file')", 'hd::file' ],
477[ "Mac->catpath('hd',':::','file')", 'hd:::file' ],
478
479[ "Mac->catpath('hd:','',':file')", 'hd:file' ],
480[ "Mac->catpath('hd:',':',':file')", 'hd:file' ],
481[ "Mac->catpath('hd:','::',':file')", 'hd::file' ],
482[ "Mac->catpath('hd:',':::',':file')", 'hd:::file' ],
483
484[ "Mac->catpath('hd:','d1','file')", 'hd:d1:file' ],
485[ "Mac->catpath('hd:',':d1:',':file')", 'hd:d1:file' ],
638113eb 486[ "Mac->catpath('hd:','hd:d1','')", 'hd:d1:' ],
be708cc0
JH
487
488[ "Mac->catpath('','d1','')", ':d1:' ],
489[ "Mac->catpath('',':d1','')", ':d1:' ],
490[ "Mac->catpath('',':d1:','')", ':d1:' ],
491
492[ "Mac->catpath('','d1','file')", ':d1:file' ],
493[ "Mac->catpath('',':d1:',':file')", ':d1:file' ],
494
495[ "Mac->catpath('','','file')", 'file' ],
496[ "Mac->catpath('','',':file')", 'file' ], # !
497[ "Mac->catpath('',':',':file')", ':file' ], # !
498
499
500[ "Mac->splitpath(':')", ',:,' ],
501[ "Mac->splitpath('::')", ',::,' ],
502[ "Mac->splitpath(':::')", ',:::,' ],
503
504[ "Mac->splitpath('file')", ',,file' ],
505[ "Mac->splitpath(':file')", ',:,file' ],
506
507[ "Mac->splitpath('d1',1)", ',:d1:,' ], # dir, not volume
508[ "Mac->splitpath(':d1',1)", ',:d1:,' ],
509[ "Mac->splitpath(':d1:',1)", ',:d1:,' ],
510[ "Mac->splitpath(':d1:')", ',:d1:,' ],
511[ "Mac->splitpath(':d1:d2:d3:')", ',:d1:d2:d3:,' ],
512[ "Mac->splitpath(':d1:d2:d3:',1)", ',:d1:d2:d3:,' ],
513[ "Mac->splitpath(':d1:file')", ',:d1:,file' ],
514[ "Mac->splitpath('::d1:file')", ',::d1:,file' ],
515
516[ "Mac->splitpath('hd:', 1)", 'hd:,,' ],
517[ "Mac->splitpath('hd:')", 'hd:,,' ],
518[ "Mac->splitpath('hd:d1:d2:')", 'hd:,:d1:d2:,' ],
519[ "Mac->splitpath('hd:d1:d2',1)", 'hd:,:d1:d2:,' ],
520[ "Mac->splitpath('hd:d1:d2:file')", 'hd:,:d1:d2:,file' ],
521[ "Mac->splitpath('hd:d1:d2::file')", 'hd:,:d1:d2::,file' ],
522[ "Mac->splitpath('hd::d1:d2:file')", 'hd:,::d1:d2:,file' ], # invalid path
523[ "Mac->splitpath('hd:file')", 'hd:,,file' ],
524
2586ba89 525[ "Mac->splitdir()", '' ],
be708cc0
JH
526[ "Mac->splitdir('')", '' ],
527[ "Mac->splitdir(':')", ':' ],
528[ "Mac->splitdir('::')", '::' ],
2586ba89
JH
529[ "Mac->splitdir(':::')", '::,::' ],
530[ "Mac->splitdir(':::d1:d2')", '::,::,d1,d2' ],
531
532[ "Mac->splitdir(':d1:d2:d3::')", 'd1,d2,d3,::'],
533[ "Mac->splitdir(':d1:d2:d3:')", 'd1,d2,d3' ],
534[ "Mac->splitdir(':d1:d2:d3')", 'd1,d2,d3' ],
535
536# absolute paths in splitdir() work, but you'd better use splitpath()
537[ "Mac->splitdir('hd:')", 'hd:' ],
538[ "Mac->splitdir('hd::')", 'hd:,::' ], # invalid path, but it works
539[ "Mac->splitdir('hd::d1:')", 'hd:,::,d1' ], # invalid path, but it works
540[ "Mac->splitdir('hd:d1:d2:::')", 'hd:,d1,d2,::,::' ],
541[ "Mac->splitdir('hd:d1:d2::')", 'hd:,d1,d2,::' ],
542[ "Mac->splitdir('hd:d1:d2:')", 'hd:,d1,d2' ],
543[ "Mac->splitdir('hd:d1:d2')", 'hd:,d1,d2' ],
544[ "Mac->splitdir('hd:d1::d2::')", 'hd:,d1,::,d2,::' ],
545
546[ "Mac->catdir()", '' ],
547[ "Mac->catdir('')", $root, 'MacOS' ], # skipped on other OS
548[ "Mac->catdir(':')", ':' ],
549
550[ "Mac->catdir('', '')", $root, 'MacOS' ], # skipped on other OS
45657e91
JH
551[ "Mac->catdir('', ':')", $root, 'MacOS' ], # skipped on other OS
552[ "Mac->catdir(':', ':')", ':' ],
553[ "Mac->catdir(':', '')", ':' ],
2586ba89
JH
554
555[ "Mac->catdir('', '::')", $root, 'MacOS' ], # skipped on other OS
45657e91 556[ "Mac->catdir(':', '::')", '::' ],
2586ba89 557
45657e91
JH
558[ "Mac->catdir('::', '')", '::' ],
559[ "Mac->catdir('::', ':')", '::' ],
2586ba89 560
45657e91 561[ "Mac->catdir('::', '::')", ':::' ],
2586ba89
JH
562
563[ "Mac->catdir(':d1')", ':d1:' ],
564[ "Mac->catdir(':d1:')", ':d1:' ],
565[ "Mac->catdir(':d1','d2')", ':d1:d2:' ],
566[ "Mac->catdir(':d1',':d2')", ':d1:d2:' ],
567[ "Mac->catdir(':d1',':d2:')", ':d1:d2:' ],
568[ "Mac->catdir(':d1',':d2::')", ':d1:d2::' ],
569[ "Mac->catdir(':',':d1',':d2')", ':d1:d2:' ],
570[ "Mac->catdir('::',':d1',':d2')", '::d1:d2:' ],
571[ "Mac->catdir('::','::',':d1',':d2')", ':::d1:d2:' ],
572[ "Mac->catdir(':',':',':d1',':d2')", ':d1:d2:' ],
573[ "Mac->catdir('::',':',':d1',':d2')", '::d1:d2:' ],
574
575[ "Mac->catdir('d1')", ':d1:' ],
576[ "Mac->catdir('d1','d2','d3')", ':d1:d2:d3:' ],
577[ "Mac->catdir('d1','d2/','d3')", ':d1:d2/:d3:' ],
578[ "Mac->catdir('d1','',':d2')", ':d1:d2:' ],
579[ "Mac->catdir('d1',':',':d2')", ':d1:d2:' ],
580[ "Mac->catdir('d1','::',':d2')", ':d1::d2:' ],
581[ "Mac->catdir('d1',':::',':d2')", ':d1:::d2:' ],
582[ "Mac->catdir('d1','::','::',':d2')", ':d1:::d2:' ],
583[ "Mac->catdir('d1','d2')", ':d1:d2:' ],
584[ "Mac->catdir('d1','d2', '')", ':d1:d2:' ],
585[ "Mac->catdir('d1','d2', ':')", ':d1:d2:' ],
586[ "Mac->catdir('d1','d2', '::')", ':d1:d2::' ],
587[ "Mac->catdir('d1','d2','','')", ':d1:d2:' ],
588[ "Mac->catdir('d1','d2',':','::')", ':d1:d2::' ],
589[ "Mac->catdir('d1','d2','::','::')", ':d1:d2:::' ],
590[ "Mac->catdir('d1',':d2')", ':d1:d2:' ],
591[ "Mac->catdir('d1',':d2:')", ':d1:d2:' ],
592
593[ "Mac->catdir('','d1','d2','d3')", $root . 'd1:d2:d3:', 'MacOS' ], # skipped on other OS
594[ "Mac->catdir('',':','d1','d2')", $root . 'd1:d2:' , 'MacOS' ], # skipped on other OS
595[ "Mac->catdir('','::','d1','d2')", $root . 'd1:d2:' , 'MacOS' ], # skipped on other OS
596[ "Mac->catdir('',':','','d1')", $root . 'd1:' , 'MacOS' ], # skipped on other OS
597[ "Mac->catdir('', ':d1',':d2')", $root . 'd1:d2:' , 'MacOS' ], # skipped on other OS
598[ "Mac->catdir('','',':d1',':d2')", $root . 'd1:d2:' , 'MacOS' ], # skipped on other OS
be708cc0 599
be708cc0
JH
600[ "Mac->catdir('hd:',':d1')", 'hd:d1:' ],
601[ "Mac->catdir('hd:d1:',':d2')", 'hd:d1:d2:' ],
602[ "Mac->catdir('hd:','d1')", 'hd:d1:' ],
be708cc0
JH
603[ "Mac->catdir('hd:d1:',':d2')", 'hd:d1:d2:' ],
604[ "Mac->catdir('hd:d1:',':d2:')", 'hd:d1:d2:' ],
605
45657e91 606[ "Mac->catfile()", '' ],
2586ba89 607[ "Mac->catfile('')", '' ],
45657e91 608[ "Mac->catfile('', '')", $root , 'MacOS' ], # skipped on other OS
2586ba89
JH
609[ "Mac->catfile('', 'file')", $root . 'file', 'MacOS' ], # skipped on other OS
610[ "Mac->catfile(':')", ':' ],
611[ "Mac->catfile(':', '')", ':' ],
be708cc0 612
2586ba89
JH
613[ "Mac->catfile('d1','d2','file')", ':d1:d2:file' ],
614[ "Mac->catfile('d1','d2',':file')", ':d1:d2:file' ],
45657e91
JH
615[ "Mac->catfile('file')", 'file' ],
616[ "Mac->catfile(':', 'file')", ':file' ],
617
0994714a
GS
618[ "Mac->canonpath('')", '' ],
619[ "Mac->canonpath(':')", ':' ],
620[ "Mac->canonpath('::')", '::' ],
621[ "Mac->canonpath('a::')", 'a::' ],
622[ "Mac->canonpath(':a::')", ':a::' ],
623
be708cc0
JH
624[ "Mac->abs2rel('hd:d1:d2:','hd:d1:d2:')", ':' ],
625[ "Mac->abs2rel('hd:d1:d2:','hd:d1:d2:file')", ':' ], # ignore base's file portion
45657e91 626[ "Mac->abs2rel('hd:d1:d2:file','hd:d1:d2:')", ':file' ],
be708cc0
JH
627[ "Mac->abs2rel('hd:d1:','hd:d1:d2:')", '::' ],
628[ "Mac->abs2rel('hd:d3:','hd:d1:d2:')", ':::d3:' ],
629[ "Mac->abs2rel('hd:d3:','hd:d1:d2::')", '::d3:' ],
630[ "Mac->abs2rel('hd:d1:d4:d5:','hd:d1::d2:d3::')", '::d1:d4:d5:' ],
631[ "Mac->abs2rel('hd:d1:d4:d5:','hd:d1::d2:d3:')", ':::d1:d4:d5:' ], # first, resolve updirs in base
632[ "Mac->abs2rel('hd:d1:d3:','hd:d1:d2:')", '::d3:' ],
633[ "Mac->abs2rel('hd:d1::d3:','hd:d1:d2:')", ':::d3:' ],
634[ "Mac->abs2rel('hd:d3:','hd:d1:d2:')", ':::d3:' ], # same as above
635[ "Mac->abs2rel('hd:d1:d2:d3:','hd:d1:d2:')", ':d3:' ],
636[ "Mac->abs2rel('hd:d1:d2:d3::','hd:d1:d2:')", ':d3::' ],
638113eb 637[ "Mac->abs2rel('hd1:d3:d4:d5:','hd2:d1:d2:')", 'hd1:d3:d4:d5:'], # volume mismatch
be708cc0
JH
638[ "Mac->abs2rel('hd:','hd:d1:d2:')", ':::' ],
639
45657e91
JH
640[ "Mac->rel2abs(':d3:','hd:d1:d2:')", 'hd:d1:d2:d3:' ],
641[ "Mac->rel2abs(':d3:d4:','hd:d1:d2:')", 'hd:d1:d2:d3:d4:' ],
be708cc0
JH
642[ "Mac->rel2abs('','hd:d1:d2:')", '' ],
643[ "Mac->rel2abs('::','hd:d1:d2:')", 'hd:d1:d2::' ],
644[ "Mac->rel2abs('::','hd:d1:d2:file')", 'hd:d1:d2::' ],# ignore base's file portion
645[ "Mac->rel2abs(':file','hd:d1:d2:')", 'hd:d1:d2:file' ],
646[ "Mac->rel2abs('::file','hd:d1:d2:')", 'hd:d1:d2::file' ],
647[ "Mac->rel2abs('::d3:','hd:d1:d2:')", 'hd:d1:d2::d3:' ],
648[ "Mac->rel2abs('hd:','hd:d1:d2:')", 'hd:' ], # path already absolute
649[ "Mac->rel2abs('hd:d3:file','hd:d1:d2:')", 'hd:d3:file' ],
650[ "Mac->rel2abs('hd:d3:','hd:d1:file')", 'hd:d3:' ],
e021ab8e
JH
651
652[ "Epoc->case_tolerant()", '1' ],
653
654[ "Epoc->canonpath('')", '' ],
655[ "Epoc->canonpath('///../../..//./././a//b/.././c/././')", '/a/b/../c' ],
656[ "Epoc->canonpath('/./')", '/' ],
657[ "Epoc->canonpath('/a/./')", '/a' ],
658
659# XXX Todo, copied from Unix, but fail. Should they? 2003-07-07 Tels
660#[ "Epoc->canonpath('/a/.')", '/a' ],
661#[ "Epoc->canonpath('/.')", '/' ],
662
8915552c 663[ "Cygwin->case_tolerant()", '1' ],
e4f3fca4
RU
664[ "Cygwin->catfile('a','b','c')", 'a/b/c' ],
665[ "Cygwin->catfile('a','b','./c')", 'a/b/c' ],
666[ "Cygwin->catfile('./a','b','c')", 'a/b/c' ],
667[ "Cygwin->catfile('c')", 'c' ],
668[ "Cygwin->catfile('./c')", 'c' ],
669
670[ "Cygwin->splitpath('file')", ',,file' ],
671[ "Cygwin->splitpath('/d1/d2/d3/')", ',/d1/d2/d3/,' ],
672[ "Cygwin->splitpath('d1/d2/d3/')", ',d1/d2/d3/,' ],
673[ "Cygwin->splitpath('/d1/d2/d3/.')", ',/d1/d2/d3/.,' ],
674[ "Cygwin->splitpath('/d1/d2/d3/..')", ',/d1/d2/d3/..,' ],
675[ "Cygwin->splitpath('/d1/d2/d3/.file')", ',/d1/d2/d3/,.file' ],
676[ "Cygwin->splitpath('d1/d2/d3/file')", ',d1/d2/d3/,file' ],
677[ "Cygwin->splitpath('/../../d1/')", ',/../../d1/,' ],
678[ "Cygwin->splitpath('/././d1/')", ',/././d1/,' ],
679
680[ "Cygwin->catpath('','','file')", 'file' ],
681[ "Cygwin->catpath('','/d1/d2/d3/','')", '/d1/d2/d3/' ],
682[ "Cygwin->catpath('','d1/d2/d3/','')", 'd1/d2/d3/' ],
683[ "Cygwin->catpath('','/d1/d2/d3/.','')", '/d1/d2/d3/.' ],
684[ "Cygwin->catpath('','/d1/d2/d3/..','')", '/d1/d2/d3/..' ],
685[ "Cygwin->catpath('','/d1/d2/d3/','.file')", '/d1/d2/d3/.file' ],
686[ "Cygwin->catpath('','d1/d2/d3/','file')", 'd1/d2/d3/file' ],
687[ "Cygwin->catpath('','/../../d1/','')", '/../../d1/' ],
688[ "Cygwin->catpath('','/././d1/','')", '/././d1/' ],
689[ "Cygwin->catpath('d1','d2/d3/','')", 'd2/d3/' ],
690[ "Cygwin->catpath('d1','d2','d3/')", 'd2/d3/' ],
691
692[ "Cygwin->splitdir('')", '' ],
693[ "Cygwin->splitdir('/d1/d2/d3/')", ',d1,d2,d3,' ],
694[ "Cygwin->splitdir('d1/d2/d3/')", 'd1,d2,d3,' ],
695[ "Cygwin->splitdir('/d1/d2/d3')", ',d1,d2,d3' ],
696[ "Cygwin->splitdir('d1/d2/d3')", 'd1,d2,d3' ],
697
698[ "Cygwin->catdir()", '' ],
699[ "Cygwin->catdir('/')", '/' ],
700[ "Cygwin->catdir('','d1','d2','d3','')", '/d1/d2/d3' ],
701[ "Cygwin->catdir('d1','d2','d3','')", 'd1/d2/d3' ],
702[ "Cygwin->catdir('','d1','d2','d3')", '/d1/d2/d3' ],
703[ "Cygwin->catdir('d1','d2','d3')", 'd1/d2/d3' ],
ff235dd6 704[ "Cygwin->catdir('/','d2/d3')", '/d2/d3' ],
e021ab8e 705
e4f3fca4
RU
706[ "Cygwin->canonpath('///../../..//./././a//b/.././c/././')", '/a/b/../c' ],
707[ "Cygwin->canonpath('')", '' ],
708[ "Cygwin->canonpath('a/../../b/c')", 'a/../../b/c' ],
709[ "Cygwin->canonpath('/.')", '/' ],
710[ "Cygwin->canonpath('/./')", '/' ],
711[ "Cygwin->canonpath('/a/./')", '/a' ],
712[ "Cygwin->canonpath('/a/.')", '/a' ],
713[ "Cygwin->canonpath('/../../')", '/' ],
714[ "Cygwin->canonpath('/../..')", '/' ],
715
716[ "Cygwin->abs2rel('/t1/t2/t3','/t1/t2/t3')", '.' ],
717[ "Cygwin->abs2rel('/t1/t2/t4','/t1/t2/t3')", '../t4' ],
718[ "Cygwin->abs2rel('/t1/t2','/t1/t2/t3')", '..' ],
719[ "Cygwin->abs2rel('/t1/t2/t3/t4','/t1/t2/t3')", 't4' ],
720[ "Cygwin->abs2rel('/t4/t5/t6','/t1/t2/t3')", '../../../t4/t5/t6' ],
721#[ "Cygwin->abs2rel('../t4','/t1/t2/t3')", '../t4' ],
722[ "Cygwin->abs2rel('/','/t1/t2/t3')", '../../..' ],
723[ "Cygwin->abs2rel('///','/t1/t2/t3')", '../../..' ],
724[ "Cygwin->abs2rel('/.','/t1/t2/t3')", '../../..' ],
725[ "Cygwin->abs2rel('/./','/t1/t2/t3')", '../../..' ],
726#[ "Cygwin->abs2rel('../t4','/t1/t2/t3')", '../t4' ],
727[ "Cygwin->abs2rel('/t1/t2/t3', '/')", 't1/t2/t3' ],
728[ "Cygwin->abs2rel('/t1/t2/t3', '/t1')", 't2/t3' ],
729[ "Cygwin->abs2rel('t1/t2/t3', 't1')", 't2/t3' ],
730[ "Cygwin->abs2rel('t1/t2/t3', 't4')", '../t1/t2/t3' ],
731
732[ "Cygwin->rel2abs('t4','/t1/t2/t3')", '/t1/t2/t3/t4' ],
733[ "Cygwin->rel2abs('t4/t5','/t1/t2/t3')", '/t1/t2/t3/t4/t5' ],
734[ "Cygwin->rel2abs('.','/t1/t2/t3')", '/t1/t2/t3' ],
735[ "Cygwin->rel2abs('..','/t1/t2/t3')", '/t1/t2/t3/..' ],
736[ "Cygwin->rel2abs('../t4','/t1/t2/t3')", '/t1/t2/t3/../t4' ],
737[ "Cygwin->rel2abs('/t1','/t1/t2/t3')", '/t1' ],
bf7c0a3d 738[ "Cygwin->rel2abs('//t1/t2/t3','/foo')", '//t1/t2/t3' ],
e4f3fca4 739
0994714a
GS
740) ;
741
5b287435
RGS
742
743
e021ab8e 744plan tests => scalar @tests;
270d1e39 745
e021ab8e 746{
5b287435
RGS
747 package File::Spec::FakeWin32;
748 use vars qw(@ISA);
749 @ISA = qw(File::Spec::Win32);
750
751 sub _cwd { 'C:\\one\\two' }
752
753 # Some funky stuff to override Cwd::getdcwd() for testing purposes,
754 # in the limited scope of the rel2abs() method.
99f36a73 755 if ($Cwd::VERSION && $Cwd::VERSION gt '2.17') { # Avoid a 'used only once' warning
5b287435
RGS
756 local $^W;
757 *rel2abs = sub {
758 my $self = shift;
759 local $^W;
760 local *Cwd::getdcwd = sub {
761 return 'D:\alpha\beta' if $_[0] eq 'D:';
762 return 'C:\one\two' if $_[0] eq 'C:';
763 return;
764 };
765 *Cwd::getdcwd = *Cwd::getdcwd; # Avoid a 'used only once' warning
766 return $self->SUPER::rel2abs(@_);
767 };
768 *rel2abs = *rel2abs; # Avoid a 'used only once' warning
769 }
e021ab8e 770}
0994714a 771
0994714a 772
0994714a
GS
773# Test out the class methods
774for ( @tests ) {
775 tryfunc( @$_ ) ;
270d1e39
GS
776}
777
0994714a 778
0994714a
GS
779#
780# Tries a named function with the given args and compares the result against
781# an expected result. Works with functions that return scalars or arrays.
782#
783sub tryfunc {
784 my $function = shift ;
785 my $expected = shift ;
f6a53ef2
GS
786 my $platform = shift ;
787
788 if ($platform && $^O ne $platform) {
e021ab8e 789 skip("skip $function", 1);
f6a53ef2
GS
790 return;
791 }
0994714a
GS
792
793 $function =~ s#\\#\\\\#g ;
e021ab8e
JH
794 $function =~ s/^([^\$].*->)/File::Spec::$1/;
795 my $got = join ',', eval $function;
0994714a
GS
796
797 if ( $@ ) {
e021ab8e
JH
798 if ( $@ =~ /^\Q$skip_exception/ ) {
799 skip "skip $function: $skip_exception", 1;
800 }
801 else {
802 ok $@, '', $function;
803 }
804 return;
0994714a 805 }
e021ab8e
JH
806
807 ok $got, $expected, $function;
0994714a 808}