Skip to content

Commit

Permalink
Merge pull request #18 from patrickbkr/master
Browse files Browse the repository at this point in the history
List calls when with matching failed
  • Loading branch information
jnthn authored Oct 7, 2022
2 parents 1130427 + dc181c0 commit 37fe0c3
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/Test/Mock.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ monitor Test::Mock::Log {
# If we've an argument filter, apply it; we smart-match
# everything but captures, which we eqv.
my $with-args-note = "";
my $candidates-note = "";
if defined($with) {
if @calls {
$candidates-note = ", was only called with:"
~ @calls.map({ "\n" ~ .<capture>.raku });
}
if $with ~~ Capture {
@calls .= grep({ .<capture> eqv $with });
}
Expand All @@ -31,10 +36,12 @@ monitor Test::Mock::Log {
$times == 0 ?? "never called $name" !!
$times == 1 ?? "called $name 1 time" !!
"called $name $times times";
is +@calls, $times, "$times-msg$with-args-note";
is +@calls, $times, "$times-msg$with-args-note"
~ (+@calls ?? "" !! $candidates-note);
}
else {
ok ?@calls, "called $name$with-args-note";
ok ?@calls, "called $name$with-args-note"
~ (?@calls ?? "" !! $candidates-note);
}
}

Expand Down

0 comments on commit 37fe0c3

Please sign in to comment.