Re: Fatal "wide character" warnings in tests

David Golden <[email protected]>
Newsgroups gmane.comp.lang.perl.quality-assurance
Message-ID <CAOeq1c80wPKMPMhv5qmibMKKksLwUF-nDyUwVTF2GpsaoiWZpw@mail.gmail.com>
Hook %SIG?

David
 On Jan 29, 2012 4:56 PM, "Ovid" <[email protected]> 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/
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.