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