diff options
Diffstat (limited to 'lib/bignum/t')
-rwxr-xr-x | lib/bignum/t/bignum.t | 10 | ||||
-rwxr-xr-x | lib/bignum/t/bigrat.t | 24 | ||||
-rwxr-xr-x | lib/bignum/t/trace.t | 39 |
3 files changed, 27 insertions, 46 deletions
diff --git a/lib/bignum/t/bignum.t b/lib/bignum/t/bignum.t index a804a26f23..32235ea2d5 100755 --- a/lib/bignum/t/bignum.t +++ b/lib/bignum/t/bignum.t @@ -10,7 +10,7 @@ BEGIN $| = 1; chdir 't' if -d 't'; unshift @INC, '../lib'; - plan tests => 17; + plan tests => 21; } use bignum; @@ -20,13 +20,15 @@ use bignum; my $x = 5; ok (ref($x) =~ /^Math::BigInt/); # :constant -# todo: ok (2 + 2.5,4.5); # should still work -# todo: $x = 2 + 3.5; ok (ref($x),'Math::BigFloat'); +ok (2 + 2.5,4.5); +$x = 2 + 3.5; ok (ref($x),'Math::BigFloat'); +ok (2 * 2.1,4.2); +$x = 2 + 2.1; ok (ref($x),'Math::BigFloat'); $x = 2 ** 255; ok (ref($x) =~ /^Math::BigInt/); # see if Math::BigInt constant and upgrading works -ok (Math::BigInt::bsqrt(12),'3.464101615137754587054892683011744733886'); +ok (Math::BigInt::bsqrt('12'),'3.464101615137754587054892683011744733886'); ok (sqrt(12),'3.464101615137754587054892683011744733886'); ok (2/3,"0.6666666666666666666666666666666666666667"); diff --git a/lib/bignum/t/bigrat.t b/lib/bignum/t/bigrat.t index 3664e8beb6..e5edcb441d 100755 --- a/lib/bignum/t/bigrat.t +++ b/lib/bignum/t/bigrat.t @@ -10,7 +10,7 @@ BEGIN $| = 1; chdir 't' if -d 't'; unshift @INC, '../lib'; - plan tests => 4; + plan tests => 16; } use bigrat; @@ -18,16 +18,34 @@ use bigrat; ############################################################################### # general tests -my $x = 5; ok (ref($x),'Math::BigInt'); # :constant +my $x = 5; ok (ref($x) =~ /^Math::BigInt/); # :constant # todo: ok (2 + 2.5,4.5); # should still work # todo: $x = 2 + 3.5; ok (ref($x),'Math::BigFloat'); -$x = 2 ** 255; ok (ref($x),'Math::BigInt'); +$x = 2 ** 255; ok (ref($x) =~ /^Math::BigInt/); # see if Math::BigRat constant works ok (1/3, '1/3'); ok (1/4+1/3,'7/12'); +ok (5/7+3/7,'8/7'); + +ok (3/7+1,'10/7'); +ok (3/7+1.1,'107/70'); +ok (3/7+3/7,'6/7'); + +ok (3/7-1,'-4/7'); +ok (3/7-1.1,'-47/70'); +ok (3/7-2/7,'1/7'); + +# fails ? +# ok (1+3/7,'10/7'); + +ok (1.1+3/7,'107/70'); +ok (3/7*5/7,'15/49'); +ok (3/7 / (5/7),'3/5'); +ok (3/7 / 1,'3/7'); +ok (3/7 / 1.5,'2/7'); ############################################################################### # accurarcy and precision diff --git a/lib/bignum/t/trace.t b/lib/bignum/t/trace.t deleted file mode 100755 index 891101b5f9..0000000000 --- a/lib/bignum/t/trace.t +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/perl -w - -############################################################################### - -use Test; -use strict; - -BEGIN - { - $| = 1; - chdir 't' if -d 't'; - unshift @INC, '../lib'; - plan tests => 1; - } - -BEGIN - { - print "# "; # for testsuite - } -use bignum qw/ trace /; - -############################################################################### -# general tests - -my $x = 5; -print "\n"; -ok (ref($x),'Math::BigInt::Trace'); # :constant via trace - -############################################################################### -############################################################################### -# Perl 5.005 does not like ok ($x,undef) - -sub ok_undef - { - my $x = shift; - - ok (1,1) and return if !defined $x; - ok ($x,'undef'); - } |