Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

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

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don't worry, you can still create the pull request.
  • 5 commits
  • 3 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)
116df1c
Commits on Feb 16, 2012
@rjbs test fix for perl 5.6
a912db0
@rjbs v0.010
          avoid tickling an overloading bug in perl 5.6 during testing (thanks,
          Zefram)
e6dc77f
Showing with 23 additions and 5 deletions.
  1. +7 −0 Changes
  2. +15 −4 lib/Test/Fatal.pm
  3. +1 −1  t/basic.t
View
7 Changes
@@ -2,6 +2,13 @@ Revision history for {{$dist->name}}
{{$NEXT}}
+0.010 2012-02-16 10:27:54 America/New_York
+ avoid tickling an overloading bug in perl 5.6 during testing (thanks,
+ Zefram)
+
+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
View
19 lib/Test/Fatal.pm
@@ -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",
);
isa_ok(
@@ -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>.
+
=cut
sub exception (&) {
View
2  t/basic.t
@@ -67,7 +67,7 @@ if ($] < 5.013001) {
{
package FalseObject;
- use overload 'bool' => sub { return };
+ use overload 'bool' => sub { 0 };
}
like(

No commit comments for this range

Something went wrong with that request. Please try again.