From: Vincent Pit Date: Tue, 28 Dec 2010 11:20:22 +0000 (+0100) Subject: Expand the list of valid operators for cmp_ok X-Git-Tag: v0.01~7 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=0857b9585353fe0fe98e3e1fded50f6e15b3f1f3;p=perl%2Fmodules%2FTest-Leaner.git Expand the list of valid operators for cmp_ok --- diff --git a/lib/Test/Leaner.pm b/lib/Test/Leaner.pm index 4aaa5e4..b629f6a 100644 --- a/lib/Test/Leaner.pm +++ b/lib/Test/Leaner.pm @@ -45,6 +45,11 @@ L, L, L, L, L, L, L and L throws an exception if the given operator isn't a valid Perl binary operator (except C<'='> and variants). +It also tests in scalar context, so C<'..'> will be treated as the flip-flop operator and not the range operator. + +=item * + C, C, C, C, C, C, C, C blocks and C are not implemented. =back @@ -350,12 +355,17 @@ sub isnt ($$;$) { my %binops = ( 'or' => 'or', - 'and' => 'and', 'xor' => 'xor', + 'and' => 'and', '||' => 'hor', + ('//' => 'dor') x ($] >= 5.010), '&&' => 'hand', + '|' => 'bor', + '^' => 'bxor', + '&' => 'band', + 'lt' => 'lt', 'le' => 'le', 'gt' => 'gt', @@ -374,7 +384,21 @@ my %binops = ( '=~' => 'like', '!~' => 'unlike', - '~~' => 'smartmatch', + ('~~' => 'smartmatch') x ($] >= 5.010), + + '+' => 'add', + '-' => 'substract', + '*' => 'multiply', + '/' => 'divide', + '%' => 'modulo', + '<<' => 'lshift', + '>>' => 'rshift', + + '.' => 'concat', + '..' => 'flipflop', + '...' => 'altflipflop', + ',' => 'comma', + '=>' => 'fatcomma', ); my %binop_handlers; @@ -388,7 +412,7 @@ sub _create_binop_handler { eval <<"IS_BINOP"; sub is_$name (\$\$;\$) { my (\$got, \$expected, \$desc) = \@_; - \@_ = ((\$got $op \$expected), \$desc); + \@_ = (scalar(\$got $op \$expected), \$desc); goto &ok; } IS_BINOP