Code tweaks in sv.c
[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' ],
258
259[ "FakeWin32->rel2abs('temp','C:/')", 'C:\\temp' ],
260[ "FakeWin32->rel2abs('temp','C:/a')", 'C:\\a\\temp' ],
261[ "FakeWin32->rel2abs('temp','C:/a/')", 'C:\\a\\temp' ],
262[ "FakeWin32->rel2abs('../','C:/')", 'C:\\' ],
263[ "FakeWin32->rel2abs('../','C:/a')", 'C:\\' ],
264[ "FakeWin32->rel2abs('temp','//prague_main/work/')", '\\\\prague_main\\work\\temp' ],
265[ "FakeWin32->rel2abs('../temp','//prague_main/work/')", '\\\\prague_main\\work\\temp' ],
266[ "FakeWin32->rel2abs('temp','//prague_main/work')", '\\\\prague_main\\work\\temp' ],
267[ "FakeWin32->rel2abs('../','//prague_main/work')", '\\\\prague_main\\work' ],
268
269[ "VMS->case_tolerant()", '1' ],
02961b52 270
271[ "VMS->catfile('a','b','c')", '[.a.b]c' ],
272[ "VMS->catfile('a','b','[]c')", '[.a.b]c' ],
273[ "VMS->catfile('[.a]','b','c')", '[.a.b]c' ],
274[ "VMS->catfile('c')", 'c' ],
275[ "VMS->catfile('[]c')", 'c' ],
276
0994714a 277[ "VMS->splitpath('file')", ',,file' ],
08c7cbbb 278[ "VMS->splitpath('[d1.d2.d3]')", ',[d1.d2.d3],' ],
279[ "VMS->splitpath('[.d1.d2.d3]')", ',[.d1.d2.d3],' ],
280[ "VMS->splitpath('[d1.d2.d3]file')", ',[d1.d2.d3],file' ],
281[ "VMS->splitpath('d1/d2/d3/file')", ',[.d1.d2.d3],file' ],
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('node::volume:[d1.d2.d3]')", 'node::volume:,[d1.d2.d3],' ],
285[ "VMS->splitpath('node::volume:[d1.d2.d3]file')", 'node::volume:,[d1.d2.d3],file' ],
286[ "VMS->splitpath('node\"access_spec\"::volume:[d1.d2.d3]')", 'node"access_spec"::volume:,[d1.d2.d3],' ],
287[ "VMS->splitpath('node\"access_spec\"::volume:[d1.d2.d3]file')", 'node"access_spec"::volume:,[d1.d2.d3],file' ],
0994714a 288
289[ "VMS->catpath('','','file')", 'file' ],
290[ "VMS->catpath('','[d1.d2.d3]','')", '[d1.d2.d3]' ],
291[ "VMS->catpath('','[.d1.d2.d3]','')", '[.d1.d2.d3]' ],
292[ "VMS->catpath('','[d1.d2.d3]','file')", '[d1.d2.d3]file' ],
293[ "VMS->catpath('','[.d1.d2.d3]','file')", '[.d1.d2.d3]file' ],
08c7cbbb 294[ "VMS->catpath('','d1/d2/d3','file')", '[.d1.d2.d3]file' ],
295[ "VMS->catpath('v','d1/d2/d3','file')", 'v:[.d1.d2.d3]file' ],
638113eb 296[ "VMS->catpath('v','w:[d1.d2.d3]','file')", 'v:[d1.d2.d3]file' ],
0994714a 297[ "VMS->catpath('node::volume:','[d1.d2.d3]','')", 'node::volume:[d1.d2.d3]' ],
298[ "VMS->catpath('node::volume:','[d1.d2.d3]','file')", 'node::volume:[d1.d2.d3]file' ],
299[ "VMS->catpath('node\"access_spec\"::volume:','[d1.d2.d3]','')", 'node"access_spec"::volume:[d1.d2.d3]' ],
300[ "VMS->catpath('node\"access_spec\"::volume:','[d1.d2.d3]','file')", 'node"access_spec"::volume:[d1.d2.d3]file' ],
301
302[ "VMS->canonpath('')", '' ],
178326fd 303[ "VMS->canonpath('volume:[d1]file')", 'volume:[d1]file' ],
08c7cbbb 304[ "VMS->canonpath('volume:[d1.-.d2.][d3.d4.-]')", 'volume:[d2.d3]' ],
178326fd 305[ "VMS->canonpath('volume:[000000.d1]d2.dir;1')", 'volume:[d1]d2.dir;1' ],
bdc74e5c 306[ "VMS->canonpath('volume:[d1.d2.d3]file.txt')", 'volume:[d1.d2.d3]file.txt' ],
307[ "VMS->canonpath('[d1.d2.d3]file.txt')", '[d1.d2.d3]file.txt' ],
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:[d2.d3]file.txt' ],
313[ "VMS->canonpath('[d1.-.d2.d3]file.txt')", '[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:[d1.d3]file.txt' ],
317[ "VMS->canonpath('[d1.d2.-.d3]file.txt')", '[d1.d3]file.txt' ],
318[ "VMS->canonpath('volume:[d1.d2.--.d3]file.txt')", 'volume:[d3]file.txt' ],
319[ "VMS->canonpath('[d1.d2.--.d3]file.txt')", '[d3]file.txt' ],
320[ "VMS->canonpath('volume:[d1.d2.d3.-]file.txt')", 'volume:[d1.d2]file.txt' ],
321[ "VMS->canonpath('[d1.d2.d3.-]file.txt')", '[d1.d2]file.txt' ],
322[ "VMS->canonpath('volume:[d1.d2.d3.--]file.txt')", 'volume:[d1]file.txt' ],
323[ "VMS->canonpath('[d1.d2.d3.--]file.txt')", '[d1]file.txt' ],
324[ "VMS->canonpath('volume:[d1.000000.][000000.][d3.--]file.txt')", 'volume:[d1]file.txt' ],
325[ "VMS->canonpath('[d1.000000.][000000.][d3.--]file.txt')", '[d1]file.txt' ],
326[ "VMS->canonpath('volume:[d1.000000.][000000.][d2.000000]file.txt')", 'volume:[d1.000000.d2.000000]file.txt' ],
327[ "VMS->canonpath('[d1.000000.][000000.][d2.000000]file.txt')", '[d1.000000.d2.000000]file.txt' ],
328[ "VMS->canonpath('volume:[d1.000000.][000000.][d3.--.000000]file.txt')",'volume:[d1.000000]file.txt' ],
329[ "VMS->canonpath('[d1.000000.][000000.][d3.--.000000]file.txt')", '[d1.000000]file.txt' ],
330[ "VMS->canonpath('volume:[d1.000000.][000000.][-.-.000000]file.txt')", 'volume:[000000]file.txt' ],
331[ "VMS->canonpath('[d1.000000.][000000.][--.-.000000]file.txt')", '[-.000000]file.txt' ],
99f36a73 332[ "VMS->canonpath('[d1.d2.--]file')", '[000000]file' ],
0994714a 333
334[ "VMS->splitdir('')", '' ],
335[ "VMS->splitdir('[]')", '' ],
336[ "VMS->splitdir('d1.d2.d3')", 'd1,d2,d3' ],
337[ "VMS->splitdir('[d1.d2.d3]')", 'd1,d2,d3' ],
338[ "VMS->splitdir('.d1.d2.d3')", ',d1,d2,d3' ],
339[ "VMS->splitdir('[.d1.d2.d3]')", ',d1,d2,d3' ],
340[ "VMS->splitdir('.-.d2.d3')", ',-,d2,d3' ],
341[ "VMS->splitdir('[.-.d2.d3]')", ',-,d2,d3' ],
bdc74e5c 342[ "VMS->splitdir('[d1.d2]')", 'd1,d2' ],
343[ "VMS->splitdir('[d1-.--d2]')", 'd1-,--d2' ],
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.][000000.d2]')", 'd1,d2' ],
0994714a 348
08c7cbbb 349[ "VMS->catdir('')", '' ],
350[ "VMS->catdir('d1','d2','d3')", '[.d1.d2.d3]' ],
351[ "VMS->catdir('d1','d2/','d3')", '[.d1.d2.d3]' ],
352[ "VMS->catdir('','d1','d2','d3')", '[.d1.d2.d3]' ],
353[ "VMS->catdir('','-','d2','d3')", '[-.d2.d3]' ],
354[ "VMS->catdir('','-','','d3')", '[-.d3]' ],
355[ "VMS->catdir('dir.dir','d2.dir','d3.dir')", '[.dir.d2.d3]' ],
356[ "VMS->catdir('[.name]')", '[.name]' ],
45657e91 357[ "VMS->catdir('[.name]','[.name]')", '[.name.name]'],
0994714a 358
9d5071ba 359[ "VMS->abs2rel('node::volume:[t1.t2.t3]','node::volume:[t1.t2.t3]')", '[]' ],
cda9bddd 360[ "VMS->abs2rel('node::volume:[t1.t2.t3]','[t1.t2.t3]')", 'node::volume:[t1.t2.t3]' ],
416c0615 361[ "VMS->abs2rel('node::volume:[t1.t2.t4]','node::volume:[t1.t2.t3]')", '[-.t4]' ],
cda9bddd 362[ "VMS->abs2rel('node::volume:[t1.t2.t4]','[t1.t2.t3]')", 'node::volume:[t1.t2.t4]' ],
9d5071ba 363[ "VMS->abs2rel('[t1.t2.t3]','[t1.t2.t3]')", '[]' ],
0994714a 364[ "VMS->abs2rel('[t1.t2.t3]file','[t1.t2.t3]')", 'file' ],
638113eb 365[ "VMS->abs2rel('[t1.t2.t3]file','[t1.t2]')", '[.t3]file' ],
366[ "VMS->abs2rel('v:[t1.t2.t3]file','v:[t1.t2]')", '[.t3]file' ],
0994714a 367[ "VMS->abs2rel('[t1.t2.t4]','[t1.t2.t3]')", '[-.t4]' ],
368[ "VMS->abs2rel('[t1.t2]file','[t1.t2.t3]')", '[-]file' ],
638113eb 369[ "VMS->abs2rel('[t1.t2.t3.t4]','[t1.t2.t3]')", '[.t4]' ],
08c7cbbb 370[ "VMS->abs2rel('[t4.t5.t6]','[t1.t2.t3]')", '[---.t4.t5.t6]' ],
737c380e 371[ "VMS->abs2rel('[000000]','[t1.t2.t3]')", '[---]' ],
9d5071ba 372[ "VMS->abs2rel('a:[t1.t2.t4]','a:[t1.t2.t3]')", '[-.t4]' ],
cda9bddd 373[ "VMS->abs2rel('a:[t1.t2.t4]','[t1.t2.t3]')", 'a:[t1.t2.t4]' ],
08c7cbbb 374[ "VMS->abs2rel('[a.-.b.c.-]','[t1.t2.t3]')", '[---.b]' ],
270d1e39 375
0994714a 376[ "VMS->rel2abs('[.t4]','[t1.t2.t3]')", '[t1.t2.t3.t4]' ],
377[ "VMS->rel2abs('[.t4.t5]','[t1.t2.t3]')", '[t1.t2.t3.t4.t5]' ],
378[ "VMS->rel2abs('[]','[t1.t2.t3]')", '[t1.t2.t3]' ],
08c7cbbb 379[ "VMS->rel2abs('[-]','[t1.t2.t3]')", '[t1.t2]' ],
380[ "VMS->rel2abs('[-.t4]','[t1.t2.t3]')", '[t1.t2.t4]' ],
0994714a 381[ "VMS->rel2abs('[t1]','[t1.t2.t3]')", '[t1]' ],
270d1e39 382
e021ab8e 383[ "OS2->case_tolerant()", '1' ],
384
0994714a 385[ "OS2->catdir('A:/d1','B:/d2','d3','')", 'A:/d1/B:/d2/d3' ],
02961b52 386
0994714a 387[ "OS2->catfile('a','b','c')", 'a/b/c' ],
02961b52 388[ "OS2->catfile('a','b','./c')", 'a/b/c' ],
389[ "OS2->catfile('./a','b','c')", 'a/b/c' ],
390[ "OS2->catfile('c')", 'c' ],
391[ "OS2->catfile('./c')", 'c' ],
0994714a 392
638113eb 393[ "OS2->catdir('/', '../')", '/' ],
394[ "OS2->catdir('/', '..\\')", '/' ],
395[ "OS2->catdir('\\', '../')", '/' ],
396[ "OS2->catdir('\\', '..\\')", '/' ],
397
e021ab8e 398[ "Mac->case_tolerant()", '1' ],
be708cc0 399
400[ "Mac->catpath('','','')", '' ],
401[ "Mac->catpath('',':','')", ':' ],
402[ "Mac->catpath('','::','')", '::' ],
403
404[ "Mac->catpath('hd','','')", 'hd:' ],
405[ "Mac->catpath('hd:','','')", 'hd:' ],
45657e91 406[ "Mac->catpath('hd:',':','')", 'hd:' ],
be708cc0 407[ "Mac->catpath('hd:','::','')", 'hd::' ],
408
409[ "Mac->catpath('hd','','file')", 'hd:file' ],
410[ "Mac->catpath('hd',':','file')", 'hd:file' ],
411[ "Mac->catpath('hd','::','file')", 'hd::file' ],
412[ "Mac->catpath('hd',':::','file')", 'hd:::file' ],
413
414[ "Mac->catpath('hd:','',':file')", 'hd:file' ],
415[ "Mac->catpath('hd:',':',':file')", 'hd:file' ],
416[ "Mac->catpath('hd:','::',':file')", 'hd::file' ],
417[ "Mac->catpath('hd:',':::',':file')", 'hd:::file' ],
418
419[ "Mac->catpath('hd:','d1','file')", 'hd:d1:file' ],
420[ "Mac->catpath('hd:',':d1:',':file')", 'hd:d1:file' ],
638113eb 421[ "Mac->catpath('hd:','hd:d1','')", 'hd:d1:' ],
be708cc0 422
423[ "Mac->catpath('','d1','')", ':d1:' ],
424[ "Mac->catpath('',':d1','')", ':d1:' ],
425[ "Mac->catpath('',':d1:','')", ':d1:' ],
426
427[ "Mac->catpath('','d1','file')", ':d1:file' ],
428[ "Mac->catpath('',':d1:',':file')", ':d1:file' ],
429
430[ "Mac->catpath('','','file')", 'file' ],
431[ "Mac->catpath('','',':file')", 'file' ], # !
432[ "Mac->catpath('',':',':file')", ':file' ], # !
433
434
435[ "Mac->splitpath(':')", ',:,' ],
436[ "Mac->splitpath('::')", ',::,' ],
437[ "Mac->splitpath(':::')", ',:::,' ],
438
439[ "Mac->splitpath('file')", ',,file' ],
440[ "Mac->splitpath(':file')", ',:,file' ],
441
442[ "Mac->splitpath('d1',1)", ',:d1:,' ], # dir, not volume
443[ "Mac->splitpath(':d1',1)", ',:d1:,' ],
444[ "Mac->splitpath(':d1:',1)", ',:d1:,' ],
445[ "Mac->splitpath(':d1:')", ',:d1:,' ],
446[ "Mac->splitpath(':d1:d2:d3:')", ',:d1:d2:d3:,' ],
447[ "Mac->splitpath(':d1:d2:d3:',1)", ',:d1:d2:d3:,' ],
448[ "Mac->splitpath(':d1:file')", ',:d1:,file' ],
449[ "Mac->splitpath('::d1:file')", ',::d1:,file' ],
450
451[ "Mac->splitpath('hd:', 1)", 'hd:,,' ],
452[ "Mac->splitpath('hd:')", 'hd:,,' ],
453[ "Mac->splitpath('hd:d1:d2:')", 'hd:,:d1:d2:,' ],
454[ "Mac->splitpath('hd:d1:d2',1)", 'hd:,:d1:d2:,' ],
455[ "Mac->splitpath('hd:d1:d2:file')", 'hd:,:d1:d2:,file' ],
456[ "Mac->splitpath('hd:d1:d2::file')", 'hd:,:d1:d2::,file' ],
457[ "Mac->splitpath('hd::d1:d2:file')", 'hd:,::d1:d2:,file' ], # invalid path
458[ "Mac->splitpath('hd:file')", 'hd:,,file' ],
459
2586ba89 460[ "Mac->splitdir()", '' ],
be708cc0 461[ "Mac->splitdir('')", '' ],
462[ "Mac->splitdir(':')", ':' ],
463[ "Mac->splitdir('::')", '::' ],
2586ba89 464[ "Mac->splitdir(':::')", '::,::' ],
465[ "Mac->splitdir(':::d1:d2')", '::,::,d1,d2' ],
466
467[ "Mac->splitdir(':d1:d2:d3::')", 'd1,d2,d3,::'],
468[ "Mac->splitdir(':d1:d2:d3:')", 'd1,d2,d3' ],
469[ "Mac->splitdir(':d1:d2:d3')", 'd1,d2,d3' ],
470
471# absolute paths in splitdir() work, but you'd better use splitpath()
472[ "Mac->splitdir('hd:')", 'hd:' ],
473[ "Mac->splitdir('hd::')", 'hd:,::' ], # invalid path, but it works
474[ "Mac->splitdir('hd::d1:')", 'hd:,::,d1' ], # invalid path, but it works
475[ "Mac->splitdir('hd:d1:d2:::')", 'hd:,d1,d2,::,::' ],
476[ "Mac->splitdir('hd:d1:d2::')", 'hd:,d1,d2,::' ],
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
481[ "Mac->catdir()", '' ],
482[ "Mac->catdir('')", $root, 'MacOS' ], # skipped on other OS
483[ "Mac->catdir(':')", ':' ],
484
485[ "Mac->catdir('', '')", $root, 'MacOS' ], # skipped on other OS
45657e91 486[ "Mac->catdir('', ':')", $root, 'MacOS' ], # skipped on other OS
487[ "Mac->catdir(':', ':')", ':' ],
488[ "Mac->catdir(':', '')", ':' ],
2586ba89 489
490[ "Mac->catdir('', '::')", $root, 'MacOS' ], # skipped on other OS
45657e91 491[ "Mac->catdir(':', '::')", '::' ],
2586ba89 492
45657e91 493[ "Mac->catdir('::', '')", '::' ],
494[ "Mac->catdir('::', ':')", '::' ],
2586ba89 495
45657e91 496[ "Mac->catdir('::', '::')", ':::' ],
2586ba89 497
498[ "Mac->catdir(':d1')", ':d1:' ],
499[ "Mac->catdir(':d1:')", ':d1:' ],
500[ "Mac->catdir(':d1','d2')", ':d1:d2:' ],
501[ "Mac->catdir(':d1',':d2')", ':d1:d2:' ],
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
510[ "Mac->catdir('d1')", ':d1:' ],
511[ "Mac->catdir('d1','d2','d3')", ':d1:d2:d3:' ],
512[ "Mac->catdir('d1','d2/','d3')", ':d1:d2/:d3:' ],
513[ "Mac->catdir('d1','',':d2')", ':d1:d2:' ],
514[ "Mac->catdir('d1',':',':d2')", ':d1:d2:' ],
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
528[ "Mac->catdir('','d1','d2','d3')", $root . 'd1:d2:d3:', 'MacOS' ], # skipped on other OS
529[ "Mac->catdir('',':','d1','d2')", $root . 'd1:d2:' , 'MacOS' ], # skipped on other OS
530[ "Mac->catdir('','::','d1','d2')", $root . 'd1:d2:' , 'MacOS' ], # skipped on other OS
531[ "Mac->catdir('',':','','d1')", $root . 'd1:' , 'MacOS' ], # skipped on other OS
532[ "Mac->catdir('', ':d1',':d2')", $root . 'd1:d2:' , 'MacOS' ], # skipped on other OS
533[ "Mac->catdir('','',':d1',':d2')", $root . 'd1:d2:' , 'MacOS' ], # skipped on other OS
be708cc0 534
be708cc0 535[ "Mac->catdir('hd:',':d1')", 'hd:d1:' ],
536[ "Mac->catdir('hd:d1:',':d2')", 'hd:d1:d2:' ],
537[ "Mac->catdir('hd:','d1')", 'hd:d1:' ],
be708cc0 538[ "Mac->catdir('hd:d1:',':d2')", 'hd:d1:d2:' ],
539[ "Mac->catdir('hd:d1:',':d2:')", 'hd:d1:d2:' ],
540
45657e91 541[ "Mac->catfile()", '' ],
2586ba89 542[ "Mac->catfile('')", '' ],
45657e91 543[ "Mac->catfile('', '')", $root , 'MacOS' ], # skipped on other OS
2586ba89 544[ "Mac->catfile('', 'file')", $root . 'file', 'MacOS' ], # skipped on other OS
545[ "Mac->catfile(':')", ':' ],
546[ "Mac->catfile(':', '')", ':' ],
be708cc0 547
2586ba89 548[ "Mac->catfile('d1','d2','file')", ':d1:d2:file' ],
549[ "Mac->catfile('d1','d2',':file')", ':d1:d2:file' ],
45657e91 550[ "Mac->catfile('file')", 'file' ],
551[ "Mac->catfile(':', 'file')", ':file' ],
552
0994714a 553[ "Mac->canonpath('')", '' ],
554[ "Mac->canonpath(':')", ':' ],
555[ "Mac->canonpath('::')", '::' ],
556[ "Mac->canonpath('a::')", 'a::' ],
557[ "Mac->canonpath(':a::')", ':a::' ],
558
be708cc0 559[ "Mac->abs2rel('hd:d1:d2:','hd:d1:d2:')", ':' ],
560[ "Mac->abs2rel('hd:d1:d2:','hd:d1:d2:file')", ':' ], # ignore base's file portion
45657e91 561[ "Mac->abs2rel('hd:d1:d2:file','hd:d1:d2:')", ':file' ],
be708cc0 562[ "Mac->abs2rel('hd:d1:','hd:d1:d2:')", '::' ],
563[ "Mac->abs2rel('hd:d3:','hd:d1:d2:')", ':::d3:' ],
564[ "Mac->abs2rel('hd:d3:','hd:d1:d2::')", '::d3:' ],
565[ "Mac->abs2rel('hd:d1:d4:d5:','hd:d1::d2:d3::')", '::d1:d4:d5:' ],
566[ "Mac->abs2rel('hd:d1:d4:d5:','hd:d1::d2:d3:')", ':::d1:d4:d5:' ], # first, resolve updirs in base
567[ "Mac->abs2rel('hd:d1:d3:','hd:d1:d2:')", '::d3:' ],
568[ "Mac->abs2rel('hd:d1::d3:','hd:d1:d2:')", ':::d3:' ],
569[ "Mac->abs2rel('hd:d3:','hd:d1:d2:')", ':::d3:' ], # same as above
570[ "Mac->abs2rel('hd:d1:d2:d3:','hd:d1:d2:')", ':d3:' ],
571[ "Mac->abs2rel('hd:d1:d2:d3::','hd:d1:d2:')", ':d3::' ],
638113eb 572[ "Mac->abs2rel('hd1:d3:d4:d5:','hd2:d1:d2:')", 'hd1:d3:d4:d5:'], # volume mismatch
be708cc0 573[ "Mac->abs2rel('hd:','hd:d1:d2:')", ':::' ],
574
45657e91 575[ "Mac->rel2abs(':d3:','hd:d1:d2:')", 'hd:d1:d2:d3:' ],
576[ "Mac->rel2abs(':d3:d4:','hd:d1:d2:')", 'hd:d1:d2:d3:d4:' ],
be708cc0 577[ "Mac->rel2abs('','hd:d1:d2:')", '' ],
578[ "Mac->rel2abs('::','hd:d1:d2:')", 'hd:d1:d2::' ],
579[ "Mac->rel2abs('::','hd:d1:d2:file')", 'hd:d1:d2::' ],# ignore base's file portion
580[ "Mac->rel2abs(':file','hd:d1:d2:')", 'hd:d1:d2:file' ],
581[ "Mac->rel2abs('::file','hd:d1:d2:')", 'hd:d1:d2::file' ],
582[ "Mac->rel2abs('::d3:','hd:d1:d2:')", 'hd:d1:d2::d3:' ],
583[ "Mac->rel2abs('hd:','hd:d1:d2:')", 'hd:' ], # path already absolute
584[ "Mac->rel2abs('hd:d3:file','hd:d1:d2:')", 'hd:d3:file' ],
585[ "Mac->rel2abs('hd:d3:','hd:d1:file')", 'hd:d3:' ],
e021ab8e 586
587[ "Epoc->case_tolerant()", '1' ],
588
589[ "Epoc->canonpath('')", '' ],
590[ "Epoc->canonpath('///../../..//./././a//b/.././c/././')", '/a/b/../c' ],
591[ "Epoc->canonpath('/./')", '/' ],
592[ "Epoc->canonpath('/a/./')", '/a' ],
593
594# XXX Todo, copied from Unix, but fail. Should they? 2003-07-07 Tels
595#[ "Epoc->canonpath('/a/.')", '/a' ],
596#[ "Epoc->canonpath('/.')", '/' ],
597
598[ "Cygwin->case_tolerant()", '0' ],
599
0994714a 600) ;
601
5b287435 602if ($^O eq 'MSWin32') {
603 push @tests, [ "FakeWin32->rel2abs('D:foo.txt')", 'D:\\alpha\\beta\\foo.txt' ];
604}
605
606
e021ab8e 607plan tests => scalar @tests;
270d1e39 608
e021ab8e 609{
5b287435 610 package File::Spec::FakeWin32;
611 use vars qw(@ISA);
612 @ISA = qw(File::Spec::Win32);
613
614 sub _cwd { 'C:\\one\\two' }
615
616 # Some funky stuff to override Cwd::getdcwd() for testing purposes,
617 # in the limited scope of the rel2abs() method.
99f36a73 618 if ($Cwd::VERSION && $Cwd::VERSION gt '2.17') { # Avoid a 'used only once' warning
5b287435 619 local $^W;
620 *rel2abs = sub {
621 my $self = shift;
622 local $^W;
623 local *Cwd::getdcwd = sub {
624 return 'D:\alpha\beta' if $_[0] eq 'D:';
625 return 'C:\one\two' if $_[0] eq 'C:';
626 return;
627 };
628 *Cwd::getdcwd = *Cwd::getdcwd; # Avoid a 'used only once' warning
629 return $self->SUPER::rel2abs(@_);
630 };
631 *rel2abs = *rel2abs; # Avoid a 'used only once' warning
632 }
e021ab8e 633}
0994714a 634
0994714a 635
0994714a 636# Test out the class methods
637for ( @tests ) {
638 tryfunc( @$_ ) ;
270d1e39 639}
640
0994714a 641
0994714a 642#
643# Tries a named function with the given args and compares the result against
644# an expected result. Works with functions that return scalars or arrays.
645#
646sub tryfunc {
647 my $function = shift ;
648 my $expected = shift ;
f6a53ef2 649 my $platform = shift ;
650
651 if ($platform && $^O ne $platform) {
e021ab8e 652 skip("skip $function", 1);
f6a53ef2 653 return;
654 }
0994714a 655
656 $function =~ s#\\#\\\\#g ;
e021ab8e 657 $function =~ s/^([^\$].*->)/File::Spec::$1/;
658 my $got = join ',', eval $function;
0994714a 659
660 if ( $@ ) {
e021ab8e 661 if ( $@ =~ /^\Q$skip_exception/ ) {
662 skip "skip $function: $skip_exception", 1;
663 }
664 else {
665 ok $@, '', $function;
666 }
667 return;
0994714a 668 }
e021ab8e 669
670 ok $got, $expected, $function;
0994714a 671}