Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

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

Report information
The Basics
Id: 81529
Status: open
Priority: 0/
Queue: Test-Exception

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

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



Subject: throws_ok passed even if no exception was thrown
Run: perl -MTest::Exception=1 -e 'throws_ok { return 1 } qr/.*/;' to see the problem. We tried to use such construct to detect failures, without knowing error message beforehand. Using it instead of dies_ok makes it simpler to fill in actual expected error later (when it becomes known). I do believe that throws_ok should never pass if no exception was thrown.
On 2012-11-29 04:36:22, BJAKUBSKI wrote: Show quoted text
> Run: > > perl -MTest::Exception=1 -e 'throws_ok { return 1 } qr/.*/;' > > to see the problem. > > We tried to use such construct to detect failures, without knowing error > message beforehand. Using it instead of dies_ok makes it simpler to fill > in actual expected error later (when it becomes known). > > I do believe that throws_ok should never pass if no exception was thrown.
Shouldn't the regexp be written to match at least one character, e.g. qr/.+/? Otherwise it also matches the empty string... Regards, Slaven
On Mon Jan 14 05:25:18 2013, SREZIC wrote: Show quoted text
> On 2012-11-29 04:36:22, BJAKUBSKI wrote:
> > Run: > > > > perl -MTest::Exception=1 -e 'throws_ok { return 1 } qr/.*/;' > > > > to see the problem. > > > > We tried to use such construct to detect failures, without knowing
error Show quoted text
> > message beforehand. Using it instead of dies_ok makes it simpler to
fill Show quoted text
> > in actual expected error later (when it becomes known). > > > > I do believe that throws_ok should never pass if no exception was
thrown. Show quoted text
> > Shouldn't the regexp be written to match at least one character, e.g. > qr/.+/? Otherwise it also matches the empty string... >
I wanted it to match _always_ if there is exception thrown. I didn't use dies_ok, cause I knew I'd put specific pattern there later, so I knew I'll have throws_ok there in the end anyway. I find it very weird that "no exception thrown" is considered the same (as far as test goes) as exception that stringifies to empty string here. It seems simpler and more logical to me for throws_ok to pass only if: 1. there WAS actual exception (no matter what value it has nor what it stringifies to) AND 2. it matches supplied regex/class
Hi, I've published a pull request trying to fix this bug: https://github.com/Test-More/test-exception/pull/8 Best Regards, Jose Luis