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