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