# from Nadim Khemir
# on Tuesday 30 January 2007 09:17 am:

>  # all Test::Exceptions subroutines are guaranteed to preserve the
> state # of $@ so you can do things like this after throws_ok and
> dies_ok like $@, 'what the stringified exception should look like';
>
>This wouldn't be needed if dies_ok didn't exist.

I think the arguments in favor of dies_ok are good.  But, I think it 
would be better to return the $@ rather than trying to preserve it.

  my $error = dies_ok { $foo->method1 } 'expecting to die';
  isa_ok($error, 'Whatever');

Alternatively, at least a $Test::Exception::Error variable (and/or 
imported "sub last_error () {$Test::Exception::Error}") would probably 
be more robust than preserving $@, though I don't see why returning the 
value would break compatibility (well, maybe in some cases of 
overloaded exception objects?)

--Eric
-- 
perl -e 'srand; print join(" ",sort({rand() < 0.5}
  qw(sometimes it is important to be consistent)));'
---------------------------------------------------
    http://scratchcomputing.com
---------------------------------------------------

Reply via email to