1# -*- mode: perl; -*- 2 3use strict; 4use warnings; 5 6use Test::More tests => 2602; 7 8my @classes = ('Math::BigRat'); 9 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 17 18for 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; 27 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} 43