Skip Menu |

This queue is for tickets about the Carp-Assert-More CPAN distribution.

Report information
The Basics
Id: 39395
Status: resolved
Priority: 0/
Queue: Carp-Assert-More

People
Owner: Nobody in particular
Requestors: leland [...] protoplasmic.org
Cc:
AdminCc:

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



Subject: assert_nonblank("", $name) does not fail with $name [patch]
When asserting empty string is blank, assert_nonblank does not fail with the $name given. So, instead of seeing "Assertion (foo is nonblank) failed" from assert_nonblank("", "foo is nonblank"), you see "Assertion failed", like you would from providing no $name for the assertion. A patch is attached that fixes and tests this problem.
Subject: assert_nonblank.diff
diff -Nuar Carp-Assert-More-1.12/More.pm Carp-Assert-More-1.12-patched/More.pm --- Carp-Assert-More-1.12/More.pm 2005-10-14 11:58:34.000000000 -0500 +++ Carp-Assert-More-1.12-patched/More.pm 2008-09-18 10:04:41.000000000 -0500 @@ -174,7 +174,7 @@ return if $this ne ""; require Carp; - &Carp::confess( _fail_msg($_[1]) ); + &Carp::confess( _fail_msg($name) ); } =head1 NUMERIC ASSERTIONS diff -Nuar Carp-Assert-More-1.12/t/assert_nonblank.t Carp-Assert-More-1.12-patched/t/assert_nonblank.t --- Carp-Assert-More-1.12/t/assert_nonblank.t 2005-10-14 12:02:35.000000000 -0500 +++ Carp-Assert-More-1.12-patched/t/assert_nonblank.t 2008-09-18 10:06:25.000000000 -0500 @@ -3,7 +3,7 @@ use warnings; use strict; -use Test::More tests => 6; +use Test::More tests => 7; BEGIN { use_ok( 'Carp::Assert::More' ); } @@ -41,3 +41,10 @@ assert_nonblank( $ref ); }; like( $@, qr/Assertion.*failed/ ); + +# fails with given $name +my $name = "foo is nonblank"; +eval { + assert_nonblank("", $name); +}; +like( $@, qr/Assertion \(\Q$name\E\) failed/, 'fails with given name' );
Fixed in 1.14. Thanks.