in reply to What is the proper way to suppress a warning in a test file?
#!/usr/bin/perl use warnings; use strict; use Test::NoWarnings; use Test::More tests => 2; my $old = $SIG{__WARN__}; $SIG{__WARN__} = sub { my ($w) = @_; return if $w =~ /Eh/; warn $w; $old->(@_) if $old; }; ok(1); warn 'Eh'; # Will be ignored. warn 'Error'; # Will be reported.
At work, we use Test::Warnings instead (it handles done_testing() correctly). The solution is similar for this module, you just don't need to rewarn:
#!/usr/bin/perl use warnings; use strict; use Test::Warnings; use Test::More; my $old = $SIG{__WARN__}; $SIG{__WARN__} = sub { my ($w) = @_; return if $w =~ /Eh/; $old->(@_) if $old }; ok(1); warn 'Eh'; # Will be ignored. warn 'Error'; # Will be reported. done_testing();
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
|
|---|