summaryrefslogtreecommitdiff
path: root/lib/bignum/t/bigrat.t
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2002-03-26 19:54:48 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2002-03-26 19:54:48 +0000
commit8f675a64451b3c11c234adeda6be313fb8d03f6c (patch)
tree701fd72b4f0ed95c891264108a1b9fc231f2674b /lib/bignum/t/bigrat.t
parent2c45f8e1be053d3d2fa453b2278c7225f1689f9c (diff)
downloadperl-8f675a64451b3c11c234adeda6be313fb8d03f6c.tar.gz
Upgrade to Math::BigInt 1.56, Math::BigRat 0.05,
and bignum 0.11, from Tels. p4raw-id: //depot/perl@15523
Diffstat (limited to 'lib/bignum/t/bigrat.t')
-rwxr-xr-xlib/bignum/t/bigrat.t24
1 files changed, 21 insertions, 3 deletions
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