From: Vincent Pit Date: Fri, 24 Dec 2010 17:44:03 +0000 (+0100) Subject: More cmp_ok() tests X-Git-Tag: v0.01~22 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=3f7bd7950bb41e09b5ea6e0896e280d57e521913;p=perl%2Fmodules%2FTest-Leaner.git More cmp_ok() tests --- diff --git a/t/22-cmp_ok.t b/t/22-cmp_ok.t index f26d687..ad880f3 100644 --- a/t/22-cmp_ok.t +++ b/t/22-cmp_ok.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::Leaner tests => 4 * 8; +use Test::Leaner tests => 4 * 10 + 7 + 10; my @num_tests = ( [ '1.0', '==', '1.0' ], @@ -14,6 +14,8 @@ my @num_tests = ( [ '1.0', '<', '2.0' ], [ '2.0', '>=', '1.0' ], [ '2.0', '>', '1.0' ], + [ '1.0', '!=', '2.0' ], + [ '2.0', '!=', '1.0' ], ); for my $t (@num_tests) { @@ -23,3 +25,37 @@ for my $t (@num_tests) { cmp_ok $x, $op, int($y); cmp_ok int($x), $op, int($y); } + +my @str_tests = ( + [ 'a', 'eq', 'a' ], + [ 'a', 'le', 'b' ], + [ 'a', 'lt', 'b' ], + [ 'b', 'ge', 'a' ], + [ 'b', 'gt', 'a' ], + [ 'a', 'ne', 'b' ], + [ 'b', 'ne', 'a' ], +); + +for my $t (@str_tests) { + my ($x, $op, $y) = @$t; + cmp_ok $x, $op, $y; +} + +my @logic_tests = ( + [ 1, 'or', 0 ], + [ 0, 'or', 1 ], + [ 1, 'or', 1 ], + [ 1, 'xor', 0 ], + [ 0, 'xor', 1 ], + [ 1, 'and', 1 ], + + [ 1, '||', 0 ], + [ 0, '||', 1 ], + [ 1, '||', 1 ], + [ 1, '&&', 1 ], +); + +for my $t (@logic_tests) { + my ($x, $op, $y) = @$t; + cmp_ok $x, $op, $y; +}