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