]> git.vpit.fr Git - perl/modules/Test-Leaner.git/blob - t/22-cmp_ok.t
ad880f35b5995b6206190ef679ecfe9a5d1d7ea4
[perl/modules/Test-Leaner.git] / t / 22-cmp_ok.t
1 #!perl -T
2
3 use strict;
4 use warnings;
5
6 use Test::Leaner tests => 4 * 10 + 7 + 10;
7
8 my @num_tests = (
9  [ '1.0', '==', '1.0' ],
10  [ '1e0', '==', '1e0' ],
11  [ '1.0', '<=', '1.0' ],
12  [ '1.0', '>=', '1.0' ],
13  [ '1.0', '<=', '2.0' ],
14  [ '1.0', '<',  '2.0' ],
15  [ '2.0', '>=', '1.0' ],
16  [ '2.0', '>',  '1.0' ],
17  [ '1.0', '!=', '2.0' ],
18  [ '2.0', '!=', '1.0' ],
19 );
20
21 for my $t (@num_tests) {
22  my ($x, $op, $y) = @$t;
23  cmp_ok $x,      $op, $y;
24  cmp_ok int($x), $op, $y;
25  cmp_ok $x,      $op, int($y);
26  cmp_ok int($x), $op, int($y);
27 }
28
29 my @str_tests = (
30  [ 'a', 'eq', 'a' ],
31  [ 'a', 'le', 'b' ],
32  [ 'a', 'lt', 'b' ],
33  [ 'b', 'ge', 'a' ],
34  [ 'b', 'gt', 'a' ],
35  [ 'a', 'ne', 'b' ],
36  [ 'b', 'ne', 'a' ],
37 );
38
39 for my $t (@str_tests) {
40  my ($x, $op, $y) = @$t;
41  cmp_ok $x, $op, $y;
42 }
43
44 my @logic_tests = (
45  [ 1, 'or',  0 ],
46  [ 0, 'or',  1 ],
47  [ 1, 'or',  1 ],
48  [ 1, 'xor', 0 ],
49  [ 0, 'xor', 1 ],
50  [ 1, 'and', 1 ],
51
52  [ 1, '||', 0 ],
53  [ 0, '||', 1 ],
54  [ 1, '||', 1 ],
55  [ 1, '&&', 1 ],
56 );
57
58 for my $t (@logic_tests) {
59  my ($x, $op, $y) = @$t;
60  cmp_ok $x, $op, $y;
61 }