Skip to content

Commit

Permalink
Add a test for += cmp_ok.
Browse files Browse the repository at this point in the history
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
schwern committed Apr 9, 2012
1 parent 83bf083 commit 9d2eba3
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions t/cmp_ok.t
Expand Up @@ -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?//;
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 9d2eba3

Please sign in to comment.