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