Commit | Line | Data |
---|---|---|
6853e8af | 1 | # -*- mode: perl; -*- |
11c955be | 2 | |
9aa0b648 FR |
3 | use strict; |
4 | use warnings; | |
11c955be | 5 | |
6320cdc0 | 6 | use Test::More tests => 2602; |
9aa0b648 | 7 | |
6320cdc0 | 8 | my @classes = ('Math::BigRat'); |
9aa0b648 | 9 | |
6320cdc0 SH |
10 | # We should test all the following operators: |
11 | # | |
12 | # & | ^ << >> &= |= ^= <<= >>= | |
13 | # | |
14 | # as well as the corresponding methods | |
15 | # | |
16 | # band bior bxor blsft brsft | |
9aa0b648 | 17 | |
6320cdc0 SH |
18 | for my $class (@classes) { |
19 | use_ok($class); | |
20 | ||
21 | for my $op (qw( & | ^ )) { | |
22 | for (my $xscalar = 0 ; $xscalar <= 8 ; $xscalar += 0.5) { | |
23 | for (my $yscalar = 0 ; $yscalar <= 8 ; $yscalar += 0.5) { | |
24 | ||
25 | my $xint = int $xscalar; | |
26 | my $yint = int $yscalar; | |
9aa0b648 | 27 | |
6320cdc0 SH |
28 | my $x = $class -> new("$xscalar"); |
29 | my $y = $class -> new("$yscalar"); | |
30 | ||
31 | my $test = "$x $op $y"; | |
32 | my $expected = eval "$xscalar $op $yscalar"; | |
33 | my $got = eval "\$x $op \$y"; | |
34 | ||
35 | is($@, '', 'is $@ empty'); | |
36 | isa_ok($got, $class, $test); | |
37 | is($got, $expected, | |
38 | "$x $op $y = $xint $op $yint = $expected"); | |
39 | } | |
40 | } | |
41 | } | |
42 | } |