Subject: | warning_is doesn't work with trailing newline |
Date: | Wed, 23 Nov 2016 15:26:31 +0100 |
To: | bug-Test-Warn [...] rt.cpan.org |
From: | Éric Cholet <cholet [...] logilune.com> |
warning_is does not work when warning with trailing newline:
#!/usr/bin/perl
use strict;
use Test::More tests => 1;
use Test::Warn;
warning_is { foo() } "error\n";
sub foo { warn "error\n" }
# Failed test at foo line 6.
# found warning: error
# expected to find warning: error
It seems that this line in
my $cmp = $got_msg =~ /^\Q$exp_msg\E at .+ line \d+\.?$/;
assumes that the warning ends with "at line...", which of course doesn't occur when warning with a trailing newline.
—
Éric Cholet