Commit | Line | Data |
---|---|---|
6853e8af | 1 | # -*- mode: perl; -*- |
990fb837 | 2 | |
12fc2493 | 3 | # Test whether $Math::BigInt::upgrade breaks our neck |
990fb837 | 4 | |
990fb837 | 5 | use strict; |
11c955be SH |
6 | use warnings; |
7 | ||
c32198f6 | 8 | use Test::More tests => 5; |
990fb837 RGS |
9 | |
10 | use Math::BigInt upgrade => 'Math::BigRat'; | |
11 | use Math::BigRat; | |
12 | ||
13 | my $rat = 'Math::BigRat'; | |
11c955be | 14 | my($x, $y, $z); |
990fb837 RGS |
15 | |
16 | ############################################################################## | |
17 | # bceil/bfloor | |
18 | ||
11c955be SH |
19 | $x = $rat->new('49/4'); |
20 | is($x->bfloor(), '12', 'floor(49/4)'); | |
21 | ||
22 | $x = $rat->new('49/4'); | |
23 | is($x->bceil(), '13', 'ceil(49/4)'); | |
990fb837 RGS |
24 | |
25 | ############################################################################## | |
26 | # bsqrt | |
27 | ||
11c955be SH |
28 | $x = $rat->new('144'); |
29 | is($x->bsqrt(), '12', 'bsqrt(144)'); | |
30 | ||
31 | $x = $rat->new('144/16'); | |
32 | is($x->bsqrt(), '3', 'bsqrt(144/16)'); | |
33 | ||
34 | $x = $rat->new('1/3'); | |
35 | is($x->bsqrt(), | |
6320cdc0 | 36 | '1443375672974064411272871951254893639119/2500000000000000000000000000000000000000', |
11c955be | 37 | 'bsqrt(1/3)'); |
990fb837 | 38 | |
c4a6f826 | 39 | # all tests successful |
990fb837 | 40 | |
12fc2493 | 41 | 1; |