X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMath%2FBigRat%2Ft%2Fbigrat.t;h=dd289f241f4d6772033084c9c6b6a745ea357f45;hb=7d34101341a809b9376ff7e60b225b04e87a56fe;hp=b59d9f0aa765a129973f6b5e18e09187856744ae;hpb=f3d61276bee2ff0cc5e5e49de55d638b96e26b89;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/Math/BigRat/t/bigrat.t b/lib/Math/BigRat/t/bigrat.t index b59d9f0..dd289f2 100755 --- a/lib/Math/BigRat/t/bigrat.t +++ b/lib/Math/BigRat/t/bigrat.t @@ -8,7 +8,7 @@ BEGIN $| = 1; chdir 't' if -d 't'; unshift @INC, '../lib'; # for running manually - plan tests => 136; + plan tests => 151; } # testing of Math::BigRat @@ -164,6 +164,12 @@ $x = $cr->new('144/9')->bsqrt(); ok ($x,'4'); # bpow $x = $cr->new('2/1'); $z = $x->bpow('3/1'); ok ($x,'8'); +$x = $cr->new('1/2'); $z = $x->bpow('3/1'); ok ($x,'1/8'); +$x = $cr->new('1/3'); $z = $x->bpow('4/1'); ok ($x,'1/81'); +$x = $cr->new('2/3'); $z = $x->bpow('4/1'); ok ($x,'16/81'); + +# XXX todo: +#$x = $cr->new('2/3'); $z = $x->bpow('5/3'); ok ($x,'32/81 ???'); ############################################################################## # bfac @@ -190,6 +196,28 @@ $x = $cr->new('-7/7'); ok ($x->{_n}, '1'); ok ($x->{_d}, '1'); $x = $cr->new('-7/7')->bfloor(); ok ($x->{_n}, '1'); ok ($x->{_d}, '1'); ############################################################################## +# bsstr + +$x = $cr->new('7/5')->bsstr(); ok ($x,'7/5'); +$x = $cr->new('-7/5')->bsstr(); ok ($x,'-7/5'); + +############################################################################## +# numify() + +my @array = qw/1 2 3 4 5 6 7 8 9/; +$x = $cr->new('8/8'); ok ($array[$x],2); +$x = $cr->new('16/8'); ok ($array[$x],3); +$x = $cr->new('17/8'); ok ($array[$x],3); +$x = $cr->new('33/8'); ok ($array[$x],5); +$x = $cr->new('-33/8'); ok ($array[$x],6); + +$x = $cr->new('33/8'); ok ($x->numify() * 1000, 4125); +$x = $cr->new('-33/8'); ok ($x->numify() * 1000, -4125); +$x = $cr->new('inf'); ok ($x->numify(), 'inf'); +$x = $cr->new('-inf'); ok ($x->numify(), '-inf'); +$x = $cr->new('NaN'); ok ($x->numify(), 'NaN'); + +############################################################################## # done 1;