Hook %SIG? David On Jan 29, 2012 4:56 PM, "Ovid" <publiustemp-perl...@yahoo.com> wrote:
> How do I make "Wide character in print" warnings fatal in tests? > > This test passes; > > use Test::More; > > > use strict; > use warnings; > use warnings FATAL => 'utf8'; > use utf8::all; > my $string = '日本国'; > my $length = length($string); > is $length, 3, "$string should have $length characters"; > diag $string; > done_testing; > > That's passing because the warnings pragma is lexically scoped and the > actual warnings are emitted in Test::Builder guts (utf8::all will let the > test pass because that package's code is now marked as utf8, but it doesn't > fix Test::Builder's filehandles). I can make the warnings go away with this: > > my $output = Test::Builder->new->todo_output; > binmode $output, ':encoding(UTF-8)'; > $output = Test::Builder->new->failure_output; > binmode $output, ':encoding(UTF-8)'; > > But I'd really like a clean way of just saying "kill my code if I ever see > 'Wide character in print'" regardless of which package the error is emitted > from. > > Cheers, > Ovid > -- > Live and work overseas - http://overseas-exile.blogspot.com/ > Buy the book - http://www.oreilly.com/catalog/perlhks/ > Tech blog - http://blogs.perl.org/users/ovid/ > Twitter - http://twitter.com/OvidPerl/ >