On 30 Jan 2007, at 20:11, Joshua ben Jore wrote:

Interestingly, this has caused me to wonder how well Test::Exception
handles the corner cases where $@ is clobbered during the scope ending
of eval{} and related.

It doesn't. It's been on my list for some time, but I'm too lazy :-)

I've just filed a bug against it at
http://rt.cpan.org/Ticket/Display.html?id=24678. The overall moral is
when using eval{} you have to test the return value as well as [EMAIL 
PROTECTED] $@
can be empty under errors which is kind of a bummer.

My problem with making T::E do the "right" thing (for certain definitions of right) is that it may not help folk - since the edge case behaviour is something that the majority of people never encounter so while the test will "work" their code won't. So rather than make

  dies_ok { $o->annoying_corner_case } 'exception thrown';

do the SIG{__DIE__} dance make the tester write

  dies_ok { $o->annoying_corner_case; 1 } 'exception thrown';

as they would have to do in a "real" eval if they wanted to cope with the edge case.

Does this sound vaguely sane?

Anyhow, dies_ok and lives_ok are great language for talking about your
intent for testing. Just because there's a more verbose and more
powerful way to say something doesn't make it better. It's
occasionally important just to talk about things at the level of "this
dies." "this other thing doesn't." I see this as just expanding the
vocabulary.

Aye. Intention revealing code++

Adrian

Reply via email to