Permalink
Browse files

Add a test for += cmp_ok.

Fix the test to properly predict the x= error from cmp_ok() based on our
passing in an error message rather than try the operator.

For #141
  • Loading branch information...
1 parent 83bf083 commit 9d2eba3d0068f4ef5e6e8fae571e735f3cc71942 @schwern schwern committed Apr 9, 2012
Showing with 8 additions and 5 deletions.
  1. +8 −5 t/cmp_ok.t
View
13 t/cmp_ok.t
@@ -17,10 +17,12 @@ sub try_cmp_ok {
my($left, $cmp, $right, $error) = @_;
my %expect;
- $expect{ok} = eval "\$left $cmp \$right";
- $expect{error} = $error;
-
- if (!$expect{error}) {
+ if( $error ) {
+ $expect{ok} = 0;
+ $expect{error} = $error;
+ }
+ else {
+ $expect{ok} = eval "\$left $cmp \$right";
$expect{error} = $@;
$expect{error} =~ s/ at .*\n?//;
}
@@ -72,7 +74,8 @@ my @Tests = (
[$ify, 'eq', "bar"],
[$ify, "==", 23],
- [1, "=", 0, "= is not a valid comparison operator in cmp_ok()"],
+ [1, "=", 0, "= is not a valid comparison operator in cmp_ok()"],
+ [1, "+=", 0, "+= is not a valid comparison operator in cmp_ok()"],
);
plan tests => scalar @Tests;

0 comments on commit 9d2eba3

Please sign in to comment.