Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
new does-ok test assertion
  • Loading branch information
dwarring committed Aug 25, 2015
1 parent f7cfe9d commit df589cd
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/Test.pm
Expand Up @@ -342,6 +342,14 @@ multi sub isa-ok(Mu $var, Mu $type, $msg = ("The object is-a '" ~ $type.perl ~ "
$ok;
}

multi sub does-ok(Mu $var, Mu $type, $msg = ("The object does role '" ~ $type.perl ~ "'")) is export {
$time_after = nqp::p6box_n(nqp::time_n);
my $ok = proclaim($var.does($type), $msg)
or diag([~] 'Type: ', $var.^name, " doesn't do role ", $type.perl);
$time_before = nqp::time_n;
$ok;
}

multi sub can-ok(Mu $var, Str $meth, $msg = ( ($var.defined ?? "An object of type '" !! "The type '" ) ~ $var.WHAT.perl ~ "' can do the method '$meth'") ) is export {
$time_after = nqp::p6box_n(nqp::time_n);
my $ok = proclaim($var.^can($meth), $msg);
Expand Down

0 comments on commit df589cd

Please sign in to comment.