Skip Menu |

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

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

People
Owner: CHORNY [...] cpan.org
Requestors: cholet [...] logilune.com
Cc:
AdminCc:

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



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
On 2016-11-23 06:26:45, cholet@logilune.com wrote: Show quoted text
> warning_is does not work when warning with trailing newline:
Unfortunately there's no way to fix this without breaking other users of the module. You might find Test::Warnings more flexible for testing your warning syntax.
Am Mi 23. Nov 2016, 20:16:07, ETHER schrieb: Show quoted text
> On 2016-11-23 06:26:45, cholet@logilune.com wrote:
> > warning_is does not work when warning with trailing newline:
> > Unfortunately there's no way to fix this without breaking other users > of the module.
So far trailing newlines was never supported, so I can't imagine really breaking stuff here. It's also not first request for this feature. I added a Test::Warn-0.31 version handling trailing newlines (and marked it as experimental) and uploaded it to PAUSE. Greetings, Janek