📄 spec.t
字号:
[ "Mac->catdir('', '::')", $root, 'MacOS' ], # skipped on other OS[ "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('','d1','d2','d3')", $root . 'd1:d2:d3:', 'MacOS' ], # skipped on other OS[ "Mac->catdir('',':','d1','d2')", $root . 'd1:d2:' , 'MacOS' ], # skipped on other OS[ "Mac->catdir('','::','d1','d2')", $root . 'd1:d2:' , 'MacOS' ], # skipped on other OS[ "Mac->catdir('',':','','d1')", $root . 'd1:' , 'MacOS' ], # skipped on other OS[ "Mac->catdir('', ':d1',':d2')", $root . 'd1:d2:' , 'MacOS' ], # skipped on other OS[ "Mac->catdir('','',':d1',':d2')", $root . 'd1:d2:' , 'MacOS' ], # skipped on other OS[ "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('', '')", $root , 'MacOS' ], # skipped on other OS[ "Mac->catfile('', 'file')", $root . 'file', 'MacOS' ], # skipped on other OS[ "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()", '1' ],[ "Cygwin->catfile('a','b','c')", 'a/b/c' ],[ "Cygwin->catfile('a','b','./c')", 'a/b/c' ],[ "Cygwin->catfile('./a','b','c')", 'a/b/c' ],[ "Cygwin->catfile('c')", 'c' ],[ "Cygwin->catfile('./c')", 'c' ],[ "Cygwin->splitpath('file')", ',,file' ],[ "Cygwin->splitpath('/d1/d2/d3/')", ',/d1/d2/d3/,' ],[ "Cygwin->splitpath('d1/d2/d3/')", ',d1/d2/d3/,' ],[ "Cygwin->splitpath('/d1/d2/d3/.')", ',/d1/d2/d3/.,' ],[ "Cygwin->splitpath('/d1/d2/d3/..')", ',/d1/d2/d3/..,' ],[ "Cygwin->splitpath('/d1/d2/d3/.file')", ',/d1/d2/d3/,.file' ],[ "Cygwin->splitpath('d1/d2/d3/file')", ',d1/d2/d3/,file' ],[ "Cygwin->splitpath('/../../d1/')", ',/../../d1/,' ],[ "Cygwin->splitpath('/././d1/')", ',/././d1/,' ],[ "Cygwin->catpath('','','file')", 'file' ],[ "Cygwin->catpath('','/d1/d2/d3/','')", '/d1/d2/d3/' ],[ "Cygwin->catpath('','d1/d2/d3/','')", 'd1/d2/d3/' ],[ "Cygwin->catpath('','/d1/d2/d3/.','')", '/d1/d2/d3/.' ],[ "Cygwin->catpath('','/d1/d2/d3/..','')", '/d1/d2/d3/..' ],[ "Cygwin->catpath('','/d1/d2/d3/','.file')", '/d1/d2/d3/.file' ],[ "Cygwin->catpath('','d1/d2/d3/','file')", 'd1/d2/d3/file' ],[ "Cygwin->catpath('','/../../d1/','')", '/../../d1/' ],[ "Cygwin->catpath('','/././d1/','')", '/././d1/' ],[ "Cygwin->catpath('d1','d2/d3/','')", 'd2/d3/' ],[ "Cygwin->catpath('d1','d2','d3/')", 'd2/d3/' ],[ "Cygwin->splitdir('')", '' ],[ "Cygwin->splitdir('/d1/d2/d3/')", ',d1,d2,d3,' ],[ "Cygwin->splitdir('d1/d2/d3/')", 'd1,d2,d3,' ],[ "Cygwin->splitdir('/d1/d2/d3')", ',d1,d2,d3' ],[ "Cygwin->splitdir('d1/d2/d3')", 'd1,d2,d3' ],[ "Cygwin->catdir()", '' ],[ "Cygwin->catdir('/')", '/' ],[ "Cygwin->catdir('','d1','d2','d3','')", '/d1/d2/d3' ],[ "Cygwin->catdir('d1','d2','d3','')", 'd1/d2/d3' ],[ "Cygwin->catdir('','d1','d2','d3')", '/d1/d2/d3' ],[ "Cygwin->catdir('d1','d2','d3')", 'd1/d2/d3' ],[ "Cygwin->catdir('/','d2/d3')", '/d2/d3' ],[ "Cygwin->canonpath('///../../..//./././a//b/.././c/././')", '/a/b/../c' ],[ "Cygwin->canonpath('')", '' ],[ "Cygwin->canonpath('a/../../b/c')", 'a/../../b/c' ],[ "Cygwin->canonpath('/.')", '/' ],[ "Cygwin->canonpath('/./')", '/' ],[ "Cygwin->canonpath('/a/./')", '/a' ],[ "Cygwin->canonpath('/a/.')", '/a' ],[ "Cygwin->canonpath('/../../')", '/' ],[ "Cygwin->canonpath('/../..')", '/' ],[ "Cygwin->abs2rel('/t1/t2/t3','/t1/t2/t3')", '.' ],[ "Cygwin->abs2rel('/t1/t2/t4','/t1/t2/t3')", '../t4' ],[ "Cygwin->abs2rel('/t1/t2','/t1/t2/t3')", '..' ],[ "Cygwin->abs2rel('/t1/t2/t3/t4','/t1/t2/t3')", 't4' ],[ "Cygwin->abs2rel('/t4/t5/t6','/t1/t2/t3')", '../../../t4/t5/t6' ],#[ "Cygwin->abs2rel('../t4','/t1/t2/t3')", '../t4' ],[ "Cygwin->abs2rel('/','/t1/t2/t3')", '../../..' ],[ "Cygwin->abs2rel('///','/t1/t2/t3')", '../../..' ],[ "Cygwin->abs2rel('/.','/t1/t2/t3')", '../../..' ],[ "Cygwin->abs2rel('/./','/t1/t2/t3')", '../../..' ],#[ "Cygwin->abs2rel('../t4','/t1/t2/t3')", '../t4' ],[ "Cygwin->abs2rel('/t1/t2/t3', '/')", 't1/t2/t3' ],[ "Cygwin->abs2rel('/t1/t2/t3', '/t1')", 't2/t3' ],[ "Cygwin->abs2rel('t1/t2/t3', 't1')", 't2/t3' ],[ "Cygwin->abs2rel('t1/t2/t3', 't4')", '../t1/t2/t3' ],[ "Cygwin->rel2abs('t4','/t1/t2/t3')", '/t1/t2/t3/t4' ],[ "Cygwin->rel2abs('t4/t5','/t1/t2/t3')", '/t1/t2/t3/t4/t5' ],[ "Cygwin->rel2abs('.','/t1/t2/t3')", '/t1/t2/t3' ],[ "Cygwin->rel2abs('..','/t1/t2/t3')", '/t1/t2/t3/..' ],[ "Cygwin->rel2abs('../t4','/t1/t2/t3')", '/t1/t2/t3/../t4' ],[ "Cygwin->rel2abs('/t1','/t1/t2/t3')", '/t1' ],) ;plan tests => scalar @tests;{ package File::Spec::FakeWin32; use vars qw(@ISA); @ISA = qw(File::Spec::Win32); sub _cwd { 'C:\\one\\two' } # Some funky stuff to override Cwd::getdcwd() for testing purposes, # in the limited scope of the rel2abs() method. if ($Cwd::VERSION && $Cwd::VERSION gt '2.17') { # Avoid a 'used only once' warning local $^W; *rel2abs = sub { my $self = shift; local $^W; local *Cwd::getdcwd = sub { return 'D:\alpha\beta' if $_[0] eq 'D:'; return 'C:\one\two' if $_[0] eq 'C:'; return; }; *Cwd::getdcwd = *Cwd::getdcwd; # Avoid a 'used only once' warning return $self->SUPER::rel2abs(@_); }; *rel2abs = *rel2abs; # Avoid a 'used only once' warning }}# Test out the class methodsfor ( @tests ) { tryfunc( @$_ ) ;}## 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 ; if ($platform && $^O ne $platform) { skip("skip $function", 1); return; } $function =~ s#\\#\\\\#g ; $function =~ s/^([^\$].*->)/File::Spec::$1/; my $got = join ',', eval $function; if ( $@ ) { if ( $@ =~ /^\Q$skip_exception/ ) { skip "skip $function: $skip_exception", 1; } else { ok $@, '', $function; } return; } ok $got, $expected, $function;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -