Skip to content

Commit

Permalink
test: surpress warning/warnings is called in void context
Browse files Browse the repository at this point in the history
  • Loading branch information
iiharu committed Feb 7, 2025
1 parent 4e558b3 commit 6840c41
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions t/modules/Plugin/SRand.t
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,16 @@ sub intercept_2(&) {
);
ok($CLASS->seed && $CLASS->seed != 1234, "set seed");
is($CLASS->from, 'local date', "set from");
like($warning, $reseed_qr, $reseed_name);
$warning = like($warning, $reseed_qr, $reseed_name);

my $hooks = Test2::API::test2_list_exit_callbacks();
delete $ENV{HARNESS_IS_VERBOSE};
$ENV{HARNESS_ACTIVE} = 1;
warning { $events = intercept { $CLASS->import() } };
warning { $events = intercept { $CLASS->import() } };
$warning = warning { $events = intercept { $CLASS->import() } };
$warning = warning { $events = intercept { $CLASS->import() } };
is(Test2::API::test2_list_exit_callbacks, $hooks + 1, "added hook, but only once");

warning { $CLASS->import(undef) };
$warning = warning { $CLASS->import(undef) };
is($CLASS->seed, 0 , "set seed");
is($CLASS->from, 'import arg', "set from");
}
Expand Down
5 changes: 3 additions & 2 deletions t/modules/Tools/ClassicCompare.t
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ $line = __LINE__ + 2;
like(
intercept {
local $ENV{TS_TERM_SIZE} = 10000;
main::warning {
$warning = main::warning {
cmp_ok($foo, '&& die', $foo, 'overload exception', 'extra diag')
}
},
Expand Down Expand Up @@ -312,12 +312,13 @@ note "cmp_ok() displaying good numbers"; {
}


my $warnings;
note "cmp_ok() displaying bad numbers"; {
my $have = "zero";
my $want = "3point5";
like(
intercept {
warnings { cmp_ok($have, '>', $want) };
$warnings = warnings { cmp_ok($have, '>', $want) };
},
array {
fail_events Ok => sub {
Expand Down

0 comments on commit 6840c41

Please sign in to comment.