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