{ my $warning; local $SIG{__WARN__} = sub { $warning = shift }; is( $warning, undef, 'no warnings recorded' ); code_that_warns(); is( $warning, 'expected warning', 'code_that_warns() does indeed warn' ); $warning = undef; non_warning_code(); is( $warning, undef, 'non_warning_code() is clean' ); }