Skip to content

Instantly share code, notes, and snippets.

@diakopter
Created June 2, 2012 01:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diakopter/2856077 to your computer and use it in GitHub Desktop.
Save diakopter/2856077 to your computer and use it in GitHub Desktop.
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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment