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