summaryrefslogtreecommitdiff
path: root/lib/bignum
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bignum')
-rwxr-xr-xlib/bignum/t/bignum.t2
-rw-r--r--lib/bignum/t/biinfnan.t21
-rw-r--r--lib/bignum/t/bn_lite.t30
-rw-r--r--lib/bignum/t/bninfnan.t21
-rw-r--r--lib/bignum/t/br_lite.t30
-rw-r--r--lib/bignum/t/brinfnan.t21
-rw-r--r--lib/bignum/t/infnan.inc35
7 files changed, 160 insertions, 0 deletions
diff --git a/lib/bignum/t/bignum.t b/lib/bignum/t/bignum.t
index 32235ea2d5..21a70e39dc 100755
--- a/lib/bignum/t/bignum.t
+++ b/lib/bignum/t/bignum.t
@@ -35,6 +35,8 @@ ok (2/3,"0.6666666666666666666666666666666666666667");
#ok (2 ** 0.5, 'NaN'); # should be sqrt(2);
+print "huh\n";
+
ok (12->bfac(),479001600);
# see if Math::BigFloat constant works
diff --git a/lib/bignum/t/biinfnan.t b/lib/bignum/t/biinfnan.t
new file mode 100644
index 0000000000..84d3a71bfa
--- /dev/null
+++ b/lib/bignum/t/biinfnan.t
@@ -0,0 +1,21 @@
+#!/usr/bin/perl -w
+
+###############################################################################
+
+use Test;
+use strict;
+
+BEGIN
+ {
+ $| = 1;
+ chdir 't' if -d 't';
+ unshift @INC, '../lib';
+ plan tests => 26;
+ }
+
+use bigint;
+
+my ($x);
+
+require "infnan.inc";
+
diff --git a/lib/bignum/t/bn_lite.t b/lib/bignum/t/bn_lite.t
new file mode 100644
index 0000000000..21247c1ee7
--- /dev/null
+++ b/lib/bignum/t/bn_lite.t
@@ -0,0 +1,30 @@
+#!/usr/bin/perl -w
+
+###############################################################################
+
+use Test;
+use strict;
+
+BEGIN
+ {
+ $| = 1;
+ chdir 't' if -d 't';
+ unshift @INC, '../lib';
+ plan tests => 1;
+ }
+
+eval 'require Math::BigInt::Lite;';
+if ($@ eq '')
+ {
+ # can use Lite, so let bignum try it
+ require bignum; bignum->import();
+ # can't get to work a ref(1+1) here, presumable because :constant phase
+ # already done
+ ok ($bignum::_lite,1);
+ }
+else
+ {
+ print "ok 1 # skipped, no Math::BigInt::Lite\n";
+ }
+
+
diff --git a/lib/bignum/t/bninfnan.t b/lib/bignum/t/bninfnan.t
new file mode 100644
index 0000000000..d097215b9e
--- /dev/null
+++ b/lib/bignum/t/bninfnan.t
@@ -0,0 +1,21 @@
+#!/usr/bin/perl -w
+
+###############################################################################
+
+use Test;
+use strict;
+
+BEGIN
+ {
+ $| = 1;
+ chdir 't' if -d 't';
+ unshift @INC, '../lib';
+ plan tests => 26;
+ }
+
+use bignum;
+
+my ($x);
+
+require "infnan.inc";
+
diff --git a/lib/bignum/t/br_lite.t b/lib/bignum/t/br_lite.t
new file mode 100644
index 0000000000..2bf77d4037
--- /dev/null
+++ b/lib/bignum/t/br_lite.t
@@ -0,0 +1,30 @@
+#!/usr/bin/perl -w
+
+###############################################################################
+
+use Test;
+use strict;
+
+BEGIN
+ {
+ $| = 1;
+ chdir 't' if -d 't';
+ unshift @INC, '../lib';
+ plan tests => 1;
+ }
+
+eval 'require Math::BigInt::Lite;';
+if ($@ eq '')
+ {
+ # can use Lite, so let bignum try it
+ require bigrat; bigrat->import();
+ # can't get to work a ref(1+1) here, presumable because :constant phase
+ # already done
+ ok ($bigrat::_lite,1);
+ }
+else
+ {
+ print "ok 1 # skipped, no Math::BigInt::Lite\n";
+ }
+
+
diff --git a/lib/bignum/t/brinfnan.t b/lib/bignum/t/brinfnan.t
new file mode 100644
index 0000000000..689a855698
--- /dev/null
+++ b/lib/bignum/t/brinfnan.t
@@ -0,0 +1,21 @@
+#!/usr/bin/perl -w
+
+###############################################################################
+
+use Test;
+use strict;
+
+BEGIN
+ {
+ $| = 1;
+ chdir 't' if -d 't';
+ unshift @INC, '../lib';
+ plan tests => 26;
+ }
+
+use bigrat;
+
+my ($x);
+
+require "infnan.inc";
+
diff --git a/lib/bignum/t/infnan.inc b/lib/bignum/t/infnan.inc
new file mode 100644
index 0000000000..771b94e748
--- /dev/null
+++ b/lib/bignum/t/infnan.inc
@@ -0,0 +1,35 @@
+
+use strict;
+
+my ($x);
+
+###############################################################################
+# inf tests
+
+$x = 1+inf; ok (ref($x) =~ /^Math::BigInt/); ok ($x->bstr(),'inf');
+$x = 1*inf; ok (ref($x) =~ /^Math::BigInt/); ok ($x->bstr(),'inf');
+
+# these don't work without exporting inf()
+$x = inf; ok (ref($x) =~ /^Math::BigInt/); ok ($x->bstr(),'inf');
+$x = inf+inf; ok (ref($x) =~ /^Math::BigInt/); ok ($x->bstr(),'inf');
+$x = inf*inf; ok (ref($x) =~ /^Math::BigInt/); ok ($x->bstr(),'inf');
+
+###############################################################################
+# NaN tests
+
+$x = 1+NaN; ok (ref($x) =~ /^Math::BigInt/); ok ($x->bstr(),'NaN');
+$x = 1*NaN; ok (ref($x) =~ /^Math::BigInt/); ok ($x->bstr(),'NaN');
+
+# these don't work without exporting NaN()
+$x = NaN; ok (ref($x) =~ /^Math::BigInt/); ok ($x->bstr(),'NaN');
+$x = NaN+NaN; ok (ref($x) =~ /^Math::BigInt/); ok ($x->bstr(),'NaN');
+$x = NaN*NaN; ok (ref($x) =~ /^Math::BigInt/); ok ($x->bstr(),'NaN');
+
+###############################################################################
+# mixed tests
+
+# these don't work without exporting NaN() or inf()
+$x = NaN+inf; ok (ref($x) =~ /^Math::BigInt/); ok ($x->bstr(),'NaN');
+$x = NaN*inf; ok (ref($x) =~ /^Math::BigInt/); ok ($x->bstr(),'NaN');
+$x = inf*NaN; ok (ref($x) =~ /^Math::BigInt/); ok ($x->bstr(),'NaN');
+