Skip to content

Commit

Permalink
Use handled Failure for X::Sum::Push::Usage.
Browse files Browse the repository at this point in the history
  It isn't perfect but at least it gets things up and running for star13
  Still some work to do to adapt to the new sink/failure handling
  • Loading branch information
skids committed Jan 31, 2013
1 parent bf773fc commit c5edfb6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions lib/Sum.pm6
Expand Up @@ -372,7 +372,9 @@ role Sum::Marshal::Raw {
# Pass the whole list to the class's add method, unprocessed. # Pass the whole list to the class's add method, unprocessed.
sink self.add(@addends).grep({$_.WHAT ~~ Failure }).map: sink self.add(@addends).grep({$_.WHAT ~~ Failure }).map:
{ return $_ }; { return $_ };
Failure.new(X::Sum::Push::Usage.new()); my $res = Failure.new(X::Sum::Push::Usage.new());
$res.defined;
$res;
}; };


# This allows simultaneous mixin of Sum::Partial # This allows simultaneous mixin of Sum::Partial
Expand Down Expand Up @@ -429,7 +431,9 @@ role Sum::Marshal::Cooked {
when Failure { return $_ }; when Failure { return $_ };
} }
}; };
Failure.new(X::Sum::Push::Usage.new()); my $res = Failure.new(X::Sum::Push::Usage.new());
$res.defined;
$res;
} }
} }


Expand Down
2 changes: 1 addition & 1 deletion t/sum.t
Expand Up @@ -175,7 +175,7 @@ class Foo5
method size () { 64 } method size () { 64 }
method finalize (*@addends) { method finalize (*@addends) {
self.push(@addends); self.push(@addends);
return fail(X::Sum::Missing.new()) unless self.whole; return Failure.new(X::Sum::Missing.new()) unless self.whole;
$.accum; $.accum;
} }
method Numeric () { self.finalize }; method Numeric () { self.finalize };
Expand Down

0 comments on commit c5edfb6

Please sign in to comment.