Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
  • 3 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Commits on Feb 09, 2012
@rjbs advise against isnt(e{}, undef) 97571f9
@rjbs elaborate on previous advice a0a2027
@rjbs v0.009
          advise against using isnt(exception{...},undef)
Showing with 18 additions and 4 deletions.
  1. +3 −0 Changes
  2. +15 −4 lib/Test/
3 Changes
@@ -2,6 +2,9 @@ Revision history for {{$dist->name}}
+0.009 2012-02-09 15:26:11 America/New_York
+ advise against using isnt(exception{...},undef)
0.008 2011-11-06 21:10:14 America/New_York
no changes since 0.007
19 lib/Test/
@@ -16,10 +16,10 @@ package Test::Fatal;
"the code lived",
- isnt(
+ like(
exception { might_die; },
- undef,
- "the code died",
+ qr/turns out it died/,
+ "the code died as expected",
@@ -53,7 +53,7 @@ our @EXPORT_OK = qw(exception success dies_ok lives_ok);
C<exception> takes a bare block of code and returns the exception thrown by
that block. If no exception was thrown, it returns undef.
-B<ACHTUNG!> If the block results in a I<false> exception, such as 0 or the
+B<Achtung!> If the block results in a I<false> exception, such as 0 or the
empty string, Test::Fatal itself will die. Since either of these cases
indicates a serious problem with the system under testing, this behavior is
considered a I<feature>. If you must test for these conditions, you should use
@@ -82,6 +82,17 @@ exception" will itself be matched by the regex. Instead, write this:
my $exception = exception { ... };
like( $exception, qr/foo/, "foo appears in the exception" );
+B<Achtung>: One final bad idea:
+ isnt( exception { ... }, undef, "my code died!");
+It's true that this tests that your code died, but you should really test that
+it died I<for the right reason>. For example, if you make an unrelated mistake
+in the block, like using the wrong dereference, your test will pass even though
+the code to be tested isn't really run at all. If you're expecting an
+inspectable exception with an identifier or class, test that. If you're
+expecting a string exception, consider using C<like>.
sub exception (&) {

No commit comments for this range

Something went wrong with that request. Please try again.