Skip to content

Commit

Permalink
Merge pull request #3464 from atroxaper/2364-throws-like-bool
Browse files Browse the repository at this point in the history
Make throws-like throw an exception on Bool:D matchers
  • Loading branch information
vrurg committed Feb 11, 2020
2 parents b19c4ee + 50f084d commit f2b3091
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/Test.rakumod
Expand Up @@ -602,6 +602,11 @@ multi sub is-deeply(Mu $got, Mu $expected, $reason = '') is export {
}

sub throws-like($code, $ex_type, $reason?, *%matcher) is export {
for %matcher.kv -> $k, $v {
if $v ~~ Bool and $v.DEFINITE {
X::Match::Bool.new(:type(".$k")).throw;
}
}
my $caller-context = $*THROWS-LIKE-CONTEXT // CALLER::; # Don't guess our caller context, know it!
subtest {
plan 2 + %matcher.keys.elems;
Expand Down Expand Up @@ -644,6 +649,11 @@ sub throws-like($code, $ex_type, $reason?, *%matcher) is export {
sub fails-like (
\test where Callable:D|Str:D, $ex-type, $reason?, *%matcher
) is export {
for %matcher.kv -> $k, $v {
if $v ~~ Bool and $v.DEFINITE {
X::Match::Bool.new(:type(".$k")).throw;
}
}
my $*THROWS-LIKE-CONTEXT = CALLER::;
subtest sub {
plan 2;
Expand Down

0 comments on commit f2b3091

Please sign in to comment.