7 package Test::Leaner::TestCmpNum;
9 use overload '<=>' => sub {
13 $y = $y->{num} if ref $y;
15 ($x, $y) = ($y, $x) if $r;
23 bless { num => $_[0] }, $class
27 use Test::Leaner tests => 7 * 10 + 4 * 7 + 10;
30 [ '1.0', '==', '1.0' ],
31 [ '1e0', '==', '1e0' ],
32 [ '1.0', '<=', '1.0' ],
33 [ '1.0', '>=', '1.0' ],
34 [ '1.0', '<=', '2.0' ],
35 [ '1.0', '<', '2.0' ],
36 [ '2.0', '>=', '1.0' ],
37 [ '2.0', '>', '1.0' ],
38 [ '1.0', '!=', '2.0' ],
39 [ '2.0', '!=', '1.0' ],
42 for my $t (@num_tests) {
43 my ($x, $op, $y) = @$t;
46 cmp_ok int($x), $op, $y;
47 cmp_ok $x, $op, int($y);
48 cmp_ok int($x), $op, int($y);
50 my $ox = Test::Leaner::TestCmpNum->new($x);
51 my $oy = Test::Leaner::TestCmpNum->new($y);
59 package Test::Leaner::TestCmpStr;
61 use overload 'cmp' => sub {
65 $y = $y->{str} if ref $y;
67 ($x, $y) = ($y, $x) if $r;
75 bless { str => $_[0] }, $class
89 for my $t (@str_tests) {
90 my ($x, $op, $y) = @$t;
94 my $ox = Test::Leaner::TestCmpStr->new($x);
95 my $oy = Test::Leaner::TestCmpStr->new($y);
116 for my $t (@logic_tests) {
117 my ($x, $op, $y) = @$t;