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