xref: /openbsd-src/gnu/usr.bin/perl/cpan/Math-BigInt/t/bigratup.t (revision 5486feefcc8cb79b19e014ab332cc5dfd05b3b33)
1*5486feefSafresh1# -*- mode: perl; -*-
2*5486feefSafresh1
3*5486feefSafresh1# Test whether $Math::BigInt::upgrade breaks our neck
4*5486feefSafresh1
5*5486feefSafresh1use strict;
6*5486feefSafresh1use warnings;
7*5486feefSafresh1
8*5486feefSafresh1use Test::More tests => 5;
9*5486feefSafresh1
10*5486feefSafresh1use Math::BigInt upgrade => 'Math::BigRat';
11*5486feefSafresh1use Math::BigRat;
12*5486feefSafresh1
13*5486feefSafresh1my $rat = 'Math::BigRat';
14*5486feefSafresh1my($x, $y, $z);
15*5486feefSafresh1
16*5486feefSafresh1##############################################################################
17*5486feefSafresh1# bceil/bfloor
18*5486feefSafresh1
19*5486feefSafresh1$x = $rat->new('49/4');
20*5486feefSafresh1is($x->bfloor(), '12', 'floor(49/4)');
21*5486feefSafresh1
22*5486feefSafresh1$x = $rat->new('49/4');
23*5486feefSafresh1is($x->bceil(), '13', 'ceil(49/4)');
24*5486feefSafresh1
25*5486feefSafresh1##############################################################################
26*5486feefSafresh1# bsqrt
27*5486feefSafresh1
28*5486feefSafresh1$x = $rat->new('144');
29*5486feefSafresh1is($x->bsqrt(), '12', 'bsqrt(144)');
30*5486feefSafresh1
31*5486feefSafresh1$x = $rat->new('144/16');
32*5486feefSafresh1is($x->bsqrt(), '3', 'bsqrt(144/16)');
33*5486feefSafresh1
34*5486feefSafresh1$x = $rat->new('1/3');
35*5486feefSafresh1is($x->bsqrt(),
36*5486feefSafresh1   '1443375672974064411272871951254893639119/2500000000000000000000000000000000000000',
37*5486feefSafresh1   'bsqrt(1/3)');
38*5486feefSafresh1
39*5486feefSafresh1# all tests successful
40*5486feefSafresh1
41*5486feefSafresh11;
42