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