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