Permalink
Browse files

Add diakopter++'s eval_dies_with_error.

  • Loading branch information...
1 parent 6365270 commit eff089bffb21215fb79868394e94845cd1869fff @colomon colomon committed Jun 2, 2012
Showing with 17 additions and 0 deletions.
  1. +17 −0 lib/Test.pm
View
@@ -201,6 +201,23 @@ multi sub eval_lives_ok(Str $code, $reason = '') is export {
$time_before = nqp::p6box_n(nqp::time_n);
}
+multi sub eval_dies_with_error(Str $code, $pattern, $reason = '') is export {
+ $time_after = nqp::p6box_n(nqp::time_n);
+ my $ee = eval_exception($code);
+ if defined $ee {
+ # XXX no regexes yet in nom
+ my $bad_death = $ee.Str !~~ $pattern;
+ if $bad_death {
+ diag "wrong way to die: '$ee'";
+ }
+ proclaim( !$bad_death, $reason );
+ }
+ else {
+ proclaim( 0, $reason );
+ }
+ $time_before = nqp::p6box_n(nqp::time_n);
+}
+
multi sub is_deeply(Mu $got, Mu $expected, $reason = '') is export
{
$time_after = nqp::p6box_n(nqp::time_n);

0 comments on commit eff089b

Please sign in to comment.