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