Skip to content

Commit

Permalink
Use nqp::can to test for test-assertion
Browse files Browse the repository at this point in the history
In some cases, specifically on the JVM, frames can be NQP code objects.
So instead of using .? dispatch, we're just checking if it can do the
'is-test-assertion' method.  Which it only can if the code actually had
the "is test-assertion` trait applied with a true value.

This should fix #3999, Christian Bartolomäus++ for spotting.
  • Loading branch information
lizmat committed Nov 1, 2020
1 parent ee08923 commit 86a208e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/Test.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -771,8 +771,9 @@ sub proclaim(Bool(Mu) $cond, $desc is copy, $unescaped-prefix = '') {
my $tester = $caller;

repeat {
my \code := ($caller = callframe($level++)).code;
$tester = callframe($level) # the next one should be reported
if ($caller = callframe($level++)).code.?is-test-assertion;
if nqp::can(code,'is-test-assertion'); # must use nqp
} until $caller.file.ends-with('.nqp');

# the final place we want to report from
Expand Down

0 comments on commit 86a208e

Please sign in to comment.