Permalink
Browse files

catdir done

  • Loading branch information...
1 parent 3b42e0f commit 413eaeccd6628bff677fb9f9f951fbf5cd0d8abb @FROGGS committed Sep 14, 2012
Showing with 12 additions and 7 deletions.
  1. +1 −1 README.md
  2. +1 −1 lib/File/Spec.pm
  3. +1 −3 lib/File/Spec/Unix.pm
  4. +9 −2 t/01_unix.t
View
@@ -10,7 +10,7 @@ Methods (current state):
Unix Mac OS2 Win32 VMS
canonpath done
- catdir
+ catdir done
catfile
curdir done done done
devnull done done done
View
@@ -19,7 +19,7 @@ require $module;
class File::Spec {
method canonpath( $path ) { ::($module).canonpath( $path ) }
- method catdir { ::($module).catdir() }
+ method catdir( *@parts ) { ::($module).catdir( @parts ) }
method catfile { ::($module).catfile() }
method curdir { ::($module).curdir() }
method devnull { ::($module).devnull() }
View
@@ -27,9 +27,7 @@ class File::Spec::Unix {
return "$node$path";
}
- method catdir {
-
- }
+ method catdir( @parts ) { self.canonpath( (@parts, '').join('/') ) }
method catfile {
View
@@ -9,7 +9,6 @@ if $*OS ~~ any(<MacOS MSWin32 os2 VMS epoc NetWare symbian dos cygwin>) {
skip_rest 'this is not Unix\'ish'
}
else {
- #canonpath
my %canonpath = (
'///../../..//./././a//b/.././c/././' => '/a/b/../c',
'' => '',
@@ -26,7 +25,15 @@ else {
is File::Spec.canonpath( $get ), $want, "canonpath: '$get' -> '$want'";
}
- #catdir
+ is File::Spec.catdir( ), '', "catdir: no arg -> ''";
+ is File::Spec.catdir( '' ), '/', "catdir: '' -> '/'";
+ is File::Spec.catdir( '/' ), '/', "catdir: '/' -> '/'";
+ is File::Spec.catdir( '','d1','d2','d3','' ), '/d1/d2/d3', "catdir: ('','d1','d2','d3','') -> '/d1/d2/d3'";
+ is File::Spec.catdir( 'd1','d2','d3','' ), 'd1/d2/d3', "catdir: ('d1','d2','d3','') -> 'd1/d2/d3'";
+ is File::Spec.catdir( '','d1','d2','d3' ), '/d1/d2/d3', "catdir: ('','d1','d2','d3') -> '/d1/d2/d3'";
+ is File::Spec.catdir( 'd1','d2','d3' ), 'd1/d2/d3', "catdir: ('d1','d2','d3') -> 'd1/d2/d3'";
+ is File::Spec.catdir( '/','d2/d3' ), '/d2/d3', "catdir: ('/','d2/d3') -> '/d2/d3'";
+
#catfile
is File::Spec.curdir, '.', 'curdir is "."';
is File::Spec.devnull, '/dev/null', 'devnull is /dev/null';

0 comments on commit 413eaec

Please sign in to comment.