Permalink
Browse files

fix split, run split-simple.t

  • Loading branch information...
1 parent 6cac7f1 commit 43f9e11628cce6cf96c4a480191988896b10c6a9 @moritz moritz committed Aug 17, 2011
Showing with 6 additions and 1 deletion.
  1. +3 −0 src/core/Cool.pm
  2. +2 −0 src/core/Str.pm
  3. +1 −1 t/spectest.data
View
@@ -118,6 +118,9 @@ my class Cool {
multi method split(Regex $pat, $limit = $Inf, :$all) {
self.Stringy.split($pat, $limit, :$all);
}
+ multi method split(Cool $pat, $limit = $Inf, :$all) {
+ self.Stringy.split($pat.Stringy, $limit, :$all);
+ }
proto method match(|$) {*}
multi method match(Cool:D: $target, *%adverbs) {
self.Stringy.match($target, |%adverbs)
View
@@ -358,6 +358,7 @@ my class Str does Stringy {
multi method split(Str:D: Regex $pat, $limit = *, :$all) {
my $l = $limit ~~ Whatever ?? $Inf !! $limit - 1;
+ return ().list if $l < 0;
my @matches := self.match($pat, :x(1..$l), :g);
gather {
my $prev-pos = 0;
@@ -374,6 +375,7 @@ my class Str does Stringy {
return if self eq '' && $delimiter eq '';
my $c = 0;
my $l = $limit ~~ Whatever ?? $Inf !! $limit - 1;
+ return ().list if $l < 0;
if $l >= 0 {
gather {
while $l-- > 0 {
View
@@ -555,7 +555,7 @@ S32-str/p5chop.t
S32-str/pos.t
S32-str/rindex.t
S32-str/samecase.t # icu
-# S32-str/split-simple.t # err: No applicable candidates found to dispatch to for 'split'.
+S32-str/split-simple.t
S32-str/split.t
S32-str/sprintf.t
S32-str/substr.t

0 comments on commit 43f9e11

Please sign in to comment.