use Test;
# Grab all of the plain routines from File::Spec
eval {
} ;
my $skip_exception = "Install VMS::Filespec (from vms/ext)" ;
if ( $@ ) {
# Not pretty, but it allows testing of things not implemented soley
# on VMS. It might be better to change File::Spec::VMS to do this,
# making it more usable when running on (say) Unix but working with
# VMS paths.
eval qq-
- ;
}
# $root is only needed by Mac OS tests; these particular
# tests are skipped on other OSs
}
# Each element in this array is a single test. Storing them this way makes
# maintenance easy, and should be OK since perl should be pretty functional
# before these tests are run.
@tests = (
# [ Function , Expected , Platform ]
[ "Unix->case_tolerant()", '0' ],
[ "Unix->catfile('a','b','c')", 'a/b/c' ],
[ "Unix->catfile('a','b','./c')", 'a/b/c' ],
[ "Unix->catfile('./a','b','c')", 'a/b/c' ],
[ "Unix->catfile('c')", 'c' ],
[ "Unix->catfile('./c')", 'c' ],
[ "Unix->splitpath('file')", ',,file' ],
[ "Unix->splitpath('/../../d1/')", ',/../../d1/,' ],
[ "Unix->splitpath('/././d1/')", ',/././d1/,' ],
[ "Unix->catpath('','','file')", 'file' ],
[ "Unix->catpath('','/../../d1/','')", '/../../d1/' ],
[ "Unix->catpath('','/././d1/','')", '/././d1/' ],
[ "Unix->splitdir('')", '' ],
[ "Unix->catdir()", '' ],
[ "Unix->catdir('/')", '/' ],
[ "Unix->canonpath('')", '' ],
[ "Unix->canonpath('///../../..//./././a//b/.././c/././')", '/a/b/../c' ],
[ "Unix->canonpath('/.')", '/' ],
[ "Unix->canonpath('/./')", '/' ],
[ "Unix->canonpath('/a/./')", '/a' ],
[ "Unix->canonpath('/a/.')", '/a' ],
[ "Win32->case_tolerant()", '1' ],
[ "Win32->splitpath('file')", ',,file' ],
[ "Win32->splitpath('\\../..\\d1/')", ',\\../..\\d1/,' ],
[ "Win32->splitpath('\\./.\\d1/')", ',\\./.\\d1/,' ],
[ "Win32->splitpath('file',1)", ',file,' ],
[ "Win32->catpath('','','file')", 'file' ],
[ "Win32->catpath('','\\../..\\d1/','')", '\\../..\\d1/' ],
[ "Win32->catpath('','\\./.\\d1/','')", '\\./.\\d1/' ],
[ "Win32->splitdir('')", '' ],
[ "Win32->catdir()", '' ],
[ "Win32->catdir('')", '\\' ],
[ "Win32->catdir('/')", '\\' ],
[ "Win32->catdir('/', '../')", '\\' ],
[ "Win32->catdir('/', '..\\')", '\\' ],
[ "Win32->catdir('\\', '../')", '\\' ],
[ "Win32->catdir('\\', '..\\')", '\\' ],
[ "Win32->catdir('A:/')", 'A:\\' ],
[ "Win32->catfile('a','b','c')", 'a\\b\\c' ],
[ "Win32->catfile('a','b','.\\c')", 'a\\b\\c' ],
[ "Win32->catfile('.\\a','b','c')", 'a\\b\\c' ],
[ "Win32->catfile('c')", 'c' ],
[ "Win32->catfile('.\\c')", 'c' ],
[ "Win32->canonpath('')", '' ],
[ "Win32->canonpath('a:')", 'A:' ],
[ "Win32->canonpath('A:f')", 'A:f' ],
[ "Win32->canonpath('A:/')", 'A:\\' ],
[ "Win32->canonpath('//a\\b//c')", '\\\\a\\b\\c' ],
[ "Win32->canonpath('/a/..../c')", '\\a\\....\\c' ],
[ "Win32->canonpath('//a/b\\c')", '\\\\a\\b\\c' ],
[ "Win32->canonpath('////')", '\\\\\\' ],
[ "Win32->canonpath('//')", '\\' ],
[ "Win32->canonpath('/.')", '\\.' ],
[ "Win32->canonpath('//a/b/../../c')", '\\\\a\\b\\c' ],
[ "Win32->canonpath('//a/b/c/../d')", '\\\\a\\b\\d' ],
[ "Win32->canonpath('//a/b/c/../../d')",'\\\\a\\b\\d' ],
[ "Win32->canonpath('//a/b/c/.../d')", '\\\\a\\b\\d' ],
[ "Win32->canonpath('/a/b/c/../../d')", '\\a\\d' ],
[ "Win32->canonpath('/a/b/c/.../d')", '\\a\\d' ],
[ "Win32->canonpath('\\../')", '\\' ],
[ "Win32->canonpath('\\..\\')", '\\' ],
[ "Win32->canonpath('/../')", '\\' ],
[ "Win32->canonpath('/..\\')", '\\' ],
# FakeWin32 subclass (see below) just sets CWD to C:\one\two
[ "FakeWin32->rel2abs('../','C:/')", 'C:\\' ],
[ "FakeWin32->rel2abs('../','C:/a')", 'C:\\' ],
[ "VMS->case_tolerant()", '1' ],
[ "VMS->catfile('c')", 'c' ],
[ "VMS->catfile('[]c')", 'c' ],
[ "VMS->splitpath('node\"access_spec\"::volume:[d1.d2.d3]')", 'node"access_spec"::volume:,[d1.d2.d3],' ],
[ "VMS->splitpath('node\"access_spec\"::volume:[d1.d2.d3]file')", 'node"access_spec"::volume:,[d1.d2.d3],file' ],
[ "VMS->catpath('node\"access_spec\"::volume:','[d1.d2.d3]','')", 'node"access_spec"::volume:[d1.d2.d3]' ],
[ "VMS->catpath('node\"access_spec\"::volume:','[d1.d2.d3]','file')", 'node"access_spec"::volume:[d1.d2.d3]file' ],
[ "VMS->canonpath('')", '' ],
[ "VMS->splitdir('')", '' ],
[ "VMS->splitdir('[]')", '' ],
[ "VMS->catdir('')", '' ],
[ "OS2->case_tolerant()", '1' ],
[ "OS2->catfile('a','b','c')", 'a/b/c' ],
[ "OS2->catfile('a','b','./c')", 'a/b/c' ],
[ "OS2->catfile('./a','b','c')", 'a/b/c' ],
[ "OS2->catfile('c')", 'c' ],
[ "OS2->catfile('./c')", 'c' ],
[ "OS2->catdir('/', '../')", '/' ],
[ "OS2->catdir('/', '..\\')", '/' ],
[ "OS2->catdir('\\', '../')", '/' ],
[ "OS2->catdir('\\', '..\\')", '/' ],
[ "Mac->case_tolerant()", '1' ],
[ "Mac->catpath('','','')", '' ],
[ "Mac->catpath('',':','')", ':' ],
[ "Mac->catpath('','::','')", '::' ],
[ "Mac->splitpath(':')", ',:,' ],
[ "Mac->splitpath('::')", ',::,' ],
[ "Mac->splitpath(':::')", ',:::,' ],
[ "Mac->splitdir()", '' ],
[ "Mac->splitdir('')", '' ],
[ "Mac->splitdir(':')", ':' ],
[ "Mac->splitdir('::')", '::' ],
[ "Mac->splitdir(':::')", '::,::' ],
[ "Mac->splitdir('hd:')", 'hd:' ],
[ "Mac->splitdir('hd::')", 'hd:,::' ], # invalid path, but it works
[ "Mac->splitdir('hd::d1:')", 'hd:,::,d1' ], # invalid path, but it works
[ "Mac->splitdir('hd:d1:d2:::')", 'hd:,d1,d2,::,::' ],
[ "Mac->splitdir('hd:d1:d2::')", 'hd:,d1,d2,::' ],
[ "Mac->splitdir('hd:d1:d2:')", 'hd:,d1,d2' ],
[ "Mac->splitdir('hd:d1:d2')", 'hd:,d1,d2' ],
[ "Mac->splitdir('hd:d1::d2::')", 'hd:,d1,::,d2,::' ],
[ "Mac->catdir()", '' ],
[ "Mac->catdir(':')", ':' ],
[ "Mac->catdir(':', ':')", ':' ],
[ "Mac->catdir(':', '')", ':' ],
[ "Mac->catdir(':', '::')", '::' ],
[ "Mac->catdir('::', '')", '::' ],
[ "Mac->catdir('::', ':')", '::' ],
[ "Mac->catdir('::', '::')", ':::' ],
[ "Mac->catdir(':d1')", ':d1:' ],
[ "Mac->catdir(':d1:')", ':d1:' ],
[ "Mac->catdir(':d1','d2')", ':d1:d2:' ],
[ "Mac->catdir(':d1',':d2')", ':d1:d2:' ],
[ "Mac->catdir(':d1',':d2:')", ':d1:d2:' ],
[ "Mac->catdir(':d1',':d2::')", ':d1:d2::' ],
[ "Mac->catdir(':',':d1',':d2')", ':d1:d2:' ],
[ "Mac->catdir('::',':d1',':d2')", '::d1:d2:' ],
[ "Mac->catdir('::','::',':d1',':d2')", ':::d1:d2:' ],
[ "Mac->catdir(':',':',':d1',':d2')", ':d1:d2:' ],
[ "Mac->catdir('::',':',':d1',':d2')", '::d1:d2:' ],
[ "Mac->catdir('d1')", ':d1:' ],
[ "Mac->catdir('d1','d2','d3')", ':d1:d2:d3:' ],
[ "Mac->catdir('d1','d2/','d3')", ':d1:d2/:d3:' ],
[ "Mac->catdir('d1','',':d2')", ':d1:d2:' ],
[ "Mac->catdir('d1',':',':d2')", ':d1:d2:' ],
[ "Mac->catdir('d1','::',':d2')", ':d1::d2:' ],
[ "Mac->catdir('d1',':::',':d2')", ':d1:::d2:' ],
[ "Mac->catdir('d1','::','::',':d2')", ':d1:::d2:' ],
[ "Mac->catdir('d1','d2')", ':d1:d2:' ],
[ "Mac->catdir('d1','d2', '')", ':d1:d2:' ],
[ "Mac->catdir('d1','d2', ':')", ':d1:d2:' ],
[ "Mac->catdir('d1','d2', '::')", ':d1:d2::' ],
[ "Mac->catdir('d1','d2','','')", ':d1:d2:' ],
[ "Mac->catdir('d1','d2',':','::')", ':d1:d2::' ],
[ "Mac->catdir('d1','d2','::','::')", ':d1:d2:::' ],
[ "Mac->catdir('d1',':d2')", ':d1:d2:' ],
[ "Mac->catdir('d1',':d2:')", ':d1:d2:' ],
[ "Mac->catdir('hd:',':d1')", 'hd:d1:' ],
[ "Mac->catdir('hd:d1:',':d2')", 'hd:d1:d2:' ],
[ "Mac->catdir('hd:','d1')", 'hd:d1:' ],
[ "Mac->catdir('hd:d1:',':d2')", 'hd:d1:d2:' ],
[ "Mac->catdir('hd:d1:',':d2:')", 'hd:d1:d2:' ],
[ "Mac->catfile()", '' ],
[ "Mac->catfile('')", '' ],
[ "Mac->catfile(':')", ':' ],
[ "Mac->catfile(':', '')", ':' ],
[ "Mac->catfile('d1','d2','file')", ':d1:d2:file' ],
[ "Mac->catfile('d1','d2',':file')", ':d1:d2:file' ],
[ "Mac->catfile('file')", 'file' ],
[ "Mac->catfile(':', 'file')", ':file' ],
[ "Mac->canonpath('')", '' ],
[ "Mac->canonpath(':')", ':' ],
[ "Mac->canonpath('::')", '::' ],
[ "Mac->canonpath('a::')", 'a::' ],
[ "Mac->canonpath(':a::')", ':a::' ],
[ "Mac->abs2rel('hd:d1:d2:','hd:d1:d2:')", ':' ],
[ "Mac->abs2rel('hd:d1:d2:','hd:d1:d2:file')", ':' ], # ignore base's file portion
[ "Mac->abs2rel('hd:d1:d2:file','hd:d1:d2:')", ':file' ],
[ "Mac->abs2rel('hd:d1:','hd:d1:d2:')", '::' ],
[ "Mac->abs2rel('hd:d3:','hd:d1:d2:')", ':::d3:' ],
[ "Mac->abs2rel('hd:d3:','hd:d1:d2::')", '::d3:' ],
[ "Mac->abs2rel('hd:d1:d4:d5:','hd:d1::d2:d3::')", '::d1:d4:d5:' ],
[ "Mac->abs2rel('hd:d1:d4:d5:','hd:d1::d2:d3:')", ':::d1:d4:d5:' ], # first, resolve updirs in base
[ "Mac->abs2rel('hd:d1:d3:','hd:d1:d2:')", '::d3:' ],
[ "Mac->abs2rel('hd:d1::d3:','hd:d1:d2:')", ':::d3:' ],
[ "Mac->abs2rel('hd:d3:','hd:d1:d2:')", ':::d3:' ], # same as above
[ "Mac->abs2rel('hd:d1:d2:d3:','hd:d1:d2:')", ':d3:' ],
[ "Mac->abs2rel('hd:d1:d2:d3::','hd:d1:d2:')", ':d3::' ],
[ "Mac->abs2rel('hd1:d3:d4:d5:','hd2:d1:d2:')", 'hd1:d3:d4:d5:'], # volume mismatch
[ "Mac->abs2rel('hd:','hd:d1:d2:')", ':::' ],
[ "Mac->rel2abs(':d3:','hd:d1:d2:')", 'hd:d1:d2:d3:' ],
[ "Mac->rel2abs(':d3:d4:','hd:d1:d2:')", 'hd:d1:d2:d3:d4:' ],
[ "Mac->rel2abs('','hd:d1:d2:')", '' ],
[ "Mac->rel2abs('::','hd:d1:d2:')", 'hd:d1:d2::' ],
[ "Mac->rel2abs('::','hd:d1:d2:file')", 'hd:d1:d2::' ],# ignore base's file portion
[ "Mac->rel2abs(':file','hd:d1:d2:')", 'hd:d1:d2:file' ],
[ "Mac->rel2abs('::file','hd:d1:d2:')", 'hd:d1:d2::file' ],
[ "Mac->rel2abs('::d3:','hd:d1:d2:')", 'hd:d1:d2::d3:' ],
[ "Mac->rel2abs('hd:','hd:d1:d2:')", 'hd:' ], # path already absolute
[ "Mac->rel2abs('hd:d3:file','hd:d1:d2:')", 'hd:d3:file' ],
[ "Mac->rel2abs('hd:d3:','hd:d1:file')", 'hd:d3:' ],
[ "Epoc->case_tolerant()", '1' ],
[ "Epoc->canonpath('')", '' ],
[ "Epoc->canonpath('///../../..//./././a//b/.././c/././')", '/a/b/../c' ],
[ "Epoc->canonpath('/./')", '/' ],
[ "Epoc->canonpath('/a/./')", '/a' ],
# XXX Todo, copied from Unix, but fail. Should they? 2003-07-07 Tels
#[ "Epoc->canonpath('/a/.')", '/a' ],
#[ "Epoc->canonpath('/.')", '/' ],
[ "Cygwin->case_tolerant()", '0' ],
) ;
{
}
# Test out the class methods
}
#
# Tries a named function with the given args and compares the result against
# an expected result. Works with functions that return scalars or arrays.
#
sub tryfunc {
my $function = shift ;
my $expected = shift ;
my $platform = shift ;
return;
}
$function =~ s#\\#\\\\#g ;
if ( $@ ) {
}
else {
}
return;
}
}