xref: /openbsd-src/gnu/usr.bin/perl/dist/PathTools/t/Spec.t (revision b46d8ef224b95de1dddcd1f01c1ab482f0ab3778)
16fb12b70Safresh1#!/usr/bin/perl -w
26fb12b70Safresh1
36fb12b70Safresh1use strict;
46fb12b70Safresh1use Test::More;
56fb12b70Safresh1
66fb12b70Safresh1require_ok('File::Spec');
76fb12b70Safresh1
86fb12b70Safresh1require Cwd;
96fb12b70Safresh1
106fb12b70Safresh1my $vms_unix_rpt;
116fb12b70Safresh1
126fb12b70Safresh1if ($^O eq 'VMS') {
136fb12b70Safresh1    if (eval 'require VMS::Feature') {
146fb12b70Safresh1        $vms_unix_rpt = VMS::Feature::current("filename_unix_report");
156fb12b70Safresh1    } else {
166fb12b70Safresh1        my $unix_rpt = $ENV{'DECC$FILENAME_UNIX_REPORT'} || '';
176fb12b70Safresh1        $vms_unix_rpt = $unix_rpt =~ /^[ET1]/i;
186fb12b70Safresh1    }
196fb12b70Safresh1}
206fb12b70Safresh1
216fb12b70Safresh1
226fb12b70Safresh1my $skip_exception = "Needs VMS::Filespec (and thus VMS)" ;
236fb12b70Safresh1
246fb12b70Safresh1eval {
256fb12b70Safresh1   require VMS::Filespec ;
266fb12b70Safresh1} ;
276fb12b70Safresh1
286fb12b70Safresh1if ( $@ ) {
296fb12b70Safresh1   # Not pretty, but it allows testing of things not implemented solely
306fb12b70Safresh1   # on VMS.  It might be better to change File::Spec::VMS to do this,
316fb12b70Safresh1   # making it more usable when running on (say) Unix but working with
326fb12b70Safresh1   # VMS paths.
336fb12b70Safresh1   eval qq-
346fb12b70Safresh1      sub File::Spec::VMS::vmsify  { die "$skip_exception" }
356fb12b70Safresh1      sub File::Spec::VMS::unixify { die "$skip_exception" }
366fb12b70Safresh1      sub File::Spec::VMS::vmspath { die "$skip_exception" }
376fb12b70Safresh1   - ;
386fb12b70Safresh1   $INC{"VMS/Filespec.pm"} = 1 ;
396fb12b70Safresh1}
406fb12b70Safresh1
416fb12b70Safresh1foreach (qw(Unix Win32 VMS OS2 Mac Epoc Cygwin)) {
426fb12b70Safresh1    require_ok("File::Spec::$_");
436fb12b70Safresh1}
446fb12b70Safresh1
456fb12b70Safresh1# Each element in this array is a single test. Storing them this way makes
466fb12b70Safresh1# maintenance easy, and should be OK since perl should be pretty functional
476fb12b70Safresh1# before these tests are run.
486fb12b70Safresh1
496fb12b70Safresh1my @tests = (
506fb12b70Safresh1# [ Function          ,            Expected          ,         Platform ]
516fb12b70Safresh1
526fb12b70Safresh1[ "Unix->case_tolerant()",         '0'  ],
536fb12b70Safresh1
546fb12b70Safresh1[ "Unix->catfile('a','b','c')",         'a/b/c'  ],
556fb12b70Safresh1[ "Unix->catfile('a','b','./c')",       'a/b/c'  ],
566fb12b70Safresh1[ "Unix->catfile('./a','b','c')",       'a/b/c'  ],
576fb12b70Safresh1[ "Unix->catfile('c')",                 'c' ],
586fb12b70Safresh1[ "Unix->catfile('./c')",               'c' ],
596fb12b70Safresh1[ "Unix->catfile('a', 'b'.chr(0xaf))",         'a/b'.chr(0xaf)   ],
606fb12b70Safresh1($] >= 5.008 ? (
616fb12b70Safresh1[ "Unix->catfile('a', do { my \$x = 'b'.chr(0xaf); use utf8 (); utf8::upgrade(\$x); \$x })",   'a/b'.chr(0xaf)   ],
626fb12b70Safresh1) : ()),
636fb12b70Safresh1[ "Unix->catfile(substr('foo', 2))", 'o' ],
649f11ffb7Safresh1# https://rt.cpan.org/Ticket/Display.html?id=121633
659f11ffb7Safresh1# https://rt.perl.org/Ticket/Display.html?id=131296
669f11ffb7Safresh1[ "Unix->catfile('.', 'hints', 'Makefile.PL')", 'hints/Makefile.PL' ],
676fb12b70Safresh1
686fb12b70Safresh1[ "Unix->splitpath('file')",            ',,file'            ],
696fb12b70Safresh1[ "Unix->splitpath('/d1/d2/d3/')",      ',/d1/d2/d3/,'      ],
706fb12b70Safresh1[ "Unix->splitpath('d1/d2/d3/')",       ',d1/d2/d3/,'       ],
716fb12b70Safresh1[ "Unix->splitpath('/d1/d2/d3/.')",     ',/d1/d2/d3/.,'     ],
726fb12b70Safresh1[ "Unix->splitpath('/d1/d2/d3/..')",    ',/d1/d2/d3/..,'    ],
736fb12b70Safresh1[ "Unix->splitpath('/d1/d2/d3/.file')", ',/d1/d2/d3/,.file' ],
746fb12b70Safresh1[ "Unix->splitpath('d1/d2/d3/file')",   ',d1/d2/d3/,file'   ],
756fb12b70Safresh1[ "Unix->splitpath('/../../d1/')",      ',/../../d1/,'      ],
766fb12b70Safresh1[ "Unix->splitpath('/././d1/')",        ',/././d1/,'        ],
776fb12b70Safresh1
786fb12b70Safresh1[ "Unix->catpath('','','file')",            'file'            ],
796fb12b70Safresh1[ "Unix->catpath('','/d1/d2/d3/','')",      '/d1/d2/d3/'      ],
806fb12b70Safresh1[ "Unix->catpath('','d1/d2/d3/','')",       'd1/d2/d3/'       ],
816fb12b70Safresh1[ "Unix->catpath('','/d1/d2/d3/.','')",     '/d1/d2/d3/.'     ],
826fb12b70Safresh1[ "Unix->catpath('','/d1/d2/d3/..','')",    '/d1/d2/d3/..'    ],
836fb12b70Safresh1[ "Unix->catpath('','/d1/d2/d3/','.file')", '/d1/d2/d3/.file' ],
846fb12b70Safresh1[ "Unix->catpath('','d1/d2/d3/','file')",   'd1/d2/d3/file'   ],
856fb12b70Safresh1[ "Unix->catpath('','/../../d1/','')",      '/../../d1/'      ],
866fb12b70Safresh1[ "Unix->catpath('','/././d1/','')",        '/././d1/'        ],
876fb12b70Safresh1[ "Unix->catpath('d1','d2/d3/','')",        'd2/d3/'          ],
886fb12b70Safresh1[ "Unix->catpath('d1','d2','d3/')",         'd2/d3/'          ],
896fb12b70Safresh1
906fb12b70Safresh1[ "Unix->splitdir('')",           ''           ],
916fb12b70Safresh1[ "Unix->splitdir('/d1/d2/d3/')", ',d1,d2,d3,' ],
926fb12b70Safresh1[ "Unix->splitdir('d1/d2/d3/')",  'd1,d2,d3,'  ],
936fb12b70Safresh1[ "Unix->splitdir('/d1/d2/d3')",  ',d1,d2,d3'  ],
946fb12b70Safresh1[ "Unix->splitdir('d1/d2/d3')",   'd1,d2,d3'   ],
956fb12b70Safresh1
966fb12b70Safresh1[ "Unix->catdir()",                     ''          ],
976fb12b70Safresh1[ "Unix->catdir('')",                   '/'         ],
986fb12b70Safresh1[ "Unix->catdir('/')",                  '/'         ],
996fb12b70Safresh1[ "Unix->catdir('','d1','d2','d3','')", '/d1/d2/d3' ],
1006fb12b70Safresh1[ "Unix->catdir('d1','d2','d3','')",    'd1/d2/d3'  ],
1016fb12b70Safresh1[ "Unix->catdir('','d1','d2','d3')",    '/d1/d2/d3' ],
1026fb12b70Safresh1[ "Unix->catdir('d1','d2','d3')",       'd1/d2/d3'  ],
1036fb12b70Safresh1# QNX is POSIXly special
1046fb12b70Safresh1[ "Unix->catdir('/','d2/d3')",          ( $^O =~ m!^(nto|qnx)! ? '//d2/d3' : '/d2/d3' ) ],
1056fb12b70Safresh1[ "Unix->catdir('a', 'b'.chr(0xaf))",         'a/b'.chr(0xaf)   ],
1066fb12b70Safresh1($] >= 5.008 ? (
1076fb12b70Safresh1[ "Unix->catdir('a', do { my \$x = 'b'.chr(0xaf); use utf8 (); utf8::upgrade(\$x); \$x })",   'a/b'.chr(0xaf)   ],
1086fb12b70Safresh1) : ()),
1096fb12b70Safresh1
1106fb12b70Safresh1[ "Unix->canonpath('///../../..//./././a//b/.././c/././')",   '/a/b/../c' ],
1116fb12b70Safresh1[ "Unix->canonpath('')",                       ''               ],
1126fb12b70Safresh1# rt.perl.org 27052
1136fb12b70Safresh1[ "Unix->canonpath('a/../../b/c')",            'a/../../b/c'    ],
1146fb12b70Safresh1[ "Unix->canonpath('/')",                      '/'              ],
1156fb12b70Safresh1[ "Unix->canonpath('///')",                    '/'              ],
1166fb12b70Safresh1[ "Unix->canonpath('/.')",                     '/'              ],
1176fb12b70Safresh1[ "Unix->canonpath('/./')",                    '/'              ],
1186fb12b70Safresh1[ "Unix->canonpath('///.')",                   '/'              ],
1196fb12b70Safresh1[ "Unix->canonpath('///.///')",                '/'              ],
1206fb12b70Safresh1[ "Unix->canonpath('///..')",                  '/'              ],
1216fb12b70Safresh1[ "Unix->canonpath('///..///')",               '/'              ],
1226fb12b70Safresh1[ "Unix->canonpath('///..///.///..///')",      '/'              ],
1236fb12b70Safresh1[ "Unix->canonpath('.')",                      '.'              ],
1246fb12b70Safresh1[ "Unix->canonpath('.///')",                   '.'              ],
1256fb12b70Safresh1[ "Unix->canonpath('.///.')",                  '.'              ],
1266fb12b70Safresh1[ "Unix->canonpath('.///.///')",               '.'              ],
1276fb12b70Safresh1[ "Unix->canonpath('..')",                     '..'             ],
1286fb12b70Safresh1[ "Unix->canonpath('..///')",                  '..'             ],
1296fb12b70Safresh1[ "Unix->canonpath('../..')",                  '../..'          ],
1306fb12b70Safresh1[ "Unix->canonpath('../../')",                 '../..'          ],
1316fb12b70Safresh1[ "Unix->canonpath('..///.///..///')",         '../..'          ],
1326fb12b70Safresh1[ "Unix->canonpath('///../../..//./././a//b/.././c/././')",   '/a/b/../c' ],
1336fb12b70Safresh1[ "Unix->canonpath('a/../../b/c')",            'a/../../b/c'    ],
1346fb12b70Safresh1[ "Unix->canonpath('a///..///..///b////c')",   'a/../../b/c'    ],
1356fb12b70Safresh1[ "Unix->canonpath('.///a///.///..///.///..///.///b///.////c///.')",   'a/../../b/c'    ],
1366fb12b70Safresh1[ "Unix->canonpath('/a/./')",                  '/a'             ],
1376fb12b70Safresh1[ "Unix->canonpath('/a/.')",                   '/a'             ],
1386fb12b70Safresh1[ "Unix->canonpath('/../../')",                '/'              ],
1396fb12b70Safresh1[ "Unix->canonpath('/../..')",                 '/'              ],
1406fb12b70Safresh1[ "Unix->canonpath('/foo', '/bar')",           '/foo'           ],
1416fb12b70Safresh1[ "Unix->canonpath('///a'.chr(0xaf))",         '/a'.chr(0xaf)   ],
1426fb12b70Safresh1($] >= 5.008 ? (
1436fb12b70Safresh1[ "Unix->canonpath(do { my \$x = '///a'.chr(0xaf); use utf8 (); utf8::upgrade(\$x); \$x })",   '/a'.chr(0xaf)   ],
1446fb12b70Safresh1) : ()),
1459f11ffb7Safresh1[ "Unix->canonpath(1)",                        '1'              ],
1466fb12b70Safresh1
1476fb12b70Safresh1[  "Unix->abs2rel('/t1/t2/t3','/t1/t2/t3')",          '.'                  ],
1486fb12b70Safresh1[  "Unix->abs2rel('/t1/t2/t4','/t1/t2/t3')",          '../t4'              ],
1496fb12b70Safresh1[  "Unix->abs2rel('/t1/t2','/t1/t2/t3')",             '..'                 ],
1506fb12b70Safresh1[  "Unix->abs2rel('/t1/t2/t3/t4','/t1/t2/t3')",       't4'                 ],
1516fb12b70Safresh1[  "Unix->abs2rel('/t4/t5/t6','/t1/t2/t3')",          '../../../t4/t5/t6'  ],
1526fb12b70Safresh1#[ "Unix->abs2rel('../t4','/t1/t2/t3')",              '../t4'              ],
1536fb12b70Safresh1[  "Unix->abs2rel('/','/t1/t2/t3')",                  '../../..'           ],
1546fb12b70Safresh1[  "Unix->abs2rel('///','/t1/t2/t3')",                '../../..'           ],
1556fb12b70Safresh1[  "Unix->abs2rel('/.','/t1/t2/t3')",                 '../../..'           ],
1566fb12b70Safresh1[  "Unix->abs2rel('/./','/t1/t2/t3')",                '../../..'           ],
1576fb12b70Safresh1[  "Unix->abs2rel('/t1/t2/t3', '/')",                 't1/t2/t3'           ],
1586fb12b70Safresh1[  "Unix->abs2rel('/t1/t2/t3', '/t1')",               't2/t3'              ],
1596fb12b70Safresh1[  "Unix->abs2rel('t1/t2/t3', 't1')",                 't2/t3'              ],
1606fb12b70Safresh1[  "Unix->abs2rel('t1/t2/t3', 't4')",                 '../t1/t2/t3'        ],
1616fb12b70Safresh1 [  "Unix->abs2rel('.', '.')",                         '.'                  ],
1626fb12b70Safresh1 [  "Unix->abs2rel('/', '/')",                         '.'                  ],
1636fb12b70Safresh1 [  "Unix->abs2rel('../t1', 't2/t3')",                 '../../../t1'        ],
1646fb12b70Safresh1 [  "Unix->abs2rel('t1', 't2/../t3')",                 '../t1'              ],
1656fb12b70Safresh1
1666fb12b70Safresh1[ "Unix->rel2abs('t4','/t1/t2/t3')",             '/t1/t2/t3/t4'    ],
1676fb12b70Safresh1[ "Unix->rel2abs('t4/t5','/t1/t2/t3')",          '/t1/t2/t3/t4/t5' ],
1686fb12b70Safresh1[ "Unix->rel2abs('.','/t1/t2/t3')",              '/t1/t2/t3'       ],
1696fb12b70Safresh1[ "Unix->rel2abs('..','/t1/t2/t3')",             '/t1/t2/t3/..'    ],
1706fb12b70Safresh1[ "Unix->rel2abs('../t4','/t1/t2/t3')",          '/t1/t2/t3/../t4' ],
1716fb12b70Safresh1[ "Unix->rel2abs('/t1','/t1/t2/t3')",            '/t1'             ],
1726fb12b70Safresh1
1736fb12b70Safresh1[ "Win32->case_tolerant()",         '1'  ],
1746fb12b70Safresh1[ "Win32->rootdir()",               '\\'  ],
1756fb12b70Safresh1
1766fb12b70Safresh1[ "Win32->splitpath('file')",                            ',,file'                            ],
1776fb12b70Safresh1[ "Win32->splitpath('\\d1/d2\\d3/')",                    ',\\d1/d2\\d3/,'                    ],
1786fb12b70Safresh1[ "Win32->splitpath('d1/d2\\d3/')",                      ',d1/d2\\d3/,'                      ],
1796fb12b70Safresh1[ "Win32->splitpath('\\d1/d2\\d3/.')",                   ',\\d1/d2\\d3/.,'                   ],
1806fb12b70Safresh1[ "Win32->splitpath('\\d1/d2\\d3/..')",                  ',\\d1/d2\\d3/..,'                  ],
1816fb12b70Safresh1[ "Win32->splitpath('\\d1/d2\\d3/.file')",               ',\\d1/d2\\d3/,.file'               ],
1826fb12b70Safresh1[ "Win32->splitpath('\\d1/d2\\d3/file')",                ',\\d1/d2\\d3/,file'                ],
1836fb12b70Safresh1[ "Win32->splitpath('d1/d2\\d3/file')",                  ',d1/d2\\d3/,file'                  ],
1846fb12b70Safresh1[ "Win32->splitpath('C:\\d1/d2\\d3/')",                  'C:,\\d1/d2\\d3/,'                  ],
1856fb12b70Safresh1[ "Win32->splitpath('C:d1/d2\\d3/')",                    'C:,d1/d2\\d3/,'                    ],
1866fb12b70Safresh1[ "Win32->splitpath('C:\\d1/d2\\d3/file')",              'C:,\\d1/d2\\d3/,file'              ],
1876fb12b70Safresh1[ "Win32->splitpath('C:d1/d2\\d3/file')",                'C:,d1/d2\\d3/,file'                ],
1886fb12b70Safresh1[ "Win32->splitpath('C:\\../d2\\d3/file')",              'C:,\\../d2\\d3/,file'              ],
1896fb12b70Safresh1[ "Win32->splitpath('C:../d2\\d3/file')",                'C:,../d2\\d3/,file'                ],
1906fb12b70Safresh1[ "Win32->splitpath('\\../..\\d1/')",                    ',\\../..\\d1/,'                    ],
1916fb12b70Safresh1[ "Win32->splitpath('\\./.\\d1/')",                      ',\\./.\\d1/,'                      ],
1926fb12b70Safresh1[ "Win32->splitpath('\\\\node\\share\\d1/d2\\d3/')",     '\\\\node\\share,\\d1/d2\\d3/,'     ],
1936fb12b70Safresh1[ "Win32->splitpath('\\\\node\\share\\d1/d2\\d3/file')", '\\\\node\\share,\\d1/d2\\d3/,file' ],
1946fb12b70Safresh1[ "Win32->splitpath('\\\\node\\share\\d1/d2\\file')",    '\\\\node\\share,\\d1/d2\\,file'    ],
1956fb12b70Safresh1[ "Win32->splitpath('file',1)",                          ',file,'                            ],
1966fb12b70Safresh1[ "Win32->splitpath('\\d1/d2\\d3/',1)",                  ',\\d1/d2\\d3/,'                    ],
1976fb12b70Safresh1[ "Win32->splitpath('d1/d2\\d3/',1)",                    ',d1/d2\\d3/,'                      ],
1986fb12b70Safresh1[ "Win32->splitpath('\\\\node\\share\\d1/d2\\d3/',1)",   '\\\\node\\share,\\d1/d2\\d3/,'     ],
1996fb12b70Safresh1
2006fb12b70Safresh1[ "Win32->catpath('','','file')",                            'file'                            ],
2016fb12b70Safresh1[ "Win32->catpath('','\\d1/d2\\d3/','')",                    '\\d1/d2\\d3/'                    ],
2026fb12b70Safresh1[ "Win32->catpath('','d1/d2\\d3/','')",                      'd1/d2\\d3/'                      ],
2036fb12b70Safresh1[ "Win32->catpath('','\\d1/d2\\d3/.','')",                   '\\d1/d2\\d3/.'                   ],
2046fb12b70Safresh1[ "Win32->catpath('','\\d1/d2\\d3/..','')",                  '\\d1/d2\\d3/..'                  ],
2056fb12b70Safresh1[ "Win32->catpath('','\\d1/d2\\d3/','.file')",               '\\d1/d2\\d3/.file'               ],
2066fb12b70Safresh1[ "Win32->catpath('','\\d1/d2\\d3/','file')",                '\\d1/d2\\d3/file'                ],
2076fb12b70Safresh1[ "Win32->catpath('','d1/d2\\d3/','file')",                  'd1/d2\\d3/file'                  ],
2086fb12b70Safresh1[ "Win32->catpath('C:','\\d1/d2\\d3/','')",                  'C:\\d1/d2\\d3/'                  ],
2096fb12b70Safresh1[ "Win32->catpath('C:','d1/d2\\d3/','')",                    'C:d1/d2\\d3/'                    ],
2106fb12b70Safresh1[ "Win32->catpath('C:','\\d1/d2\\d3/','file')",              'C:\\d1/d2\\d3/file'              ],
2116fb12b70Safresh1[ "Win32->catpath('C:','d1/d2\\d3/','file')",                'C:d1/d2\\d3/file'                ],
2126fb12b70Safresh1[ "Win32->catpath('C:','\\../d2\\d3/','file')",              'C:\\../d2\\d3/file'              ],
2136fb12b70Safresh1[ "Win32->catpath('C:','../d2\\d3/','file')",                'C:../d2\\d3/file'                ],
2146fb12b70Safresh1[ "Win32->catpath('','\\../..\\d1/','')",                    '\\../..\\d1/'                    ],
2156fb12b70Safresh1[ "Win32->catpath('','\\./.\\d1/','')",                      '\\./.\\d1/'                      ],
2166fb12b70Safresh1[ "Win32->catpath('\\\\node\\share','\\d1/d2\\d3/','')",     '\\\\node\\share\\d1/d2\\d3/'     ],
2176fb12b70Safresh1[ "Win32->catpath('\\\\node\\share','\\d1/d2\\d3/','file')", '\\\\node\\share\\d1/d2\\d3/file' ],
2186fb12b70Safresh1[ "Win32->catpath('\\\\node\\share','\\d1/d2\\','file')",    '\\\\node\\share\\d1/d2\\file'    ],
2196fb12b70Safresh1
2206fb12b70Safresh1[ "Win32->splitdir('')",             ''           ],
2216fb12b70Safresh1[ "Win32->splitdir('\\d1/d2\\d3/')", ',d1,d2,d3,' ],
2226fb12b70Safresh1[ "Win32->splitdir('d1/d2\\d3/')",   'd1,d2,d3,'  ],
2236fb12b70Safresh1[ "Win32->splitdir('\\d1/d2\\d3')",  ',d1,d2,d3'  ],
2246fb12b70Safresh1[ "Win32->splitdir('d1/d2\\d3')",    'd1,d2,d3'   ],
2256fb12b70Safresh1
2266fb12b70Safresh1[ "Win32->catdir()",                        ''                   ],
2276fb12b70Safresh1[ "Win32->catdir('')",                      '\\'                 ],
2286fb12b70Safresh1[ "Win32->catdir('/')",                     '\\'                 ],
2296fb12b70Safresh1[ "Win32->catdir('/', '../')",              '\\'                 ],
2306fb12b70Safresh1[ "Win32->catdir('/', '..\\')",             '\\'                 ],
2316fb12b70Safresh1[ "Win32->catdir('\\', '../')",             '\\'                 ],
2326fb12b70Safresh1[ "Win32->catdir('\\', '..\\')",            '\\'                 ],
2336fb12b70Safresh1[ "Win32->catdir('//d1','d2')",             '\\\\d1\\d2'         ],
2346fb12b70Safresh1[ "Win32->catdir('\\d1\\','d2')",           '\\d1\\d2'         ],
2356fb12b70Safresh1[ "Win32->catdir('\\d1','d2')",             '\\d1\\d2'         ],
2366fb12b70Safresh1[ "Win32->catdir('\\d1','\\d2')",           '\\d1\\d2'         ],
2376fb12b70Safresh1[ "Win32->catdir('\\d1','\\d2\\')",         '\\d1\\d2'         ],
2386fb12b70Safresh1[ "Win32->catdir('','/d1','d2')",           '\\d1\\d2'         ],
2396fb12b70Safresh1[ "Win32->catdir('','','/d1','d2')",        '\\d1\\d2'         ],
2406fb12b70Safresh1[ "Win32->catdir('','//d1','d2')",          '\\d1\\d2'         ],
2416fb12b70Safresh1[ "Win32->catdir('','','//d1','d2')",       '\\d1\\d2'         ],
2426fb12b70Safresh1[ "Win32->catdir('','d1','','d2','')",      '\\d1\\d2'           ],
2436fb12b70Safresh1[ "Win32->catdir('','d1','d2','d3','')",    '\\d1\\d2\\d3'       ],
2446fb12b70Safresh1[ "Win32->catdir('d1','d2','d3','')",       'd1\\d2\\d3'         ],
2456fb12b70Safresh1[ "Win32->catdir('','d1','d2','d3')",       '\\d1\\d2\\d3'       ],
2466fb12b70Safresh1[ "Win32->catdir('d1','d2','d3')",          'd1\\d2\\d3'         ],
2476fb12b70Safresh1[ "Win32->catdir('A:/d1','d2','d3')",       'A:\\d1\\d2\\d3'     ],
2486fb12b70Safresh1[ "Win32->catdir('A:/d1','d2','d3','')",    'A:\\d1\\d2\\d3'     ],
2496fb12b70Safresh1#[ "Win32->catdir('A:/d1','B:/d2','d3','')", 'A:\\d1\\d2\\d3'     ],
2506fb12b70Safresh1[ "Win32->catdir('A:/d1','B:/d2','d3','')", 'A:\\d1\\B:\\d2\\d3' ],
2516fb12b70Safresh1[ "Win32->catdir('A:/')",                   'A:\\'               ],
2526fb12b70Safresh1[ "Win32->catdir('\\', 'foo')",             '\\foo'              ],
2536fb12b70Safresh1[ "Win32->catdir('','','..')",              '\\'                 ],
2546fb12b70Safresh1[ "Win32->catdir('A:', 'foo')",             'A:\\foo'            ],
2556fb12b70Safresh1
2566fb12b70Safresh1[ "Win32->catfile('a','b','c')",        'a\\b\\c' ],
2576fb12b70Safresh1[ "Win32->catfile('a','b','.\\c')",      'a\\b\\c'  ],
2586fb12b70Safresh1[ "Win32->catfile('.\\a','b','c')",      'a\\b\\c'  ],
2596fb12b70Safresh1[ "Win32->catfile('c')",                'c' ],
2606fb12b70Safresh1[ "Win32->catfile('.\\c')",              'c' ],
2616fb12b70Safresh1[ "Win32->catfile('a/..','../b')",       '..\\b' ],
2626fb12b70Safresh1[ "Win32->catfile('A:', 'foo')",         'A:\\foo'            ],
2636fb12b70Safresh1
2646fb12b70Safresh1
2656fb12b70Safresh1[ "Win32->canonpath('')",               ''                    ],
2666fb12b70Safresh1[ "Win32->canonpath('a:')",             'A:'                  ],
2676fb12b70Safresh1[ "Win32->canonpath('A:f')",            'A:f'                 ],
2686fb12b70Safresh1[ "Win32->canonpath('A:/')",            'A:\\'                ],
2696fb12b70Safresh1# rt.perl.org 27052
2706fb12b70Safresh1[ "Win32->canonpath('a\\..\\..\\b\\c')", '..\\b\\c'           ],
2716fb12b70Safresh1[ "Win32->canonpath('//a\\b//c')",      '\\\\a\\b\\c'         ],
2726fb12b70Safresh1[ "Win32->canonpath('/a/..../c')",      '\\a\\....\\c'        ],
2736fb12b70Safresh1[ "Win32->canonpath('//a/b\\c')",       '\\\\a\\b\\c'         ],
2746fb12b70Safresh1[ "Win32->canonpath('////')",           '\\'                  ],
2756fb12b70Safresh1[ "Win32->canonpath('//')",             '\\'                  ],
2766fb12b70Safresh1[ "Win32->canonpath('/.')",             '\\'                  ],
2776fb12b70Safresh1[ "Win32->canonpath('//a/b/../../c')",  '\\\\a\\b\\c'         ],
2786fb12b70Safresh1[ "Win32->canonpath('//a/b/c/../d')",   '\\\\a\\b\\d'         ],
2796fb12b70Safresh1[ "Win32->canonpath('//a/b/c/../../d')",'\\\\a\\b\\d'         ],
280*b46d8ef2Safresh1[ "Win32->canonpath('//a/b/c/.../d')",  '\\\\a\\b\\c\\...\\d' ],
2816fb12b70Safresh1[ "Win32->canonpath('/a/b/c/../../d')", '\\a\\d'              ],
282*b46d8ef2Safresh1[ "Win32->canonpath('/a/b/c/.../d')",   '\\a\\b\\c\\...\\d'   ],
2836fb12b70Safresh1[ "Win32->canonpath('\\../temp\\')",    '\\temp'              ],
2846fb12b70Safresh1[ "Win32->canonpath('\\../')",          '\\'                  ],
2856fb12b70Safresh1[ "Win32->canonpath('\\..\\')",         '\\'                  ],
2866fb12b70Safresh1[ "Win32->canonpath('/../')",           '\\'                  ],
2876fb12b70Safresh1[ "Win32->canonpath('/..\\')",          '\\'                  ],
2886fb12b70Safresh1[ "Win32->canonpath('d1/../foo')",      'foo'                 ],
2896fb12b70Safresh1
2909f11ffb7Safresh1# FakeWin32 subclass (see below) just sets getcwd() to C:\one\two and getdcwd('D') to D:\alpha\beta
2916fb12b70Safresh1
2926fb12b70Safresh1[ "FakeWin32->abs2rel('/t1/t2/t3','/t1/t2/t3')",     '.'                      ],
2936fb12b70Safresh1[ "FakeWin32->abs2rel('/t1/t2/t4','/t1/t2/t3')",     '..\\t4'                 ],
2946fb12b70Safresh1[ "FakeWin32->abs2rel('/t1/t2','/t1/t2/t3')",        '..'                     ],
2956fb12b70Safresh1[ "FakeWin32->abs2rel('/t1/t2/t3/t4','/t1/t2/t3')",  't4'                     ],
2966fb12b70Safresh1[ "FakeWin32->abs2rel('/t4/t5/t6','/t1/t2/t3')",     '..\\..\\..\\t4\\t5\\t6' ],
2976fb12b70Safresh1[ "FakeWin32->abs2rel('../t4','/t1/t2/t3')",         '..\\..\\..\\one\\t4'    ],  # Uses _cwd()
2986fb12b70Safresh1[ "FakeWin32->abs2rel('/','/t1/t2/t3')",             '..\\..\\..'             ],
2996fb12b70Safresh1[ "FakeWin32->abs2rel('///','/t1/t2/t3')",           '..\\..\\..'             ],
3006fb12b70Safresh1[ "FakeWin32->abs2rel('/.','/t1/t2/t3')",            '..\\..\\..'             ],
3016fb12b70Safresh1[ "FakeWin32->abs2rel('/./','/t1/t2/t3')",           '..\\..\\..'             ],
3026fb12b70Safresh1[ "FakeWin32->abs2rel('\\\\a/t1/t2/t4','/t2/t3')",   '\\\\a\\t1\\t2\\t4'      ],
3036fb12b70Safresh1[ "FakeWin32->abs2rel('//a/t1/t2/t4','/t2/t3')",     '\\\\a\\t1\\t2\\t4'      ],
3046fb12b70Safresh1[ "FakeWin32->abs2rel('A:/t1/t2/t3','A:/t1/t2/t3')",     '.'                  ],
3056fb12b70Safresh1[ "FakeWin32->abs2rel('A:/t1/t2/t3/t4','A:/t1/t2/t3')",  't4'                 ],
3066fb12b70Safresh1[ "FakeWin32->abs2rel('A:/t1/t2/t3','A:/t1/t2/t3/t4')",  '..'                 ],
3076fb12b70Safresh1[ "FakeWin32->abs2rel('A:/t1/t2/t3','B:/t1/t2/t3')",     'A:\\t1\\t2\\t3'     ],
3086fb12b70Safresh1[ "FakeWin32->abs2rel('A:/t1/t2/t3/t4','B:/t1/t2/t3')",  'A:\\t1\\t2\\t3\\t4' ],
3096fb12b70Safresh1[ "FakeWin32->abs2rel('E:/foo/bar/baz')",            'E:\\foo\\bar\\baz'      ],
3106fb12b70Safresh1[ "FakeWin32->abs2rel('C:/one/two/three')",          'three'                  ],
3116fb12b70Safresh1[ "FakeWin32->abs2rel('C:\\Windows\\System32', 'C:\\')",  'Windows\System32'  ],
3126fb12b70Safresh1[ "FakeWin32->abs2rel('\\\\computer2\\share3\\foo.txt', '\\\\computer2\\share3')",  'foo.txt' ],
3136fb12b70Safresh1[ "FakeWin32->abs2rel('C:\\one\\two\\t\\asd1\\', 't\\asd\\')", '..\\asd1'     ],
3146fb12b70Safresh1[ "FakeWin32->abs2rel('\\one\\two', 'A:\\foo')",     'C:\\one\\two'           ],
3156fb12b70Safresh1
3166fb12b70Safresh1[ "FakeWin32->rel2abs('temp','C:/')",                       'C:\\temp'                        ],
3176fb12b70Safresh1[ "FakeWin32->rel2abs('temp','C:/a')",                      'C:\\a\\temp'                     ],
3186fb12b70Safresh1[ "FakeWin32->rel2abs('temp','C:/a/')",                     'C:\\a\\temp'                     ],
3196fb12b70Safresh1[ "FakeWin32->rel2abs('../','C:/')",                        'C:\\'                            ],
3206fb12b70Safresh1[ "FakeWin32->rel2abs('../','C:/a')",                       'C:\\'                            ],
3216fb12b70Safresh1[ "FakeWin32->rel2abs('\\foo','C:/a')",                     'C:\\foo'                         ],
3226fb12b70Safresh1[ "FakeWin32->rel2abs('temp','//prague_main/work/')",       '\\\\prague_main\\work\\temp'     ],
3236fb12b70Safresh1[ "FakeWin32->rel2abs('../temp','//prague_main/work/')",    '\\\\prague_main\\work\\temp'     ],
3246fb12b70Safresh1[ "FakeWin32->rel2abs('temp','//prague_main/work')",        '\\\\prague_main\\work\\temp'     ],
3256fb12b70Safresh1[ "FakeWin32->rel2abs('../','//prague_main/work')",         '\\\\prague_main\\work'           ],
3266fb12b70Safresh1[ "FakeWin32->rel2abs('D:foo.txt')",                        'D:\\alpha\\beta\\foo.txt'        ],
3276fb12b70Safresh1
3286fb12b70Safresh1[ "VMS->case_tolerant()",         '1'  ],
3296fb12b70Safresh1
3306fb12b70Safresh1[ "VMS->catfile('a','b','c')",    $vms_unix_rpt ? 'a/b/c' : '[.a.b]c'  ],
3316fb12b70Safresh1[ "VMS->catfile('a','b','[]c')",  $vms_unix_rpt ? 'a/b/c' : '[.a.b]c'  ],
3326fb12b70Safresh1[ "VMS->catfile('[.a]','b','c')", $vms_unix_rpt ? 'a/b/c' : '[.a.b]c'  ],
3336fb12b70Safresh1[ "VMS->catfile('a/b/','c')",     $vms_unix_rpt ? 'a/b/c' : '[.a.b]c'  ],
3346fb12b70Safresh1[ "VMS->catfile('c')",                 'c' ],
3356fb12b70Safresh1[ "VMS->catfile('[]c')",               'c' ],
3366fb12b70Safresh1
3376fb12b70Safresh1[ "VMS->catfile('0','b','c')", $vms_unix_rpt ? '0/b/c' : '[.0.b]c' ],
3386fb12b70Safresh1[ "VMS->catfile('a','0','c')", $vms_unix_rpt ? 'a/0/c' : '[.a.0]c' ],
3396fb12b70Safresh1[ "VMS->catfile('a','b','0')", $vms_unix_rpt ? 'a/b/0' : '[.a.b]0' ],
3406fb12b70Safresh1[ "VMS->catfile('0','0','c')", $vms_unix_rpt ? '0/0/c' : '[.0.0]c' ],
3416fb12b70Safresh1[ "VMS->catfile('a','0','0')", $vms_unix_rpt ? 'a/0/0' : '[.a.0]0' ],
3426fb12b70Safresh1[ "VMS->catfile('0','b','0')", $vms_unix_rpt ? '0/b/0' : '[.0.b]0' ],
3436fb12b70Safresh1[ "VMS->catfile('0','0','0')", $vms_unix_rpt ? '0/0/0' : '[.0.0]0' ],
3446fb12b70Safresh1
3456fb12b70Safresh1
3466fb12b70Safresh1[ "VMS->splitpath('file')",                                       ',,file'                                   ],
3476fb12b70Safresh1[ "VMS->splitpath('[d1.d2.d3]')",                                 ',[d1.d2.d3],'                               ],
3486fb12b70Safresh1[ "VMS->splitpath('[.d1.d2.d3]')",                                ',[.d1.d2.d3],'                              ],
3496fb12b70Safresh1[ "VMS->splitpath('[d1.d2.d3]file')",                             ',[d1.d2.d3],file'                           ],
3506fb12b70Safresh1[ "VMS->splitpath('d1/d2/d3/file')",
3516fb12b70Safresh1       $vms_unix_rpt ? ',d1/d2/d3/,file' : ',[.d1.d2.d3],file' ],
3526fb12b70Safresh1[ "VMS->splitpath('/d1/d2/d3/file')",
3536fb12b70Safresh1       $vms_unix_rpt ? ',/d1/d2/d3/,file' : 'd1:,[d2.d3],file' ],
3546fb12b70Safresh1[ "VMS->splitpath('[.d1.d2.d3]file')",                            ',[.d1.d2.d3],file'                          ],
3556fb12b70Safresh1[ "VMS->splitpath('node::volume:[d1.d2.d3]')",                    'node::volume:,[d1.d2.d3],'                  ],
3566fb12b70Safresh1[ "VMS->splitpath('node::volume:[d1.d2.d3]file')",                'node::volume:,[d1.d2.d3],file'              ],
3576fb12b70Safresh1[ "VMS->splitpath('node\"access_spec\"::volume:[d1.d2.d3]')",     'node"access_spec"::volume:,[d1.d2.d3],'     ],
3586fb12b70Safresh1[ "VMS->splitpath('node\"access_spec\"::volume:[d1.d2.d3]file')", 'node"access_spec"::volume:,[d1.d2.d3],file' ],
3596fb12b70Safresh1
3606fb12b70Safresh1[ "VMS->splitpath('[]')",                                         ',[],'                                       ],
3616fb12b70Safresh1[ "VMS->splitpath('[-]')",                                        ',[-],'                                      ],
3626fb12b70Safresh1[ "VMS->splitpath('[]file')",                                     ',[],file'                                   ],
3636fb12b70Safresh1[ "VMS->splitpath('[-]file')",                                    ',[-],file'                                  ],
3646fb12b70Safresh1[ "VMS->splitpath('')",                                           ',,'                                         ],
3656fb12b70Safresh1[ "VMS->splitpath('0')",                                          ',,0'                                        ],
3666fb12b70Safresh1[ "VMS->splitpath('[0]')",                                        ',[0],'                                      ],
3676fb12b70Safresh1[ "VMS->splitpath('[.0]')",                                       ',[.0],'                                     ],
3686fb12b70Safresh1[ "VMS->splitpath('[0.0.0]')",                                    ',[0.0.0],'                                  ],
3696fb12b70Safresh1[ "VMS->splitpath('[.0.0.0]')",                                   ',[.0.0.0],'                                 ],
3706fb12b70Safresh1[ "VMS->splitpath('[0]0')",                                       ',[0],0'                                     ],
3716fb12b70Safresh1[ "VMS->splitpath('[0.0.0]0')",                                   ',[0.0.0],0'                                 ],
3726fb12b70Safresh1[ "VMS->splitpath('[.0.0.0]0')",                                  ',[.0.0.0],0'                                ],
3736fb12b70Safresh1[ "VMS->splitpath('0/0')",    $vms_unix_rpt ? ',0/,0' : ',[.0],0'  ],
3746fb12b70Safresh1[ "VMS->splitpath('0/0/0')",  $vms_unix_rpt ? ',0/0/,0' : ',[.0.0],0'  ],
3756fb12b70Safresh1[ "VMS->splitpath('/0/0')",   $vms_unix_rpt ? ',/0/,0' : '0:,[000000],0'  ],
3766fb12b70Safresh1[ "VMS->splitpath('/0/0/0')", $vms_unix_rpt ? ',/0/0/,0' : '0:,[0],0'  ],
3776fb12b70Safresh1[ "VMS->splitpath('d1',1)",                                       ',d1,'                                       ],
3786fb12b70Safresh1# $no_file tests
3796fb12b70Safresh1[ "VMS->splitpath('[d1.d2.d3]',1)",                               ',[d1.d2.d3],'                               ],
3806fb12b70Safresh1[ "VMS->splitpath('[.d1.d2.d3]',1)",                              ',[.d1.d2.d3],'                              ],
3816fb12b70Safresh1[ "VMS->splitpath('d1/d2/d3',1)",  $vms_unix_rpt ? ',d1/d2/d3,' : ',[.d1.d2.d3],' ],
3826fb12b70Safresh1[ "VMS->splitpath('/d1/d2/d3',1)", $vms_unix_rpt ? ',/d1/d2/d3,' : 'd1:,[d2.d3],' ],
3836fb12b70Safresh1[ "VMS->splitpath('node::volume:[d1.d2.d3]',1)",                  'node::volume:,[d1.d2.d3],'                  ],
3846fb12b70Safresh1[ "VMS->splitpath('node\"access_spec\"::volume:[d1.d2.d3]',1)",   'node"access_spec"::volume:,[d1.d2.d3],'     ],
3856fb12b70Safresh1[ "VMS->splitpath('[]',1)",                                       ',[],'                                       ],
3866fb12b70Safresh1[ "VMS->splitpath('[-]',1)",                                      ',[-],'                                      ],
3876fb12b70Safresh1[ "VMS->splitpath('',1)",                                         ',,'                                         ],
3886fb12b70Safresh1[ "VMS->splitpath('0',1)",                                        ',0,'                                        ],
3896fb12b70Safresh1[ "VMS->splitpath('[0]',1)",                                      ',[0],'                                      ],
3906fb12b70Safresh1[ "VMS->splitpath('[.0]',1)",                                     ',[.0],'                                     ],
3916fb12b70Safresh1[ "VMS->splitpath('[0.0.0]',1)",                                  ',[0.0.0],'                                  ],
3926fb12b70Safresh1[ "VMS->splitpath('[.0.0.0]',1)",                                 ',[.0.0.0],'                                 ],
3936fb12b70Safresh1[ "VMS->splitpath('0/0',1)",    $vms_unix_rpt ? ',0/0,' : ',[.0.0],' ],
3946fb12b70Safresh1[ "VMS->splitpath('0/0/0',1)",  $vms_unix_rpt ? ',0/0/0,' : ',[.0.0.0],' ],
3956fb12b70Safresh1[ "VMS->splitpath('/0/0',1)",   $vms_unix_rpt ? ',/0/0,' : '0:,[000000.0],' ],
3966fb12b70Safresh1[ "VMS->splitpath('/0/0/0',1)", $vms_unix_rpt ? ',/0/0/0,' : '0:,[0.0],' ],
3976fb12b70Safresh1
3986fb12b70Safresh1[ "VMS->catpath('','','file')",                                       'file'                                     ],
3996fb12b70Safresh1[ "VMS->catpath('','[d1.d2.d3]','')",                                 '[d1.d2.d3]'                               ],
4006fb12b70Safresh1[ "VMS->catpath('','[.d1.d2.d3]','')",                                '[.d1.d2.d3]'                              ],
4016fb12b70Safresh1[ "VMS->catpath('','[d1.d2.d3]','file')",                             '[d1.d2.d3]file'                           ],
4026fb12b70Safresh1[ "VMS->catpath('','[.d1.d2.d3]','file')",                            '[.d1.d2.d3]file'                          ],
4036fb12b70Safresh1[ "VMS->catpath('','d1/d2/d3','file')",
4046fb12b70Safresh1                             $vms_unix_rpt ? 'd1/d2/d3/file' : '[.d1.d2.d3]file' ],
4056fb12b70Safresh1[ "VMS->catpath('v','d1/d2/d3','file')",                              'v:[.d1.d2.d3]file' ],
4066fb12b70Safresh1[ "VMS->catpath('v','','file')",                                      'v:file' ],
4076fb12b70Safresh1[ "VMS->catpath('v','w:[d1.d2.d3]','file')",                          'v:[d1.d2.d3]file'                         ],
4086fb12b70Safresh1[ "VMS->catpath('node::volume:','[d1.d2.d3]','')",                    'node::volume:[d1.d2.d3]'                  ],
4096fb12b70Safresh1[ "VMS->catpath('node::volume:','[d1.d2.d3]','file')",                'node::volume:[d1.d2.d3]file'              ],
4106fb12b70Safresh1[ "VMS->catpath('node\"access_spec\"::volume:','[d1.d2.d3]','')",     'node"access_spec"::volume:[d1.d2.d3]'     ],
4116fb12b70Safresh1[ "VMS->catpath('node\"access_spec\"::volume:','[d1.d2.d3]','file')", 'node"access_spec"::volume:[d1.d2.d3]file' ],
4126fb12b70Safresh1
4136fb12b70Safresh1[ "VMS->canonpath('')",                                 ''                        ],
4146fb12b70Safresh1[ "VMS->canonpath('volume:[d1]file')",                  $vms_unix_rpt ? '/volume/d1/file'               : 'volume:[d1]file'                ],
4156fb12b70Safresh1[ "VMS->canonpath('volume:[d1.-.d2.][d3.d4.-]')",       $vms_unix_rpt ? '/volume/d2/d3/'               : 'volume:[d2.d3]'                  ],
4166fb12b70Safresh1[ "VMS->canonpath('volume:[000000.d1]d2.dir;1')",       $vms_unix_rpt ? '/volume/d1/d2.dir.1'          : 'volume:[d1]d2.dir;1'             ],
4176fb12b70Safresh1[ "VMS->canonpath('volume:[d1.d2.d3]file.txt')", 	$vms_unix_rpt ? '/volume/d1/d2/d3/file.txt'    : 'volume:[d1.d2.d3]file.txt'       ],
4186fb12b70Safresh1[ "VMS->canonpath('[d1.d2.d3]file.txt')", 		$vms_unix_rpt ? '/sys$disk/d1/d2/d3/file.txt'  : '[d1.d2.d3]file.txt'              ],
4196fb12b70Safresh1[ "VMS->canonpath('volume:[-.d1.d2.d3]file.txt')", 	$vms_unix_rpt ? '/volume/../d1/d2/d3/file.txt' : 'volume:[-.d1.d2.d3]file.txt'     ],
4206fb12b70Safresh1[ "VMS->canonpath('[-.d1.d2.d3]file.txt')", 		$vms_unix_rpt ? '../d1/d2/d3/file.txt'         : '[-.d1.d2.d3]file.txt'            ],
4216fb12b70Safresh1[ "VMS->canonpath('volume:[--.d1.d2.d3]file.txt')", 	$vms_unix_rpt ? '/volume/../../d1/d2/d3/file.txt' : 'volume:[--.d1.d2.d3]file.txt' ],
4226fb12b70Safresh1[ "VMS->canonpath('[--.d1.d2.d3]file.txt')", 		$vms_unix_rpt ? '../../d1/d2/d3/file.txt'      : '[--.d1.d2.d3]file.txt'           ],
4236fb12b70Safresh1[ "VMS->canonpath('volume:[d1.-.d2.d3]file.txt')", 	$vms_unix_rpt ? '/volume/d2/d3/file.txt'       : 'volume:[d2.d3]file.txt'          ],
4246fb12b70Safresh1[ "VMS->canonpath('[d1.-.d2.d3]file.txt')", 		$vms_unix_rpt ? '/sys$disk/d2/d3/file.txt'     : '[d2.d3]file.txt'                 ],
4256fb12b70Safresh1[ "VMS->canonpath('volume:[d1.--.d2.d3]file.txt')", 	$vms_unix_rpt ? '/volume/../d2/d3/file.txt'    : 'volume:[-.d2.d3]file.txt'        ],
4266fb12b70Safresh1[ "VMS->canonpath('[d1.--.d2.d3]file.txt')", 		$vms_unix_rpt ? '../d2/d3/file.txt'            : '[-.d2.d3]file.txt'               ],
4276fb12b70Safresh1[ "VMS->canonpath('volume:[d1.d2.-.d3]file.txt')", 	$vms_unix_rpt ? '/volume/d1/d3/file.txt'       : 'volume:[d1.d3]file.txt'          ],
4286fb12b70Safresh1[ "VMS->canonpath('[d1.d2.-.d3]file.txt')", 		$vms_unix_rpt ? '/sys$disk/d1/d3/file.txt'     : '[d1.d3]file.txt'                 ],
4296fb12b70Safresh1[ "VMS->canonpath('volume:[d1.d2.--.d3]file.txt')", 	$vms_unix_rpt ? '/volume/d3/file.txt'          : 'volume:[d3]file.txt'             ],
4306fb12b70Safresh1[ "VMS->canonpath('[d1.d2.--.d3]file.txt')", 		$vms_unix_rpt ? '/sys$disk/d3/file.txt'        : '[d3]file.txt'                    ],
4316fb12b70Safresh1[ "VMS->canonpath('volume:[d1.d2.d3.-]file.txt')", 	$vms_unix_rpt ? '/volume/d1/d2/file.txt'       : 'volume:[d1.d2]file.txt'          ],
4326fb12b70Safresh1[ "VMS->canonpath('[d1.d2.d3.-]file.txt')", 		$vms_unix_rpt ? '/sys$disk/d1/d2/file.txt'     : '[d1.d2]file.txt'                 ],
4336fb12b70Safresh1[ "VMS->canonpath('volume:[d1.d2.d3.--]file.txt')", 	$vms_unix_rpt ? '/volume/d1/file.txt'          : 'volume:[d1]file.txt'             ],
4346fb12b70Safresh1[ "VMS->canonpath('[d1.d2.d3.--]file.txt')", 		$vms_unix_rpt ? '/sys$disk/d1/file.txt'        : '[d1]file.txt'                    ],
4356fb12b70Safresh1[ "VMS->canonpath('volume:[d1.000000.][000000.][d3.--]file.txt')", $vms_unix_rpt ? '/volume/d1/file.txt'
4366fb12b70Safresh1                                                                                 : 'volume:[d1]file.txt'                                   ],
4376fb12b70Safresh1[ "VMS->canonpath('[d1.000000.][000000.][d3.--]file.txt')", 		$vms_unix_rpt ? '/sys$disk/d1/file.txt'
4386fb12b70Safresh1                                                                                      : '[d1]file.txt'                                     ],
4396fb12b70Safresh1[ "VMS->canonpath('volume:[d1.000000.][000000.][d2.000000]file.txt')",	$vms_unix_rpt ? '/volume/d1/000000/d2/000000/file.txt'
4406fb12b70Safresh1                                                                                      : 'volume:[d1.000000.d2.000000]file.txt'             ],
4416fb12b70Safresh1[ "VMS->canonpath('[d1.000000.][000000.][d2.000000]file.txt')", 	$vms_unix_rpt ? '/sys$disk/d1/000000/d2/000000/file.txt'
4426fb12b70Safresh1                                                                                      : '[d1.000000.d2.000000]file.txt'                    ],
4436fb12b70Safresh1[ "VMS->canonpath('volume:[d1.000000.][000000.][d3.--.000000]file.txt')", $vms_unix_rpt ? '/volume/d1/000000/file.txt'
4446fb12b70Safresh1                                                                                        : 'volume:[d1.000000]file.txt'                     ],
4456fb12b70Safresh1[ "VMS->canonpath('[d1.000000.][000000.][d3.--.000000]file.txt')", 	$vms_unix_rpt ? '/sys$disk/d1/000000/file.txt'
4466fb12b70Safresh1                                                                                      : '[d1.000000]file.txt'                              ],
4476fb12b70Safresh1[ "VMS->canonpath('volume:[d1.000000.][000000.][-.-.000000]file.txt')",	$vms_unix_rpt ? '/volume/file.txt'
4486fb12b70Safresh1                                                                                      : 'volume:[000000]file.txt'                          ],
4496fb12b70Safresh1[ "VMS->canonpath('[d1.000000.][000000.][--.-.000000]file.txt')", 	$vms_unix_rpt ? '../file.txt'  : '[-.000000]file.txt'              ],
4506fb12b70Safresh1[ "VMS->canonpath('[d1.d2.--]file')",                                   $vms_unix_rpt ? '../file.txt'  : '[000000]file'                    ],
4516fb12b70Safresh1# During the Perl 5.8 era, FS::Unix stopped eliminating redundant path elements, so mimic that here.
4526fb12b70Safresh1[ "VMS->canonpath('a/../../b/c.dat')",                  $vms_unix_rpt ? 'a/../../b/c.dat'              : '[-.b]c.dat'                      ],
453b8851fccSafresh1[ "VMS->canonpath('^<test^.new.-.caret^ escapes^>')",   $vms_unix_rpt ? '/<test.new.-.caret escapes>' : '^<test^.new.-.caret^ escapes^>'                                                   ],
4549f11ffb7Safresh1# Check that directory specs with caret-dot component is treated correctly
4559f11ffb7Safresh1[ "VMS->canonpath('foo:[bar.coo.kie.--]file.txt')",     $vms_unix_rpt ? '/foo/bar/file.txt'            : "foo:[bar]file.txt" ],
4569f11ffb7Safresh1[ "VMS->canonpath('foo:[bar^.coo.kie.--]file.txt')",    $vms_unix_rpt ? '/foo/file.txt'                : "foo:[000000]file.txt" ],
4579f11ffb7Safresh1[ "VMS->canonpath('foo:[bar.coo^.kie.--]file.txt')",    $vms_unix_rpt ? '/foo/file.txt'                : "foo:[000000]file.txt" ],
4589f11ffb7Safresh1[ "VMS->canonpath('foo:[bar.coo.kie.-]file.txt')",      $vms_unix_rpt ? '/foo/bar/coo/file.txt'        : "foo:[bar.coo]file.txt" ],
4599f11ffb7Safresh1[ "VMS->canonpath('foo:[bar^.coo.kie.-]file.txt')",     $vms_unix_rpt ? '/foo/bar.coo/file.txt'        : "foo:[bar^.coo]file.txt" ],
4609f11ffb7Safresh1[ "VMS->canonpath('foo:[bar.coo^.kie.-]file.txt')",     $vms_unix_rpt ? '/foo/bar/file.txt'            : "foo:[bar]file.txt" ],
4616fb12b70Safresh1
4626fb12b70Safresh1[ "VMS->splitdir('')",            ''          ],
4636fb12b70Safresh1[ "VMS->splitdir('[]')",          ''          ],
4646fb12b70Safresh1[ "VMS->splitdir('d1.d2.d3')",    'd1,d2,d3'  ],
4656fb12b70Safresh1[ "VMS->splitdir('[d1.d2.d3]')",  'd1,d2,d3'  ],
4666fb12b70Safresh1[ "VMS->splitdir('.d1.d2.d3')",   'd1,d2,d3' ],
4676fb12b70Safresh1[ "VMS->splitdir('[.d1.d2.d3]')", 'd1,d2,d3' ],
4686fb12b70Safresh1[ "VMS->splitdir('.-.d2.d3')",    '-,d2,d3'  ],
4696fb12b70Safresh1[ "VMS->splitdir('[.-.d2.d3]')",  '-,d2,d3'  ],
4706fb12b70Safresh1[ "VMS->splitdir('[d1.d2]')",  		'd1,d2'  ],
4716fb12b70Safresh1[ "VMS->splitdir('[d1-.--d2]')",  	'd1-,--d2'  ],
4726fb12b70Safresh1[ "VMS->splitdir('[d1---.-.d2]')",  	'd1---,-,d2'  ],
4736fb12b70Safresh1[ "VMS->splitdir('[d1.---.d2]')",  	'd1,-,-,-,d2'  ],
4746fb12b70Safresh1[ "VMS->splitdir('[d1---d2]')",  	'd1---d2'  ],
4756fb12b70Safresh1[ "VMS->splitdir('[d1.][000000.d2]')",  'd1,d2'  ],
4766fb12b70Safresh1[ "VMS->splitdir('[.d1.d2^.d3]')", 'd1,d2^.d3' ],
4776fb12b70Safresh1
4786fb12b70Safresh1[ "VMS->catdir('')",                            ''                 ],
4796fb12b70Safresh1[ "VMS->catdir('foo')",            $vms_unix_rpt ? 'foo'      : '[.foo]'      ],
4806fb12b70Safresh1[ "VMS->catdir('d1','d2','d3')",   $vms_unix_rpt ? 'd1/d2/d3' : '[.d1.d2.d3]' ],
4816fb12b70Safresh1[ "VMS->catdir('d1','d2/','d3')",  $vms_unix_rpt ? 'd1/d2/d3' : '[.d1.d2.d3]' ],
4826fb12b70Safresh1[ "VMS->catdir('','d1','d2','d3')",$vms_unix_rpt ? '/d1/d2/d3' : '[.d1.d2.d3]' ],
4836fb12b70Safresh1[ "VMS->catdir('','-','d2','d3')", $vms_unix_rpt ? '-/d2/d3'   : '[-.d2.d3]' ],
4846fb12b70Safresh1[ "VMS->catdir('','-','','d3')",   $vms_unix_rpt ? '-/d3'      : '[-.d3]' ],
4856fb12b70Safresh1[ "VMS->catdir('dir.dir','d2.dir','d3.dir')", $vms_unix_rpt ? 'dir/d2/d3'
4866fb12b70Safresh1                                                            : '[.dir.d2.d3]' ],
4876fb12b70Safresh1[ "VMS->catdir('[.name]')",             $vms_unix_rpt ? 'name/'     : '[.name]' ],
4886fb12b70Safresh1[ "VMS->catdir('[.name]','[.name]')",   $vms_unix_rpt ? 'name/name' :'[.name.name]' ],
4896fb12b70Safresh1[ "VMS->catdir('/a/b/c','[-]')",        $vms_unix_rpt ? '/a/b/c/..' : 'a:[b]'],
4906fb12b70Safresh1[ "VMS->catdir('a:[b.c]','..')",        $vms_unix_rpt ? '/a/b/c/..' : 'a:[b]'],
4916fb12b70Safresh1
4926fb12b70Safresh1[ "VMS->abs2rel('node::volume:[t1.t2.t3]','node::volume:[t1.t2.t3]')", $vms_unix_rpt ? './' : '[]' ],
4936fb12b70Safresh1[ "VMS->abs2rel('node::volume:[t1.t2.t3]','[t1.t2.t3]')", $vms_unix_rpt ? '/node//volume/t1/t2/t3/' : 'node::volume:[t1.t2.t3]' ],
4946fb12b70Safresh1[ "VMS->abs2rel('node::volume:[t1.t2.t4]','node::volume:[t1.t2.t3]')", $vms_unix_rpt ? '../t4/' : '[-.t4]' ],
4956fb12b70Safresh1[ "VMS->abs2rel('node::volume:[t1.t2.t4]','[t1.t2.t3]')", $vms_unix_rpt ? '/node//volume/t1/t2/t4/' : 'node::volume:[t1.t2.t4]' ],
496b8851fccSafresh1[ "VMS->abs2rel('/volume/t1/t2/t3','/volume/t1')",        $vms_unix_rpt ? 't2/t3' : '[.t2]t3' ],
497b8851fccSafresh1[ "VMS->abs2rel('/volume/t1/t2/t3/t4','/volume/t1/xyz')", $vms_unix_rpt ? '../t2/t3/t4' : '[-.t2.t3]t4' ],
4986fb12b70Safresh1[ "VMS->abs2rel('[t1.t2.t3]','[t1.t2.t3]')",              $vms_unix_rpt ? './' : '[]'             ],
4996fb12b70Safresh1[ "VMS->abs2rel('[t1.t2.t3]file','[t1.t2.t3]')",          'file'                                  ],
5006fb12b70Safresh1[ "VMS->abs2rel('[t1.t2.t3]file','[t1.t2]')",             $vms_unix_rpt ? 't3/file' : '[.t3]file' ],
5016fb12b70Safresh1[ "VMS->abs2rel('v:[t1.t2.t3]file','v:[t1.t2]')",         $vms_unix_rpt ? 't3/file' : '[.t3]file' ],
5026fb12b70Safresh1[ "VMS->abs2rel('[t1.t2.t4]','[t1.t2.t3]')",              $vms_unix_rpt ? '../t4/'  : '[-.t4]'    ],
5036fb12b70Safresh1[ "VMS->abs2rel('[t1.t2]file','[t1.t2.t3]')",             $vms_unix_rpt ? '../file' : '[-]file'   ],
5046fb12b70Safresh1[ "VMS->abs2rel('[t1.t2.t3.t4]','[t1.t2.t3]')",           $vms_unix_rpt ? 't4/'     : '[.t4]'     ],
5056fb12b70Safresh1[ "VMS->abs2rel('[t4.t5.t6]','[t1.t2.t3]')",              $vms_unix_rpt ? '../../../t4/t5/t6/' : '[---.t4.t5.t6]'   ],
5066fb12b70Safresh1[ "VMS->abs2rel('[000000]','[t1.t2.t3]')",                $vms_unix_rpt ? '../../../'          : '[---]'            ],
5076fb12b70Safresh1[ "VMS->abs2rel('a:[t1.t2.t4]','a:[t1.t2.t3]')",          $vms_unix_rpt ? '../t4/'             : '[-.t4]'           ],
508b8851fccSafresh1[ "VMS->abs2rel('a:[t1.t2.t4]','[t1.t2.t3]')",            $vms_unix_rpt ? '/a/t1/t2/t4'        : 'a:[t1.t2.t4]'    ],
5096fb12b70Safresh1[ "VMS->abs2rel('[a.-.b.c.-]','[t1.t2.t3]')",             $vms_unix_rpt ? '../../../b/'         : '[---.b]'         ],
5106fb12b70Safresh1
5116fb12b70Safresh1[ "VMS->rel2abs('[.t4]','[t1.t2.t3]')",          $vms_unix_rpt ? '/sys$disk/t1/t2/t3/t4/'    : '[t1.t2.t3.t4]'    ],
5126fb12b70Safresh1[ "VMS->rel2abs('[.t4.t5]','[t1.t2.t3]')",       $vms_unix_rpt ? '/sys$disk/t1/t2/t3/t4/t5/' : '[t1.t2.t3.t4.t5]' ],
5136fb12b70Safresh1[ "VMS->rel2abs('[]','[t1.t2.t3]')",             $vms_unix_rpt ? '/sys$disk/t1/t2/t3/'       : '[t1.t2.t3]'       ],
5146fb12b70Safresh1[ "VMS->rel2abs('[-]','[t1.t2.t3]')",            $vms_unix_rpt ? '/sys$disk/t1/t2/'          : '[t1.t2]'          ],
5156fb12b70Safresh1[ "VMS->rel2abs('[-.t4]','[t1.t2.t3]')",         $vms_unix_rpt ? '/sys$disk/t1/t2/t4/'       : '[t1.t2.t4]'       ],
5166fb12b70Safresh1[ "VMS->rel2abs('[t1]','[t1.t2.t3]')",           $vms_unix_rpt ? '/sys$disk/t1/'             : '[t1]'             ],
5176fb12b70Safresh1
5186fb12b70Safresh1[ "VMS->file_name_is_absolute('foo:')",                '1'  ],
5196fb12b70Safresh1[ "VMS->file_name_is_absolute('foo:bar.dat')",         '1'  ],
5206fb12b70Safresh1[ "VMS->file_name_is_absolute('foo:[000000]bar.dat')", '1'  ],
5216fb12b70Safresh1
5226fb12b70Safresh1[ "OS2->case_tolerant()",         '1'  ],
5236fb12b70Safresh1
5246fb12b70Safresh1[ "OS2->catdir('A:/d1','B:/d2','d3','')", 'A:/d1/B:/d2/d3' ],
5256fb12b70Safresh1
5266fb12b70Safresh1[ "OS2->catfile('a','b','c')",            'a/b/c'          ],
5276fb12b70Safresh1[ "OS2->catfile('a','b','./c')",          'a/b/c'  ],
5286fb12b70Safresh1[ "OS2->catfile('./a','b','c')",          'a/b/c'  ],
5296fb12b70Safresh1[ "OS2->catfile('c')",                    'c' ],
5306fb12b70Safresh1[ "OS2->catfile('./c')",                  'c' ],
5316fb12b70Safresh1
5326fb12b70Safresh1[ "OS2->catdir('/', '../')",              '/'                 ],
5336fb12b70Safresh1[ "OS2->catdir('/', '..\\')",             '/'                 ],
5346fb12b70Safresh1[ "OS2->catdir('\\', '../')",             '/'                 ],
5356fb12b70Safresh1[ "OS2->catdir('\\', '..\\')",            '/'                 ],
5366fb12b70Safresh1
5376fb12b70Safresh1[ "Mac->case_tolerant()",         '1'  ],
5386fb12b70Safresh1
5396fb12b70Safresh1[ "Mac->catpath('','','')",              ''                ],
5406fb12b70Safresh1[ "Mac->catpath('',':','')",             ':'               ],
5416fb12b70Safresh1[ "Mac->catpath('','::','')",            '::'              ],
5426fb12b70Safresh1
5436fb12b70Safresh1[ "Mac->catpath('hd','','')",            'hd:'             ],
5446fb12b70Safresh1[ "Mac->catpath('hd:','','')",           'hd:'             ],
5456fb12b70Safresh1[ "Mac->catpath('hd:',':','')",          'hd:'             ],
5466fb12b70Safresh1[ "Mac->catpath('hd:','::','')",         'hd::'            ],
5476fb12b70Safresh1
5486fb12b70Safresh1[ "Mac->catpath('hd','','file')",       'hd:file'          ],
5496fb12b70Safresh1[ "Mac->catpath('hd',':','file')",      'hd:file'          ],
5506fb12b70Safresh1[ "Mac->catpath('hd','::','file')",     'hd::file'         ],
5516fb12b70Safresh1[ "Mac->catpath('hd',':::','file')",    'hd:::file'        ],
5526fb12b70Safresh1
5536fb12b70Safresh1[ "Mac->catpath('hd:','',':file')",      'hd:file'         ],
5546fb12b70Safresh1[ "Mac->catpath('hd:',':',':file')",     'hd:file'         ],
5556fb12b70Safresh1[ "Mac->catpath('hd:','::',':file')",    'hd::file'        ],
5566fb12b70Safresh1[ "Mac->catpath('hd:',':::',':file')",   'hd:::file'       ],
5576fb12b70Safresh1
5586fb12b70Safresh1[ "Mac->catpath('hd:','d1','file')",     'hd:d1:file'      ],
5596fb12b70Safresh1[ "Mac->catpath('hd:',':d1:',':file')",  'hd:d1:file'      ],
5606fb12b70Safresh1[ "Mac->catpath('hd:','hd:d1','')",      'hd:d1:'          ],
5616fb12b70Safresh1
5626fb12b70Safresh1[ "Mac->catpath('','d1','')",            ':d1:'            ],
5636fb12b70Safresh1[ "Mac->catpath('',':d1','')",           ':d1:'            ],
5646fb12b70Safresh1[ "Mac->catpath('',':d1:','')",          ':d1:'            ],
5656fb12b70Safresh1
5666fb12b70Safresh1[ "Mac->catpath('','d1','file')",        ':d1:file'        ],
5676fb12b70Safresh1[ "Mac->catpath('',':d1:',':file')",     ':d1:file'        ],
5686fb12b70Safresh1
5696fb12b70Safresh1[ "Mac->catpath('','','file')",          'file'            ],
5706fb12b70Safresh1[ "Mac->catpath('','',':file')",         'file'            ], # !
5716fb12b70Safresh1[ "Mac->catpath('',':',':file')",        ':file'           ], # !
5726fb12b70Safresh1
5736fb12b70Safresh1
5746fb12b70Safresh1[ "Mac->splitpath(':')",              ',:,'               ],
5756fb12b70Safresh1[ "Mac->splitpath('::')",             ',::,'              ],
5766fb12b70Safresh1[ "Mac->splitpath(':::')",            ',:::,'             ],
5776fb12b70Safresh1
5786fb12b70Safresh1[ "Mac->splitpath('file')",           ',,file'            ],
5796fb12b70Safresh1[ "Mac->splitpath(':file')",          ',:,file'           ],
5806fb12b70Safresh1
5816fb12b70Safresh1[ "Mac->splitpath('d1',1)",           ',:d1:,'            ], # dir, not volume
5826fb12b70Safresh1[ "Mac->splitpath(':d1',1)",          ',:d1:,'            ],
5836fb12b70Safresh1[ "Mac->splitpath(':d1:',1)",         ',:d1:,'            ],
5846fb12b70Safresh1[ "Mac->splitpath(':d1:')",           ',:d1:,'            ],
5856fb12b70Safresh1[ "Mac->splitpath(':d1:d2:d3:')",     ',:d1:d2:d3:,'      ],
5866fb12b70Safresh1[ "Mac->splitpath(':d1:d2:d3:',1)",   ',:d1:d2:d3:,'      ],
5876fb12b70Safresh1[ "Mac->splitpath(':d1:file')",       ',:d1:,file'        ],
5886fb12b70Safresh1[ "Mac->splitpath('::d1:file')",      ',::d1:,file'       ],
5896fb12b70Safresh1
5906fb12b70Safresh1[ "Mac->splitpath('hd:', 1)",         'hd:,,'             ],
5916fb12b70Safresh1[ "Mac->splitpath('hd:')",            'hd:,,'             ],
5926fb12b70Safresh1[ "Mac->splitpath('hd:d1:d2:')",      'hd:,:d1:d2:,'      ],
5936fb12b70Safresh1[ "Mac->splitpath('hd:d1:d2',1)",     'hd:,:d1:d2:,'      ],
5946fb12b70Safresh1[ "Mac->splitpath('hd:d1:d2:file')",  'hd:,:d1:d2:,file'  ],
5956fb12b70Safresh1[ "Mac->splitpath('hd:d1:d2::file')", 'hd:,:d1:d2::,file' ],
5966fb12b70Safresh1[ "Mac->splitpath('hd::d1:d2:file')", 'hd:,::d1:d2:,file' ], # invalid path
5976fb12b70Safresh1[ "Mac->splitpath('hd:file')",        'hd:,,file'         ],
5986fb12b70Safresh1
5996fb12b70Safresh1[ "Mac->splitdir()",                   ''            ],
6006fb12b70Safresh1[ "Mac->splitdir('')",                 ''            ],
6016fb12b70Safresh1[ "Mac->splitdir(':')",                ':'           ],
6026fb12b70Safresh1[ "Mac->splitdir('::')",               '::'          ],
6036fb12b70Safresh1[ "Mac->splitdir(':::')",              '::,::'       ],
6046fb12b70Safresh1[ "Mac->splitdir(':::d1:d2')",         '::,::,d1,d2' ],
6056fb12b70Safresh1
6066fb12b70Safresh1[ "Mac->splitdir(':d1:d2:d3::')",      'd1,d2,d3,::'],
6076fb12b70Safresh1[ "Mac->splitdir(':d1:d2:d3:')",       'd1,d2,d3'   ],
6086fb12b70Safresh1[ "Mac->splitdir(':d1:d2:d3')",        'd1,d2,d3'   ],
6096fb12b70Safresh1
6106fb12b70Safresh1# absolute paths in splitdir() work, but you'd better use splitpath()
6116fb12b70Safresh1[ "Mac->splitdir('hd:')",              'hd:'              ],
6126fb12b70Safresh1[ "Mac->splitdir('hd::')",             'hd:,::'           ], # invalid path, but it works
6136fb12b70Safresh1[ "Mac->splitdir('hd::d1:')",          'hd:,::,d1'        ], # invalid path, but it works
6146fb12b70Safresh1[ "Mac->splitdir('hd:d1:d2:::')",      'hd:,d1,d2,::,::'  ],
6156fb12b70Safresh1[ "Mac->splitdir('hd:d1:d2::')",       'hd:,d1,d2,::'     ],
6166fb12b70Safresh1[ "Mac->splitdir('hd:d1:d2:')",        'hd:,d1,d2'        ],
6176fb12b70Safresh1[ "Mac->splitdir('hd:d1:d2')",         'hd:,d1,d2'        ],
6186fb12b70Safresh1[ "Mac->splitdir('hd:d1::d2::')",      'hd:,d1,::,d2,::'  ],
6196fb12b70Safresh1
6206fb12b70Safresh1[ "Mac->catdir()",                 ''             ],
6216fb12b70Safresh1[ "Mac->catdir(':')",              ':'            ],
6226fb12b70Safresh1
6236fb12b70Safresh1[ "Mac->catdir(':', ':')",         ':'            ],
6246fb12b70Safresh1[ "Mac->catdir(':', '')",          ':'            ],
6256fb12b70Safresh1
6266fb12b70Safresh1[ "Mac->catdir(':', '::')",        '::'           ],
6276fb12b70Safresh1
6286fb12b70Safresh1[ "Mac->catdir('::', '')",         '::'           ],
6296fb12b70Safresh1[ "Mac->catdir('::', ':')",        '::'           ],
6306fb12b70Safresh1
6316fb12b70Safresh1[ "Mac->catdir('::', '::')",       ':::'          ],
6326fb12b70Safresh1
6336fb12b70Safresh1[ "Mac->catdir(':d1')",                    ':d1:'        ],
6346fb12b70Safresh1[ "Mac->catdir(':d1:')",                   ':d1:'        ],
6356fb12b70Safresh1[ "Mac->catdir(':d1','d2')",               ':d1:d2:'     ],
6366fb12b70Safresh1[ "Mac->catdir(':d1',':d2')",              ':d1:d2:'     ],
6376fb12b70Safresh1[ "Mac->catdir(':d1',':d2:')",             ':d1:d2:'     ],
6386fb12b70Safresh1[ "Mac->catdir(':d1',':d2::')",            ':d1:d2::'     ],
6396fb12b70Safresh1[ "Mac->catdir(':',':d1',':d2')",          ':d1:d2:'     ],
6406fb12b70Safresh1[ "Mac->catdir('::',':d1',':d2')",         '::d1:d2:'    ],
6416fb12b70Safresh1[ "Mac->catdir('::','::',':d1',':d2')",    ':::d1:d2:'   ],
6426fb12b70Safresh1[ "Mac->catdir(':',':',':d1',':d2')",      ':d1:d2:'     ],
6436fb12b70Safresh1[ "Mac->catdir('::',':',':d1',':d2')",     '::d1:d2:'    ],
6446fb12b70Safresh1
6456fb12b70Safresh1[ "Mac->catdir('d1')",                    ':d1:'         ],
6466fb12b70Safresh1[ "Mac->catdir('d1','d2','d3')",          ':d1:d2:d3:'   ],
6476fb12b70Safresh1[ "Mac->catdir('d1','d2/','d3')",         ':d1:d2/:d3:'  ],
6486fb12b70Safresh1[ "Mac->catdir('d1','',':d2')",           ':d1:d2:'      ],
6496fb12b70Safresh1[ "Mac->catdir('d1',':',':d2')",          ':d1:d2:'      ],
6506fb12b70Safresh1[ "Mac->catdir('d1','::',':d2')",         ':d1::d2:'     ],
6516fb12b70Safresh1[ "Mac->catdir('d1',':::',':d2')",        ':d1:::d2:'    ],
6526fb12b70Safresh1[ "Mac->catdir('d1','::','::',':d2')",    ':d1:::d2:'    ],
6536fb12b70Safresh1[ "Mac->catdir('d1','d2')",               ':d1:d2:'      ],
6546fb12b70Safresh1[ "Mac->catdir('d1','d2', '')",           ':d1:d2:'      ],
6556fb12b70Safresh1[ "Mac->catdir('d1','d2', ':')",          ':d1:d2:'      ],
6566fb12b70Safresh1[ "Mac->catdir('d1','d2', '::')",         ':d1:d2::'     ],
6576fb12b70Safresh1[ "Mac->catdir('d1','d2','','')",         ':d1:d2:'      ],
6586fb12b70Safresh1[ "Mac->catdir('d1','d2',':','::')",      ':d1:d2::'     ],
6596fb12b70Safresh1[ "Mac->catdir('d1','d2','::','::')",     ':d1:d2:::'    ],
6606fb12b70Safresh1[ "Mac->catdir('d1',':d2')",              ':d1:d2:'      ],
6616fb12b70Safresh1[ "Mac->catdir('d1',':d2:')",             ':d1:d2:'      ],
6626fb12b70Safresh1
6636fb12b70Safresh1[ "Mac->catdir('hd:',':d1')",       'hd:d1:'      ],
6646fb12b70Safresh1[ "Mac->catdir('hd:d1:',':d2')",    'hd:d1:d2:'   ],
6656fb12b70Safresh1[ "Mac->catdir('hd:','d1')",        'hd:d1:'      ],
6666fb12b70Safresh1[ "Mac->catdir('hd:d1:',':d2')",    'hd:d1:d2:'   ],
6676fb12b70Safresh1[ "Mac->catdir('hd:d1:',':d2:')",   'hd:d1:d2:'   ],
6686fb12b70Safresh1
6696fb12b70Safresh1[ "Mac->catfile()",                      ''                      ],
6706fb12b70Safresh1[ "Mac->catfile('')",                    ''                      ],
6716fb12b70Safresh1[ "Mac->catfile(':')",                   ':'                     ],
6726fb12b70Safresh1[ "Mac->catfile(':', '')",               ':'                     ],
6736fb12b70Safresh1
6746fb12b70Safresh1[ "Mac->catfile('d1','d2','file')",      ':d1:d2:file' ],
6756fb12b70Safresh1[ "Mac->catfile('d1','d2',':file')",     ':d1:d2:file' ],
6766fb12b70Safresh1[ "Mac->catfile('file')",                'file'        ],
6776fb12b70Safresh1[ "Mac->catfile(':', 'file')",           ':file'       ],
6786fb12b70Safresh1
6796fb12b70Safresh1[ "Mac->canonpath('')",                   ''     ],
6806fb12b70Safresh1[ "Mac->canonpath(':')",                  ':'    ],
6816fb12b70Safresh1[ "Mac->canonpath('::')",                 '::'   ],
6826fb12b70Safresh1[ "Mac->canonpath('a::')",                'a::'  ],
6836fb12b70Safresh1[ "Mac->canonpath(':a::')",               ':a::' ],
6846fb12b70Safresh1
6856fb12b70Safresh1[ "Mac->abs2rel('hd:d1:d2:','hd:d1:d2:')",            ':'            ],
6866fb12b70Safresh1[ "Mac->abs2rel('hd:d1:d2:','hd:d1:d2:file')",        ':'            ], # ignore base's file portion
6876fb12b70Safresh1[ "Mac->abs2rel('hd:d1:d2:file','hd:d1:d2:')",        ':file'        ],
6886fb12b70Safresh1[ "Mac->abs2rel('hd:d1:','hd:d1:d2:')",               '::'           ],
6896fb12b70Safresh1[ "Mac->abs2rel('hd:d3:','hd:d1:d2:')",               ':::d3:'       ],
6906fb12b70Safresh1[ "Mac->abs2rel('hd:d3:','hd:d1:d2::')",              '::d3:'        ],
6916fb12b70Safresh1[ "Mac->abs2rel('hd:d1:d4:d5:','hd:d1::d2:d3::')",    '::d1:d4:d5:'  ],
6926fb12b70Safresh1[ "Mac->abs2rel('hd:d1:d4:d5:','hd:d1::d2:d3:')",     ':::d1:d4:d5:' ], # first, resolve updirs in base
6936fb12b70Safresh1[ "Mac->abs2rel('hd:d1:d3:','hd:d1:d2:')",            '::d3:'        ],
6946fb12b70Safresh1[ "Mac->abs2rel('hd:d1::d3:','hd:d1:d2:')",           ':::d3:'       ],
6956fb12b70Safresh1[ "Mac->abs2rel('hd:d3:','hd:d1:d2:')",               ':::d3:'       ], # same as above
6966fb12b70Safresh1[ "Mac->abs2rel('hd:d1:d2:d3:','hd:d1:d2:')",         ':d3:'         ],
6976fb12b70Safresh1[ "Mac->abs2rel('hd:d1:d2:d3::','hd:d1:d2:')",        ':d3::'        ],
6986fb12b70Safresh1[ "Mac->abs2rel('hd1:d3:d4:d5:','hd2:d1:d2:')",       'hd1:d3:d4:d5:'], # volume mismatch
6996fb12b70Safresh1[ "Mac->abs2rel('hd:','hd:d1:d2:')",                  ':::'          ],
7006fb12b70Safresh1
7016fb12b70Safresh1[ "Mac->rel2abs(':d3:','hd:d1:d2:')",          'hd:d1:d2:d3:'     ],
7026fb12b70Safresh1[ "Mac->rel2abs(':d3:d4:','hd:d1:d2:')",       'hd:d1:d2:d3:d4:'  ],
7036fb12b70Safresh1[ "Mac->rel2abs('','hd:d1:d2:')",              ''                 ],
7046fb12b70Safresh1[ "Mac->rel2abs('::','hd:d1:d2:')",            'hd:d1:d2::'       ],
7056fb12b70Safresh1[ "Mac->rel2abs('::','hd:d1:d2:file')",        'hd:d1:d2::'       ],# ignore base's file portion
7066fb12b70Safresh1[ "Mac->rel2abs(':file','hd:d1:d2:')",         'hd:d1:d2:file'    ],
7076fb12b70Safresh1[ "Mac->rel2abs('::file','hd:d1:d2:')",        'hd:d1:d2::file'   ],
7086fb12b70Safresh1[ "Mac->rel2abs('::d3:','hd:d1:d2:')",         'hd:d1:d2::d3:'    ],
7096fb12b70Safresh1[ "Mac->rel2abs('hd:','hd:d1:d2:')",           'hd:'              ], # path already absolute
7106fb12b70Safresh1[ "Mac->rel2abs('hd:d3:file','hd:d1:d2:')",    'hd:d3:file'       ],
7116fb12b70Safresh1[ "Mac->rel2abs('hd:d3:','hd:d1:file')",       'hd:d3:'           ],
7126fb12b70Safresh1
7136fb12b70Safresh1[ "Epoc->case_tolerant()",         '1'  ],
7146fb12b70Safresh1
7156fb12b70Safresh1[ "Epoc->canonpath('')",                                      ''          ],
7166fb12b70Safresh1[ "Epoc->canonpath('///../../..//./././a//b/.././c/././')",   '/a/b/../c' ],
7176fb12b70Safresh1[ "Epoc->canonpath('/./')",                                   '/'         ],
7186fb12b70Safresh1[ "Epoc->canonpath('/a/./')",                                 '/a'        ],
7196fb12b70Safresh1
7206fb12b70Safresh1# XXX Todo, copied from Unix, but fail. Should they? 2003-07-07 Tels
7216fb12b70Safresh1#[ "Epoc->canonpath('/a/.')",                                  '/a'        ],
7226fb12b70Safresh1#[ "Epoc->canonpath('/.')",                                    '/'         ],
7236fb12b70Safresh1
7246fb12b70Safresh1[ "Cygwin->case_tolerant()",         '1'  ],
7256fb12b70Safresh1[ "Cygwin->catfile('a','b','c')",         'a/b/c'  ],
7266fb12b70Safresh1[ "Cygwin->catfile('a','b','./c')",       'a/b/c'  ],
7276fb12b70Safresh1[ "Cygwin->catfile('./a','b','c')",       'a/b/c'  ],
7286fb12b70Safresh1[ "Cygwin->catfile('c')",                 'c' ],
7296fb12b70Safresh1[ "Cygwin->catfile('./c')",               'c' ],
7306fb12b70Safresh1
7316fb12b70Safresh1[ "Cygwin->splitpath('file')",            ',,file'            ],
7326fb12b70Safresh1[ "Cygwin->splitpath('/d1/d2/d3/')",      ',/d1/d2/d3/,'      ],
7336fb12b70Safresh1[ "Cygwin->splitpath('d1/d2/d3/')",       ',d1/d2/d3/,'       ],
7346fb12b70Safresh1[ "Cygwin->splitpath('/d1/d2/d3/.')",     ',/d1/d2/d3/.,'     ],
7356fb12b70Safresh1[ "Cygwin->splitpath('/d1/d2/d3/..')",    ',/d1/d2/d3/..,'    ],
7366fb12b70Safresh1[ "Cygwin->splitpath('/d1/d2/d3/.file')", ',/d1/d2/d3/,.file' ],
7376fb12b70Safresh1[ "Cygwin->splitpath('d1/d2/d3/file')",   ',d1/d2/d3/,file'   ],
7386fb12b70Safresh1[ "Cygwin->splitpath('/../../d1/')",      ',/../../d1/,'      ],
7396fb12b70Safresh1[ "Cygwin->splitpath('/././d1/')",        ',/././d1/,'        ],
7406fb12b70Safresh1
7416fb12b70Safresh1[ "Cygwin->catpath('','','file')",            'file'            ],
7426fb12b70Safresh1[ "Cygwin->catpath('','/d1/d2/d3/','')",      '/d1/d2/d3/'      ],
7436fb12b70Safresh1[ "Cygwin->catpath('','d1/d2/d3/','')",       'd1/d2/d3/'       ],
7446fb12b70Safresh1[ "Cygwin->catpath('','/d1/d2/d3/.','')",     '/d1/d2/d3/.'     ],
7456fb12b70Safresh1[ "Cygwin->catpath('','/d1/d2/d3/..','')",    '/d1/d2/d3/..'    ],
7466fb12b70Safresh1[ "Cygwin->catpath('','/d1/d2/d3/','.file')", '/d1/d2/d3/.file' ],
7476fb12b70Safresh1[ "Cygwin->catpath('','d1/d2/d3/','file')",   'd1/d2/d3/file'   ],
7486fb12b70Safresh1[ "Cygwin->catpath('','/../../d1/','')",      '/../../d1/'      ],
7496fb12b70Safresh1[ "Cygwin->catpath('','/././d1/','')",        '/././d1/'        ],
7506fb12b70Safresh1[ "Cygwin->catpath('d1','d2/d3/','')",        'd2/d3/'          ],
7516fb12b70Safresh1[ "Cygwin->catpath('d1','d2','d3/')",         'd2/d3/'          ],
7526fb12b70Safresh1
7536fb12b70Safresh1[ "Cygwin->splitdir('')",           ''           ],
7546fb12b70Safresh1[ "Cygwin->splitdir('/d1/d2/d3/')", ',d1,d2,d3,' ],
7556fb12b70Safresh1[ "Cygwin->splitdir('d1/d2/d3/')",  'd1,d2,d3,'  ],
7566fb12b70Safresh1[ "Cygwin->splitdir('/d1/d2/d3')",  ',d1,d2,d3'  ],
7576fb12b70Safresh1[ "Cygwin->splitdir('d1/d2/d3')",   'd1,d2,d3'   ],
7586fb12b70Safresh1
7596fb12b70Safresh1[ "Cygwin->catdir()",                     ''          ],
7606fb12b70Safresh1[ "Cygwin->catdir('/')",                  '/'         ],
7616fb12b70Safresh1[ "Cygwin->catdir('','d1','d2','d3','')", '/d1/d2/d3' ],
7626fb12b70Safresh1[ "Cygwin->catdir('d1','d2','d3','')",    'd1/d2/d3'  ],
7636fb12b70Safresh1[ "Cygwin->catdir('','d1','d2','d3')",    '/d1/d2/d3' ],
7646fb12b70Safresh1[ "Cygwin->catdir('d1','d2','d3')",       'd1/d2/d3'  ],
7656fb12b70Safresh1[ "Cygwin->catdir('/','d2/d3')",     '/d2/d3'  ],
7666fb12b70Safresh1
7676fb12b70Safresh1[ "Cygwin->canonpath('///../../..//./././a//b/.././c/././')",   '/a/b/../c' ],
7686fb12b70Safresh1[ "Cygwin->canonpath('')",                       ''               ],
7696fb12b70Safresh1[ "Cygwin->canonpath('a/../../b/c')",            'a/../../b/c'    ],
7706fb12b70Safresh1[ "Cygwin->canonpath('/.')",                     '/'              ],
7716fb12b70Safresh1[ "Cygwin->canonpath('/./')",                    '/'              ],
7726fb12b70Safresh1[ "Cygwin->canonpath('/a/./')",                  '/a'             ],
7736fb12b70Safresh1[ "Cygwin->canonpath('/a/.')",                   '/a'             ],
7746fb12b70Safresh1[ "Cygwin->canonpath('/../../')",                '/'              ],
7756fb12b70Safresh1[ "Cygwin->canonpath('/../..')",                 '/'              ],
7766fb12b70Safresh1
7776fb12b70Safresh1[  "Cygwin->abs2rel('/t1/t2/t3','/t1/t2/t3')",          '.'                  ],
7786fb12b70Safresh1[  "Cygwin->abs2rel('/t1/t2/t4','/t1/t2/t3')",          '../t4'              ],
7796fb12b70Safresh1[  "Cygwin->abs2rel('/t1/t2','/t1/t2/t3')",             '..'                 ],
7806fb12b70Safresh1[  "Cygwin->abs2rel('/t1/t2/t3/t4','/t1/t2/t3')",       't4'                 ],
7816fb12b70Safresh1[  "Cygwin->abs2rel('/t4/t5/t6','/t1/t2/t3')",          '../../../t4/t5/t6'  ],
7826fb12b70Safresh1#[ "Cygwin->abs2rel('../t4','/t1/t2/t3')",              '../t4'              ],
7836fb12b70Safresh1[  "Cygwin->abs2rel('/','/t1/t2/t3')",                  '../../..'           ],
7846fb12b70Safresh1[  "Cygwin->abs2rel('///','/t1/t2/t3')",                '../../..'           ],
7856fb12b70Safresh1[  "Cygwin->abs2rel('/.','/t1/t2/t3')",                 '../../..'           ],
7866fb12b70Safresh1[  "Cygwin->abs2rel('/./','/t1/t2/t3')",                '../../..'           ],
7876fb12b70Safresh1#[ "Cygwin->abs2rel('../t4','/t1/t2/t3')",              '../t4'              ],
7886fb12b70Safresh1[  "Cygwin->abs2rel('/t1/t2/t3', '/')",                 't1/t2/t3'           ],
7896fb12b70Safresh1[  "Cygwin->abs2rel('/t1/t2/t3', '/t1')",               't2/t3'              ],
7906fb12b70Safresh1[  "Cygwin->abs2rel('t1/t2/t3', 't1')",                 't2/t3'              ],
7916fb12b70Safresh1[  "Cygwin->abs2rel('t1/t2/t3', 't4')",                 '../t1/t2/t3'        ],
7926fb12b70Safresh1
7936fb12b70Safresh1[ "Cygwin->rel2abs('t4','/t1/t2/t3')",             '/t1/t2/t3/t4'    ],
7946fb12b70Safresh1[ "Cygwin->rel2abs('t4/t5','/t1/t2/t3')",          '/t1/t2/t3/t4/t5' ],
7956fb12b70Safresh1[ "Cygwin->rel2abs('.','/t1/t2/t3')",              '/t1/t2/t3'       ],
7966fb12b70Safresh1[ "Cygwin->rel2abs('..','/t1/t2/t3')",             '/t1/t2/t3/..'    ],
7976fb12b70Safresh1[ "Cygwin->rel2abs('../t4','/t1/t2/t3')",          '/t1/t2/t3/../t4' ],
7986fb12b70Safresh1[ "Cygwin->rel2abs('/t1','/t1/t2/t3')",            '/t1'             ],
7996fb12b70Safresh1[ "Cygwin->rel2abs('//t1/t2/t3','/foo')",          '//t1/t2/t3'      ],
8006fb12b70Safresh1
8016fb12b70Safresh1) ;
8026fb12b70Safresh1
8036fb12b70Safresh1{
8046fb12b70Safresh1    package File::Spec::FakeWin32;
8059f11ffb7Safresh1    our @ISA = qw(File::Spec::Win32);
8066fb12b70Safresh1
8076fb12b70Safresh1    # Some funky stuff to override Cwd::getdcwd() for testing purposes,
8086fb12b70Safresh1    # in the limited scope of the rel2abs() method.
8096fb12b70Safresh1    if ($Cwd::VERSION && $Cwd::VERSION gt '2.17') {  # Avoid a 'used only once' warning
8106fb12b70Safresh1	local $^W;
8116fb12b70Safresh1	*rel2abs = sub {
8126fb12b70Safresh1	    my $self = shift;
8136fb12b70Safresh1	    local $^W;
8149f11ffb7Safresh1	    local *Cwd::getcwd = sub { 'C:\\one\\two' };
8159f11ffb7Safresh1	    *Cwd::getcwd = *Cwd::getcwd; # Avoid a 'used only once' warning
8166fb12b70Safresh1	    local *Cwd::getdcwd = sub {
8176fb12b70Safresh1	      return 'D:\alpha\beta' if $_[0] eq 'D:';
8186fb12b70Safresh1	      return 'C:\one\two'    if $_[0] eq 'C:';
8196fb12b70Safresh1	      return;
8206fb12b70Safresh1	    };
8216fb12b70Safresh1	    *Cwd::getdcwd = *Cwd::getdcwd; # Avoid a 'used only once' warning
8226fb12b70Safresh1	    return $self->SUPER::rel2abs(@_);
8236fb12b70Safresh1	};
8246fb12b70Safresh1	*rel2abs = *rel2abs; # Avoid a 'used only once' warning
8259f11ffb7Safresh1	*abs2rel = sub {
8269f11ffb7Safresh1	    my $self = shift;
8279f11ffb7Safresh1	    local $^W;
8289f11ffb7Safresh1	    local *Cwd::getcwd = sub { 'C:\\one\\two' };
8299f11ffb7Safresh1	    *Cwd::getcwd = *Cwd::getcwd; # Avoid a 'used only once' warning
8309f11ffb7Safresh1	    return $self->SUPER::abs2rel(@_);
8319f11ffb7Safresh1	};
8329f11ffb7Safresh1	*abs2rel = *abs2rel; # Avoid a 'used only once' warning
8336fb12b70Safresh1    }
8346fb12b70Safresh1}
8356fb12b70Safresh1
8366fb12b70Safresh1# Tries a named function with the given args and compares the result against
8376fb12b70Safresh1# an expected result. Works with functions that return scalars or arrays.
8386fb12b70Safresh1for ( @tests ) {
8396fb12b70Safresh1    my ($function, $expected) = @$_;
8406fb12b70Safresh1
8416fb12b70Safresh1    $function =~ s#\\#\\\\#g ;
8426fb12b70Safresh1    $function =~ s/^([^\$].*->)/File::Spec::$1/;
8436fb12b70Safresh1    my $got = join ',', eval $function;
8446fb12b70Safresh1
8456fb12b70Safresh1 SKIP: {
8466fb12b70Safresh1	if ($@) {
8476fb12b70Safresh1	    skip "skip $function: $skip_exception", 1
8486fb12b70Safresh1		if $@ =~ /^\Q$skip_exception/;
8496fb12b70Safresh1	    is($@, '', $function);
8506fb12b70Safresh1	} else {
8516fb12b70Safresh1	    is($got, $expected, $function);
8526fb12b70Safresh1	}
8536fb12b70Safresh1    }
8546fb12b70Safresh1}
8556fb12b70Safresh1
8566fb12b70Safresh1is +File::Spec::Unix->canonpath(), undef;
8576fb12b70Safresh1
8586fb12b70Safresh1done_testing();
859