summaryrefslogtreecommitdiff
path: root/dist/bignum
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2010-09-10 10:59:00 +0100
committerNicholas Clark <nick@ccl4.org>2010-09-10 10:59:00 +0100
commite08c10f564aa3fa8386b88ad67ae3346d1b98787 (patch)
tree078b2b7794ac3ab2e0532a50000e41e0a29163b7 /dist/bignum
parenta8e2d8b6ac253a0c37ec3dec859fde4ff4b2859e (diff)
downloadperl-e08c10f564aa3fa8386b88ad67ae3346d1b98787.tar.gz
Convert bignum tests from Test to Test::More.
Diffstat (limited to 'dist/bignum')
-rw-r--r--dist/bignum/t/bigint.t92
-rw-r--r--dist/bignum/t/bignum.t95
-rw-r--r--dist/bignum/t/bigrat.t109
-rw-r--r--dist/bignum/t/biinfnan.t7
-rw-r--r--dist/bignum/t/bn_lite.t13
-rw-r--r--dist/bignum/t/bninfnan.t7
-rw-r--r--dist/bignum/t/br_lite.t13
-rw-r--r--dist/bignum/t/brinfnan.t7
-rw-r--r--dist/bignum/t/infnan.inc26
9 files changed, 146 insertions, 223 deletions
diff --git a/dist/bignum/t/bigint.t b/dist/bignum/t/bigint.t
index bef5aecb91..e9de090928 100644
--- a/dist/bignum/t/bigint.t
+++ b/dist/bignum/t/bigint.t
@@ -2,13 +2,7 @@
###############################################################################
-use Test;
-use strict;
-
-BEGIN
- {
- plan tests => 51;
- }
+use Test::More tests => 51;
use bigint qw/hex oct/;
@@ -37,7 +31,7 @@ foreach (qw/
{
my ($x,$y) = split /:/;
print "# Try $x\n";
- ok (bigint::_float_constant("$x"),"$y");
+ is (bigint::_float_constant("$x"),"$y");
}
foreach (qw/
@@ -49,72 +43,60 @@ foreach (qw/
{
my ($x,$y) = split /:/;
print "# Try $x\n";
- ok (bigint::_binary_constant("$x"),"$y");
+ is (bigint::_binary_constant("$x"),"$y");
}
###############################################################################
# general tests
-my $x = 5; ok (ref($x) =~ /^Math::BigInt/); # :constant
+my $x = 5; like (ref($x), qr/^Math::BigInt/); # :constant
-# todo: ok (2 + 2.5,4.5); # should still work
-# todo: $x = 2 + 3.5; ok (ref($x),'Math::BigFloat');
+# todo: is (2 + 2.5,4.5); # should still work
+# todo: $x = 2 + 3.5; is (ref($x),'Math::BigFloat');
-$x = 2 ** 255; ok (ref($x) =~ /^Math::BigInt/);
+$x = 2 ** 255; like (ref($x), qr/^Math::BigInt/);
-ok (12->bfac(),479001600);
-ok (9/4,2);
+is (12->bfac(),479001600);
+is (9/4,2);
-ok (4.5+4.5,8); # truncate
-ok (ref(4.5+4.5) =~ /^Math::BigInt/);
+is (4.5+4.5,8); # truncate
+like (ref(4.5+4.5), qr/^Math::BigInt/);
###############################################################################
# accurarcy and precision
-ok_undef (bigint->accuracy());
-ok (bigint->accuracy(12),12);
-ok (bigint->accuracy(),12);
+is (bigint->accuracy(), undef);
+is (bigint->accuracy(12),12);
+is (bigint->accuracy(),12);
-ok_undef (bigint->precision());
-ok (bigint->precision(12),12);
-ok (bigint->precision(),12);
+is (bigint->precision(), undef);
+is (bigint->precision(12),12);
+is (bigint->precision(),12);
-ok (bigint->round_mode(),'even');
-ok (bigint->round_mode('odd'),'odd');
-ok (bigint->round_mode(),'odd');
+is (bigint->round_mode(),'even');
+is (bigint->round_mode('odd'),'odd');
+is (bigint->round_mode(),'odd');
###############################################################################
# hex() and oct()
my $c = 'Math::BigInt';
-ok (ref(hex(1)), $c);
-ok (ref(hex(0x1)), $c);
-ok (ref(hex("af")), $c);
-ok (hex("af"), Math::BigInt->new(0xaf));
-ok (ref(hex("0x1")), $c);
-
-ok (ref(oct("0x1")), $c);
-ok (ref(oct("01")), $c);
-ok (ref(oct("0b01")), $c);
-ok (ref(oct("1")), $c);
-ok (ref(oct(" 1")), $c);
-ok (ref(oct(" 0x1")), $c);
-
-ok (ref(oct(0x1)), $c);
-ok (ref(oct(01)), $c);
-ok (ref(oct(0b01)), $c);
-ok (ref(oct(1)), $c);
-
-###############################################################################
-###############################################################################
-# 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');
- }
+is (ref(hex(1)), $c);
+is (ref(hex(0x1)), $c);
+is (ref(hex("af")), $c);
+is (hex("af"), Math::BigInt->new(0xaf));
+is (ref(hex("0x1")), $c);
+
+is (ref(oct("0x1")), $c);
+is (ref(oct("01")), $c);
+is (ref(oct("0b01")), $c);
+is (ref(oct("1")), $c);
+is (ref(oct(" 1")), $c);
+is (ref(oct(" 0x1")), $c);
+
+is (ref(oct(0x1)), $c);
+is (ref(oct(01)), $c);
+is (ref(oct(0b01)), $c);
+is (ref(oct(1)), $c);
diff --git a/dist/bignum/t/bignum.t b/dist/bignum/t/bignum.t
index d900cbb7a1..6cef5378a6 100644
--- a/dist/bignum/t/bignum.t
+++ b/dist/bignum/t/bignum.t
@@ -2,90 +2,73 @@
###############################################################################
-use Test;
use strict;
-
-BEGIN
- {
- plan tests => 35;
- }
+use Test::More tests => 35;
use bignum qw/oct hex/;
###############################################################################
# general tests
-my $x = 5; ok (ref($x) =~ /^Math::BigInt/); # :constant
+my $x = 5; like (ref($x), qr/^Math::BigInt/); # :constant
-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');
+is (2 + 2.5,4.5);
+$x = 2 + 3.5; is (ref($x),'Math::BigFloat');
+is (2 * 2.1,4.2);
+$x = 2 + 2.1; is (ref($x),'Math::BigFloat');
-$x = 2 ** 255; ok (ref($x) =~ /^Math::BigInt/);
+$x = 2 ** 255; like (ref($x), qr/^Math::BigInt/);
# see if Math::BigInt constant and upgrading works
-ok (Math::BigInt::bsqrt('12'),'3.464101615137754587054892683011744733886');
-ok (sqrt(12),'3.464101615137754587054892683011744733886');
+is (Math::BigInt::bsqrt('12'),'3.464101615137754587054892683011744733886');
+is (sqrt(12),'3.464101615137754587054892683011744733886');
-ok (2/3,"0.6666666666666666666666666666666666666667");
+is (2/3,"0.6666666666666666666666666666666666666667");
-#ok (2 ** 0.5, 'NaN'); # should be sqrt(2);
+#is (2 ** 0.5, 'NaN'); # should be sqrt(2);
-ok (12->bfac(),479001600);
+is (12->bfac(),479001600);
# see if Math::BigFloat constant works
# 0123456789 0123456789 <- default 40
# 0123456789 0123456789
-ok (1/3, '0.3333333333333333333333333333333333333333');
+is (1/3, '0.3333333333333333333333333333333333333333');
###############################################################################
# accurarcy and precision
-ok_undef (bignum->accuracy());
-ok (bignum->accuracy(12),12);
-ok (bignum->accuracy(),12);
+is (bignum->accuracy(), undef);
+is (bignum->accuracy(12),12);
+is (bignum->accuracy(),12);
-ok_undef (bignum->precision());
-ok (bignum->precision(12),12);
-ok (bignum->precision(),12);
+is (bignum->precision(), undef);
+is (bignum->precision(12),12);
+is (bignum->precision(),12);
-ok (bignum->round_mode(),'even');
-ok (bignum->round_mode('odd'),'odd');
-ok (bignum->round_mode(),'odd');
+is (bignum->round_mode(),'even');
+is (bignum->round_mode('odd'),'odd');
+is (bignum->round_mode(),'odd');
###############################################################################
# hex() and oct()
my $c = 'Math::BigInt';
-ok (ref(hex(1)), $c);
-ok (ref(hex(0x1)), $c);
-ok (ref(hex("af")), $c);
-ok (hex("af"), Math::BigInt->new(0xaf));
-ok (ref(hex("0x1")), $c);
-
-ok (ref(oct("0x1")), $c);
-ok (ref(oct("01")), $c);
-ok (ref(oct("0b01")), $c);
-ok (ref(oct("1")), $c);
-ok (ref(oct(" 1")), $c);
-ok (ref(oct(" 0x1")), $c);
-
-ok (ref(oct(0x1)), $c);
-ok (ref(oct(01)), $c);
-ok (ref(oct(0b01)), $c);
-ok (ref(oct(1)), $c);
-
-###############################################################################
-###############################################################################
-# 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');
- }
+is (ref(hex(1)), $c);
+is (ref(hex(0x1)), $c);
+is (ref(hex("af")), $c);
+is (hex("af"), Math::BigInt->new(0xaf));
+is (ref(hex("0x1")), $c);
+
+is (ref(oct("0x1")), $c);
+is (ref(oct("01")), $c);
+is (ref(oct("0b01")), $c);
+is (ref(oct("1")), $c);
+is (ref(oct(" 1")), $c);
+is (ref(oct(" 0x1")), $c);
+
+is (ref(oct(0x1)), $c);
+is (ref(oct(01)), $c);
+is (ref(oct(0b01)), $c);
+is (ref(oct(1)), $c);
diff --git a/dist/bignum/t/bigrat.t b/dist/bignum/t/bigrat.t
index 1423b7d1e0..2865453dc2 100644
--- a/dist/bignum/t/bigrat.t
+++ b/dist/bignum/t/bigrat.t
@@ -2,94 +2,77 @@
###############################################################################
-use Test;
use strict;
-
-BEGIN
- {
- plan tests => 40;
- }
+use Test::More tests => 40;
use bigrat qw/oct hex/;
###############################################################################
# general tests
-my $x = 5; ok (ref($x) =~ /^Math::BigInt/); # :constant
+my $x = 5; like (ref($x), qr/^Math::BigInt/); # :constant
-# todo: ok (2 + 2.5,4.5); # should still work
-# todo: $x = 2 + 3.5; ok (ref($x),'Math::BigFloat');
+# todo: is (2 + 2.5,4.5); # should still work
+# todo: $x = 2 + 3.5; is (ref($x),'Math::BigFloat');
-$x = 2 ** 255; ok (ref($x) =~ /^Math::BigInt/);
+$x = 2 ** 255; like (ref($x), qr/^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');
+is (1/3, '1/3');
+is (1/4+1/3,'7/12');
+is (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');
+is (3/7+1,'10/7');
+is (3/7+1.1,'107/70');
+is (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');
+is (3/7-1,'-4/7');
+is (3/7-1.1,'-47/70');
+is (3/7-2/7,'1/7');
# fails ?
-# ok (1+3/7,'10/7');
+# is (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');
+is (1.1+3/7,'107/70');
+is (3/7*5/7,'15/49');
+is (3/7 / (5/7),'3/5');
+is (3/7 / 1,'3/7');
+is (3/7 / 1.5,'2/7');
###############################################################################
# accurarcy and precision
-ok_undef (bigrat->accuracy());
-ok (bigrat->accuracy(12),12);
-ok (bigrat->accuracy(),12);
+is (bigrat->accuracy(), undef);
+is (bigrat->accuracy(12),12);
+is (bigrat->accuracy(),12);
-ok_undef (bigrat->precision());
-ok (bigrat->precision(12),12);
-ok (bigrat->precision(),12);
+is (bigrat->precision(), undef);
+is (bigrat->precision(12),12);
+is (bigrat->precision(),12);
-ok (bigrat->round_mode(),'even');
-ok (bigrat->round_mode('odd'),'odd');
-ok (bigrat->round_mode(),'odd');
+is (bigrat->round_mode(),'even');
+is (bigrat->round_mode('odd'),'odd');
+is (bigrat->round_mode(),'odd');
###############################################################################
# hex() and oct()
my $c = 'Math::BigInt';
-ok (ref(hex(1)), $c);
-ok (ref(hex(0x1)), $c);
-ok (ref(hex("af")), $c);
-ok (hex("af"), Math::BigInt->new(0xaf));
-ok (ref(hex("0x1")), $c);
-
-ok (ref(oct("0x1")), $c);
-ok (ref(oct("01")), $c);
-ok (ref(oct("0b01")), $c);
-ok (ref(oct("1")), $c);
-ok (ref(oct(" 1")), $c);
-ok (ref(oct(" 0x1")), $c);
-
-ok (ref(oct(0x1)), $c);
-ok (ref(oct(01)), $c);
-ok (ref(oct(0b01)), $c);
-ok (ref(oct(1)), $c);
-
-###############################################################################
-###############################################################################
-# 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');
- }
+is (ref(hex(1)), $c);
+is (ref(hex(0x1)), $c);
+is (ref(hex("af")), $c);
+is (hex("af"), Math::BigInt->new(0xaf));
+is (ref(hex("0x1")), $c);
+
+is (ref(oct("0x1")), $c);
+is (ref(oct("01")), $c);
+is (ref(oct("0b01")), $c);
+is (ref(oct("1")), $c);
+is (ref(oct(" 1")), $c);
+is (ref(oct(" 0x1")), $c);
+
+is (ref(oct(0x1)), $c);
+is (ref(oct(01)), $c);
+is (ref(oct(0b01)), $c);
+is (ref(oct(1)), $c);
diff --git a/dist/bignum/t/biinfnan.t b/dist/bignum/t/biinfnan.t
index 35890723fe..bb9f41f614 100644
--- a/dist/bignum/t/biinfnan.t
+++ b/dist/bignum/t/biinfnan.t
@@ -2,13 +2,8 @@
###############################################################################
-use Test;
use strict;
-
-BEGIN
- {
- plan tests => 26;
- }
+use Test::More tests => 26;
use bigint;
diff --git a/dist/bignum/t/bn_lite.t b/dist/bignum/t/bn_lite.t
index 889bf631e7..28e38c5968 100644
--- a/dist/bignum/t/bn_lite.t
+++ b/dist/bignum/t/bn_lite.t
@@ -2,26 +2,21 @@
###############################################################################
-use Test;
use strict;
-
-BEGIN
- {
- plan tests => 1;
- }
+use Test::More;
eval 'require Math::BigInt::Lite;';
if ($@ eq '')
{
+ plan (tests => 1);
# 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);
+ is ($bignum::_lite,1);
}
else
{
- print "ok 1 # skipped, no Math::BigInt::Lite\n";
+ plan skip_all => "no Math::BigInt::Lite";
}
-
diff --git a/dist/bignum/t/bninfnan.t b/dist/bignum/t/bninfnan.t
index ca7e21b3b7..45f83b98f8 100644
--- a/dist/bignum/t/bninfnan.t
+++ b/dist/bignum/t/bninfnan.t
@@ -2,13 +2,8 @@
###############################################################################
-use Test;
use strict;
-
-BEGIN
- {
- plan tests => 26;
- }
+use Test::More tests => 26;
use bignum;
diff --git a/dist/bignum/t/br_lite.t b/dist/bignum/t/br_lite.t
index 524cc26663..fd6325273c 100644
--- a/dist/bignum/t/br_lite.t
+++ b/dist/bignum/t/br_lite.t
@@ -2,26 +2,21 @@
###############################################################################
-use Test;
use strict;
-
-BEGIN
- {
- plan tests => 1;
- }
+use Test::More;
eval 'require Math::BigInt::Lite;';
if ($@ eq '')
{
+ plan (tests => 1);
# 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);
+ is ($bigrat::_lite,1);
}
else
{
- print "ok 1 # skipped, no Math::BigInt::Lite\n";
+ plan (skip_all => "no Math::BigInt::Lite");
}
-
diff --git a/dist/bignum/t/brinfnan.t b/dist/bignum/t/brinfnan.t
index c79b814d67..ce7daa189d 100644
--- a/dist/bignum/t/brinfnan.t
+++ b/dist/bignum/t/brinfnan.t
@@ -2,13 +2,8 @@
###############################################################################
-use Test;
use strict;
-
-BEGIN
- {
- plan tests => 26;
- }
+use Test::More tests => 26;
use bigrat;
diff --git a/dist/bignum/t/infnan.inc b/dist/bignum/t/infnan.inc
index 771b94e748..561adc1a70 100644
--- a/dist/bignum/t/infnan.inc
+++ b/dist/bignum/t/infnan.inc
@@ -6,30 +6,30 @@ 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');
+$x = 1+inf; like (ref($x), qr/^Math::BigInt/); is ($x->bstr(),'inf');
+$x = 1*inf; like (ref($x), qr/^Math::BigInt/); is ($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');
+$x = inf; like (ref($x), qr/^Math::BigInt/); is ($x->bstr(),'inf');
+$x = inf+inf; like (ref($x), qr/^Math::BigInt/); is ($x->bstr(),'inf');
+$x = inf*inf; like (ref($x), qr/^Math::BigInt/); is ($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');
+$x = 1+NaN; like (ref($x), qr/^Math::BigInt/); is ($x->bstr(),'NaN');
+$x = 1*NaN; like (ref($x), qr/^Math::BigInt/); is ($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');
+$x = NaN; like (ref($x), qr/^Math::BigInt/); is ($x->bstr(),'NaN');
+$x = NaN+NaN; like (ref($x), qr/^Math::BigInt/); is ($x->bstr(),'NaN');
+$x = NaN*NaN; like (ref($x), qr/^Math::BigInt/); is ($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');
+$x = NaN+inf; like (ref($x), qr/^Math::BigInt/); is ($x->bstr(),'NaN');
+$x = NaN*inf; like (ref($x), qr/^Math::BigInt/); is ($x->bstr(),'NaN');
+$x = inf*NaN; like (ref($x), qr/^Math::BigInt/); is ($x->bstr(),'NaN');