Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add simple use-ok implementation
  • Loading branch information
Paul Cochrane committed Feb 20, 2015
1 parent face62b commit bf2d1dd
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/Test.pm
Expand Up @@ -257,6 +257,16 @@ multi sub unlike(Str $got, Regex $expected, $desc = '') is export {
return $ok;
}

multi sub use-ok(Str $code, $msg = ("The module can be use-d ok")) is export {
$time_after = nqp::p6box_n(nqp::time_n);
try {
EVAL ( "use $code" );
}
my $ok = proclaim((not defined $!), $msg) or diag($!);
$time_before = nqp::p6box_n(nqp::time_n);
return $ok;
}

multi sub dies_ok(Callable $code, $reason = '') is export {
$time_after = nqp::p6box_n(nqp::time_n);
my $death = 1;
Expand Down

0 comments on commit bf2d1dd

Please sign in to comment.