This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Move Math::BigRat from ext/ to cpan/
[perl5.git] / cpan / Math-BigRat / t / bigratup.t
CommitLineData
990fb837
RGS
1#!/usr/bin/perl -w
2
12fc2493 3# Test whether $Math::BigInt::upgrade breaks our neck
990fb837 4
12fc2493 5use Test::More;
990fb837
RGS
6use strict;
7
8BEGIN
9 {
10 $| = 1;
11 chdir 't' if -d 't';
12 unshift @INC, '../lib';
13 plan tests => 5;
14 }
15
16use Math::BigInt upgrade => 'Math::BigRat';
17use Math::BigRat;
18
19my $rat = 'Math::BigRat';
20my ($x,$y,$z);
21
22##############################################################################
23# bceil/bfloor
24
12fc2493
AMS
25$x = $rat->new('49/4'); is ($x->bfloor(),'12', 'floor(49/4)');
26$x = $rat->new('49/4'); is ($x->bceil(),'13', 'ceil(49/4)');
990fb837
RGS
27
28##############################################################################
29# bsqrt
30
12fc2493
AMS
31$x = $rat->new('144'); is ($x->bsqrt(),'12', 'bsqrt(144)');
32$x = $rat->new('144/16'); is ($x->bsqrt(),'3', 'bsqrt(144/16)');
33$x = $rat->new('1/3'); is ($x->bsqrt(),
34 '1000000000000000000000000000000000000000/1732050807568877293527446341505872366943',
35 'bsqrt(1/3)');
990fb837 36
12fc2493 37# all tests successfull
990fb837 38
12fc2493 391;
990fb837 40