Skip Menu |

This queue is for tickets about the Test-Warn CPAN distribution.

Report information
The Basics
Id: 78705
Status: resolved
Priority: 0/
Queue: Test-Warn

People
Owner: Nobody in particular
Requestors: DOHERTY [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.24
Fixed in: 0.30



Subject: Fatal warnings cannot be detected by warning category
When I try to detect a warning of some category, it only works when the warning is non-fatal: use strict; use warnings; use Test::More tests => 3; use Test::Warn; use warnings FATAL => 'utf8'; # Fatal warning warning_like { eval q/open my $out, '>:raw', \my $mem; print $out "\x{FACE}"/; warn $@ } qr/Wide character/, # warning categories only work for non-fatal warnings 'Fatal "Wide character" warning' or diag $@; # Non-fatal warning warning_like { open my $out, '>:raw', \my $mem; use warnings NONFATAL => 'utf8'; # downgrade to non-fatal utf8 warnings print $out "\x{FACE}" } 'utf8', # category works here 'Non-fatal "Wide character" warning' or diag $@; warning_is { open my $out, '>:raw', \my $mem; no warnings FATAL => 'utf8'; # disable fatal utf8 warnings print $out "\x{FACE}"; } [], 'No "Wide character" warning';
On Tue Jul 31 23:32:53 2012, DOHERTY wrote: Show quoted text
> When I try to detect a warning of some category, it only works when the > warning is non-fatal: > > use strict; > use warnings; > use Test::More tests => 3; > use Test::Warn; > use warnings FATAL => 'utf8'; > > # Fatal warning > warning_like > { eval q/open my $out, '>:raw', \my $mem; print $out "\x{FACE}"/; > warn $@ } > qr/Wide character/, # warning categories only work for non-fatal > warnings > 'Fatal "Wide character" warning' or diag $@; > > # Non-fatal warning > warning_like > { > open my $out, '>:raw', \my $mem; > use warnings NONFATAL => 'utf8'; # downgrade to non-fatal > utf8 warnings > print $out "\x{FACE}" > } > 'utf8', # category works here > 'Non-fatal "Wide character" warning' or diag $@; > > warning_is > { > open my $out, '>:raw', \my $mem; > no warnings FATAL => 'utf8'; # disable fatal utf8 warnings > print $out "\x{FACE}"; > } > [], > 'No "Wide character" warning';
It did not work at all because categories do not work as you expect. It worked in you case, because check for category utf8 is done as qr/utf8/ and you test is named utf8.t. This warning was added to category in Test-Warn-0.30. -- Alexandr Ciornii, http://chorny.net