Skip to content

Commit

Permalink
Merge pull request #1664 from rakudo/fails-like
Browse files Browse the repository at this point in the history
Implement fails-like routine in Test.pm6
  • Loading branch information
lizmat committed Mar 28, 2018
2 parents 68a576e + 4abfd4c commit 82a0e70
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/Test.pm6
Expand Up @@ -628,6 +628,25 @@ sub throws-like($code, $ex_type, $reason?, *%matcher) is export {
}, $reason // "did we throws-like $ex_type.^name()?";
}

sub fails-like (
\test where Callable:D|Str:D, $ex-type, $reason?, *%matcher
) is export {
subtest sub {
plan 2;
CATCH { default {
with "expected code to fail but it threw {.^name} instead" {
.&flunk;
.&skip;
return False;
}
}}
my $res = test ~~ Callable ?? test.() !! test.EVAL;
isa-ok $res, Failure, 'code returned a Failure';
throws-like { $res.sink }, $ex-type,
'Failure threw when sunk', |%matcher,
}, $reason // "did we fails-like $ex-type.^name()?"
}

sub _is_deeply(Mu $got, Mu $expected) {
$got eqv $expected;
}
Expand Down
1 change: 1 addition & 0 deletions t/spectest.data
Expand Up @@ -919,6 +919,7 @@ S24-testing/11-plan-skip-all-subtests.t
S24-testing/12-subtest-todo.t
S24-testing/13-cmp-ok.t
S24-testing/14-like-unlike.t
S24-testing/fails-like.t
S24-testing/line-numbers.t
S26-documentation/01-delimited.t
S26-documentation/02-paragraph.t
Expand Down

0 comments on commit 82a0e70

Please sign in to comment.