Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

splitdir done

  • Loading branch information...
commit e75fa9220cb2ea0e41be1e23d150643dc4e3a2cd 1 parent 57cf401
@FROGGS authored
View
2  README.md
@@ -23,7 +23,7 @@ Methods (current state):
path done
join done
splitpath done
- splitdir
+ splitdir done
catpath
abs2rel
rel2abs
View
2  lib/File/Spec.pm
@@ -32,7 +32,7 @@ class File::Spec {
method path { ::($module).path() }
method join( *@parts ) { ::($module).join( @parts ) }
method splitpath( $path, $no_file = 0 ) { ::($module).splitpath( $path, $no_file ) }
- method splitdir { ::($module).splitdir() }
+ method splitdir( $path ) { ::($module).splitdir( $path ) }
method catpath { ::($module).catpath() }
method abs2rel { ::($module).abs2rel() }
method rel2abs { ::($module).rel2abs() }
View
4 lib/File/Spec/Unix.pm
@@ -103,8 +103,8 @@ class File::Spec::Unix {
return ( $volume, $directory, $file );
}
- method splitdir {
-
+ method splitdir( $path ) {
+ return $path.split( /\// )
}
method catpath {
View
14 t/01_unix.t
@@ -3,7 +3,7 @@ use lib 'lib';
use Test;
use File::Spec;
-plan 46;
+plan 51;
if $*OS ~~ any(<MacOS MSWin32 os2 VMS epoc NetWare symbian dos cygwin>) {
skip_rest 'this is not Unix\'ish'
@@ -83,7 +83,17 @@ else {
is File::Spec.splitpath( $get ), $want, "splitpath: '$get' -> '$want'";
}
- #splitdir
+ my %splitdir = (
+ '' => '',
+ '/d1/d2/d3/' => ('', 'd1', 'd2', 'd3', ''),
+ 'd1/d2/d3/' => ('d1', 'd2', 'd3', ''),
+ '/d1/d2/d3' => ('', 'd1', 'd2', 'd3'),
+ 'd1/d2/d3' => ('d1', 'd2', 'd3'),
+ );
+ for %splitdir.kv -> $get, $want {
+ is File::Spec.splitdir( $get ), $want, "splitdir: '$get' -> '$want'";
+ }
+
#catpath
#abs2rel
#rel2ab
Please sign in to comment.
Something went wrong with that request. Please try again.