From: Reini Urban Date: Wed, 20 Jun 2007 21:10:05 +0000 (+0200) Subject: File::Spec::Cygwin more tests and silence warning X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e4f3fca48b547d000a2f9fa8f3ca08566d87f410;p=p5sagit%2Fp5-mst-13.2.git File::Spec::Cygwin more tests and silence warning Message-ID: <46797B8D.8040002@x-ray.at> p4raw-id: //depot/perl@31440 --- diff --git a/lib/File/Spec/Cygwin.pm b/lib/File/Spec/Cygwin.pm index 9423eec..e2744f0 100644 --- a/lib/File/Spec/Cygwin.pm +++ b/lib/File/Spec/Cygwin.pm @@ -53,7 +53,7 @@ sub catdir { my $self = shift; # Don't create something that looks like a //network/path - if ($_[0] eq '/' or $_[0] eq '\\') { + if ($_[0] and ($_[0] eq '/' or $_[0] eq '\\')) { shift; return $self->SUPER::catdir('', @_); } diff --git a/lib/File/Spec/t/Spec.t b/lib/File/Spec/t/Spec.t index 5ca4caf..a39779f 100644 --- a/lib/File/Spec/t/Spec.t +++ b/lib/File/Spec/t/Spec.t @@ -620,8 +620,81 @@ if ($^O eq 'MacOS') { #[ "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' ], + ) ;