Permalink
Browse files

Revise 'carp test' test.

In general, tests of error messages should be written with like() rather than
is().  Why?  Because we rarely want to test for the complete error message if
that requires us to exactly calculate strings such as the line number at which
an error occurred.
  • Loading branch information...
1 parent 12129a1 commit d73009ed386e9b0f0ae9684e706d013aaa080f9a @jkeenan committed Apr 25, 2012
Showing with 1 addition and 2 deletions.
  1. +1 −2 t/Util.t
View
@@ -155,8 +155,7 @@ is( $hash{locked}, 42, 'unlock_value' );
{
my %hash = (foo => 42, bar => undef);
eval { lock_keys(%hash, qw(foo baz)); };
- is( $@, sprintf("Hash has key 'bar' which is not in the new key ".
- "set at %s line %d.\n", __FILE__, __LINE__ - 2),
+ like( $@, qr/^Hash has key 'bar' which is not in the new key set/,
'carp test' );
}

0 comments on commit d73009e

Please sign in to comment.