summaryrefslogtreecommitdiff
path: root/cpan/Math-BigRat
diff options
context:
space:
mode:
authorFlorian Ragwitz <rafl@debian.org>2010-09-15 16:54:22 +0200
committerFlorian Ragwitz <rafl@debian.org>2010-09-15 16:54:22 +0200
commitc32198f6de5a51e5a974fac12c99530219fa3797 (patch)
treec1ccbb982d2ba7d88f0ece22f2ed9cad8a62a7b5 /cpan/Math-BigRat
parent1e7868346284e83b3b2359a1ae43d11a29cb8f00 (diff)
downloadperl-c32198f6de5a51e5a974fac12c99530219fa3797.tar.gz
Upgrade Math::BigRat from version 0.25 to 0.26
Lots of unnecessary test boilerplate has been removed, allowing us to remove the dist from both %abs and %temp_no_core in t/TEST.
Diffstat (limited to 'cpan/Math-BigRat')
-rw-r--r--cpan/Math-BigRat/lib/Math/BigRat.pm2
-rw-r--r--cpan/Math-BigRat/t/big_ap.t44
-rw-r--r--cpan/Math-BigRat/t/bigfltrt.t34
-rw-r--r--cpan/Math-BigRat/t/biglog.t28
-rw-r--r--cpan/Math-BigRat/t/bigrat.t302
-rw-r--r--cpan/Math-BigRat/t/bigratpm.inc40
-rw-r--r--cpan/Math-BigRat/t/bigratpm.t30
-rw-r--r--cpan/Math-BigRat/t/bigratup.t10
-rw-r--r--cpan/Math-BigRat/t/bigroot.t28
-rw-r--r--cpan/Math-BigRat/t/hang.t10
-rw-r--r--cpan/Math-BigRat/t/requirer.t28
-rw-r--r--cpan/Math-BigRat/t/trap.t53
12 files changed, 210 insertions, 399 deletions
diff --git a/cpan/Math-BigRat/lib/Math/BigRat.pm b/cpan/Math-BigRat/lib/Math/BigRat.pm
index 17acfadf9f..030a87ecdb 100644
--- a/cpan/Math-BigRat/lib/Math/BigRat.pm
+++ b/cpan/Math-BigRat/lib/Math/BigRat.pm
@@ -23,7 +23,7 @@ use vars qw($VERSION @ISA $upgrade $downgrade
@ISA = qw(Math::BigFloat);
-$VERSION = '0.25';
+$VERSION = '0.26';
$VERSION = eval $VERSION;
use overload; # inherit overload from Math::BigFloat
diff --git a/cpan/Math-BigRat/t/big_ap.t b/cpan/Math-BigRat/t/big_ap.t
index 8e261f61a4..39a2f7185b 100644
--- a/cpan/Math-BigRat/t/big_ap.t
+++ b/cpan/Math-BigRat/t/big_ap.t
@@ -3,16 +3,8 @@
# Test that accuracy() and precision() in BigInt/BigFloat do not disturb
# the rounding force in BigRat.
-use Test;
use strict;
-
-BEGIN
- {
- $| = 1;
- chdir 't' if -d 't';
- unshift @INC, '../lib';
- plan tests => 17;
- }
+use Test::More tests => 17;
use Math::BigInt;
use Math::BigFloat;
@@ -37,67 +29,67 @@ my ($x,$y,$z);
# new()
$z = $r->new('12345678901234567890/2');
-ok ($z,$proper);
+is ($z,$proper);
$z = $r->new('1234567890123456789E1');
-ok ($z,$proper2);
+is ($z,$proper2);
$z = $r->new('12345678901234567890/1E0');
-ok ($z,$proper2);
+is ($z,$proper2);
$z = $r->new('1234567890123456789e1/1');
-ok ($z,$proper2);
+is ($z,$proper2);
$z = $r->new('1234567890123456789e1/1E0');
-ok ($z,$proper2);
+is ($z,$proper2);
$z = $r->new($proper_int);
-ok ($z,$proper2);
+is ($z,$proper2);
$z = $r->new($proper_float);
-ok ($z,$proper2);
+is ($z,$proper2);
##############################################################################
# bdiv
$x = $r->new('12345678901234567890'); $y = Math::BigRat->new('2');
$z = $x->copy->bdiv($y);
-ok ($z,$proper);
+is ($z,$proper);
##############################################################################
# bmul
$x = $r->new("$proper"); $y = Math::BigRat->new('1');
$z = $x->copy->bmul($y);
-ok ($z,$proper);
+is ($z,$proper);
$z = $r->new('12345678901234567890/1E0');
-ok ($z,$proper2);
+is ($z,$proper2);
$z = $r->new($proper_int);
-ok ($z,$proper2);
+is ($z,$proper2);
$z = $r->new($proper_float);
-ok ($z,$proper2);
+is ($z,$proper2);
##############################################################################
# bdiv
$x = $r->new('12345678901234567890'); $y = Math::BigRat->new('2');
$z = $x->copy->bdiv($y);
-ok ($z,$proper);
+is ($z,$proper);
##############################################################################
# bmul
$x = $r->new("$proper"); $y = Math::BigRat->new('1');
$z = $x->copy->bmul($y);
-ok ($z,$proper);
+is ($z,$proper);
$x = $r->new("$proper"); $y = Math::BigRat->new('2');
$z = $x->copy->bmul($y);
-ok ($z,$proper2);
+is ($z,$proper2);
##############################################################################
# binc/bdec
-$x = $proper->copy()->binc(); ok ($x,$proper_inc);
-$x = $proper->copy()->bdec(); ok ($x,$proper_dec);
+$x = $proper->copy()->binc(); is ($x,$proper_inc);
+$x = $proper->copy()->bdec(); is ($x,$proper_dec);
diff --git a/cpan/Math-BigRat/t/bigfltrt.t b/cpan/Math-BigRat/t/bigfltrt.t
index ff911b9076..278980ac57 100644
--- a/cpan/Math-BigRat/t/bigfltrt.t
+++ b/cpan/Math-BigRat/t/bigfltrt.t
@@ -1,33 +1,11 @@
#!/usr/bin/perl -w
-use Test;
use strict;
+use Test::More tests => 1;
-BEGIN
- {
- $| = 1;
- # to locate the testing files
- my $location = $0; $location =~ s/bigfltrt.t//i;
- if ($ENV{PERL_CORE})
- {
- # testing with the core distribution
- @INC = qw(../t/lib);
- }
- unshift @INC, '../lib';
- if (-d 't')
- {
- chdir 't';
- require File::Spec;
- unshift @INC, File::Spec->catdir(File::Spec->updir, $location);
- }
- else
- {
- unshift @INC, $location;
- }
- print "# INC = @INC\n";
-
- plan tests => 1;
- }
+BEGIN {
+ unshift @INC, 't';
+}
use Math::BigRat::Test lib => 'Calc'; # test via this Subclass
@@ -35,7 +13,7 @@ use vars qw ($class $try $x $y $f @args $ans $ans1 $ans1_str $setup $CL);
$class = "Math::BigRat::Test";
$CL = "Math::BigInt::Calc";
-ok (1,1);
+pass();
# fails still too many tests
-#require 'bigfltpm.inc'; # all tests here for sharing
+#require 't/bigfltpm.inc'; # all tests here for sharing
diff --git a/cpan/Math-BigRat/t/biglog.t b/cpan/Math-BigRat/t/biglog.t
index 3002c2079c..5c4b96b3d4 100644
--- a/cpan/Math-BigRat/t/biglog.t
+++ b/cpan/Math-BigRat/t/biglog.t
@@ -2,34 +2,8 @@
# Test blog function (and bpow, since it uses blog), as well as bexp().
-use Test::More;
use strict;
-
-BEGIN
- {
- $| = 1;
- # to locate the testing files
- my $location = $0; $location =~ s/biglog.t//i;
- if ($ENV{PERL_CORE})
- {
- # testing with the core distribution
- @INC = qw(../lib);
- }
- unshift @INC, '../lib';
- if (-d 't')
- {
- chdir 't';
- require File::Spec;
- unshift @INC, File::Spec->catdir(File::Spec->updir, $location);
- }
- else
- {
- unshift @INC, $location;
- }
- print "# INC = @INC\n";
-
- plan tests => 17;
- }
+use Test::More tests => 17;
use Math::BigRat;
diff --git a/cpan/Math-BigRat/t/bigrat.t b/cpan/Math-BigRat/t/bigrat.t
index c7563e5f70..4d1d451489 100644
--- a/cpan/Math-BigRat/t/bigrat.t
+++ b/cpan/Math-BigRat/t/bigrat.t
@@ -1,15 +1,7 @@
#!/usr/bin/perl -w
use strict;
-use Test;
-
-BEGIN
- {
- $| = 1;
- chdir 't' if -d 't';
- unshift @INC, '../lib'; # for running manually
- plan tests => 200;
- }
+use Test::More tests => 200;
# basic testing of Math::BigRat
@@ -24,240 +16,240 @@ my $mbf = 'Math::BigFloat';
my ($x,$y,$z);
-$x = Math::BigRat->new(1234); ok ($x,1234);
-ok ($x->isa('Math::BigRat'));
-ok (!$x->isa('Math::BigFloat'));
-ok (!$x->isa('Math::BigInt'));
+$x = Math::BigRat->new(1234); is ($x,1234);
+isa_ok ($x, 'Math::BigRat');
+is ($x->isa('Math::BigFloat'), 0);
+is ($x->isa('Math::BigInt'), 0);
##############################################################################
# new and bnorm()
foreach my $func (qw/new bnorm/)
{
- $x = $cr->$func(1234); ok ($x,1234);
-
- $x = $cr->$func('1234/1'); ok ($x,1234);
- $x = $cr->$func('1234/2'); ok ($x,617);
-
- $x = $cr->$func('100/1.0'); ok ($x,100);
- $x = $cr->$func('10.0/1.0'); ok ($x,10);
- $x = $cr->$func('0.1/10'); ok ($x,'1/100');
- $x = $cr->$func('0.1/0.1'); ok ($x,'1');
- $x = $cr->$func('1e2/10'); ok ($x,10);
- $x = $cr->$func('5/1e2'); ok ($x,'1/20');
- $x = $cr->$func('1e2/1e1'); ok ($x,10);
- $x = $cr->$func('1 / 3'); ok ($x,'1/3');
- $x = $cr->$func('-1 / 3'); ok ($x,'-1/3');
- $x = $cr->$func('NaN'); ok ($x,'NaN');
- $x = $cr->$func('inf'); ok ($x,'inf');
- $x = $cr->$func('-inf'); ok ($x,'-inf');
- $x = $cr->$func('1/'); ok ($x,'NaN');
-
- $x = $cr->$func("0x7e"); ok($x, 126);
+ $x = $cr->$func(1234); is ($x,1234);
+
+ $x = $cr->$func('1234/1'); is ($x,1234);
+ $x = $cr->$func('1234/2'); is ($x,617);
+
+ $x = $cr->$func('100/1.0'); is ($x,100);
+ $x = $cr->$func('10.0/1.0'); is ($x,10);
+ $x = $cr->$func('0.1/10'); is ($x,'1/100');
+ $x = $cr->$func('0.1/0.1'); is ($x,'1');
+ $x = $cr->$func('1e2/10'); is ($x,10);
+ $x = $cr->$func('5/1e2'); is ($x,'1/20');
+ $x = $cr->$func('1e2/1e1'); is ($x,10);
+ $x = $cr->$func('1 / 3'); is ($x,'1/3');
+ $x = $cr->$func('-1 / 3'); is ($x,'-1/3');
+ $x = $cr->$func('NaN'); is ($x,'NaN');
+ $x = $cr->$func('inf'); is ($x,'inf');
+ $x = $cr->$func('-inf'); is ($x,'-inf');
+ $x = $cr->$func('1/'); is ($x,'NaN');
+
+ $x = $cr->$func("0x7e"); is ($x,126);
# input ala '1+1/3' isn't parsed ok yet
- $x = $cr->$func('1+1/3'); ok ($x,'NaN');
+ $x = $cr->$func('1+1/3'); is ($x,'NaN');
- $x = $cr->$func('1/1.2'); ok ($x,'5/6');
- $x = $cr->$func('1.3/1.2'); ok ($x,'13/12');
- $x = $cr->$func('1.2/1'); ok ($x,'6/5');
+ $x = $cr->$func('1/1.2'); is ($x,'5/6');
+ $x = $cr->$func('1.3/1.2'); is ($x,'13/12');
+ $x = $cr->$func('1.2/1'); is ($x,'6/5');
############################################################################
# other classes as input
- $x = $cr->$func($mbi->new(1231)); ok ($x,'1231');
- $x = $cr->$func($mbf->new(1232)); ok ($x,'1232');
- $x = $cr->$func($mbf->new(1232.3)); ok ($x,'12323/10');
+ $x = $cr->$func($mbi->new(1231)); is ($x,'1231');
+ $x = $cr->$func($mbf->new(1232)); is ($x,'1232');
+ $x = $cr->$func($mbf->new(1232.3)); is ($x,'12323/10');
}
my $n = 'numerator';
my $d = 'denominator';
-$x = $cr->new('-0'); ok ($x,'0'); ok ($x->$n(), '0'); ok ($x->$d(),'1');
-$x = $cr->new('NaN'); ok ($x,'NaN'); ok ($x->$n(), 'NaN'); ok ($x->$d(),'NaN');
-$x = $cr->new('-NaN'); ok ($x,'NaN'); ok ($x->$n(), 'NaN'); ok ($x->$d(),'NaN');
-$x = $cr->new('-1r4'); ok ($x,'NaN'); ok ($x->$n(), 'NaN'); ok ($x->$d(),'NaN');
+$x = $cr->new('-0'); is ($x,'0'); is ($x->$n(), '0'); is ($x->$d(),'1');
+$x = $cr->new('NaN'); is ($x,'NaN'); is ($x->$n(), 'NaN'); is ($x->$d(),'NaN');
+$x = $cr->new('-NaN'); is ($x,'NaN'); is ($x->$n(), 'NaN'); is ($x->$d(),'NaN');
+$x = $cr->new('-1r4'); is ($x,'NaN'); is ($x->$n(), 'NaN'); is ($x->$d(),'NaN');
-$x = $cr->new('+inf'); ok ($x,'inf'); ok ($x->$n(), 'inf'); ok ($x->$d(),'1');
-$x = $cr->new('-inf'); ok ($x,'-inf'); ok ($x->$n(), '-inf'); ok ($x->$d(),'1');
-$x = $cr->new('123a4'); ok ($x,'NaN'); ok ($x->$n(), 'NaN'); ok ($x->$d(),'NaN');
+$x = $cr->new('+inf'); is ($x,'inf'); is ($x->$n(), 'inf'); is ($x->$d(),'1');
+$x = $cr->new('-inf'); is ($x,'-inf'); is ($x->$n(), '-inf'); is ($x->$d(),'1');
+$x = $cr->new('123a4'); is ($x,'NaN'); is ($x->$n(), 'NaN'); is ($x->$d(),'NaN');
# wrong inputs
-$x = $cr->new('1e2e2'); ok ($x,'NaN'); ok ($x->$n(), 'NaN'); ok ($x->$d(),'NaN');
-$x = $cr->new('1+2+2'); ok ($x,'NaN'); ok ($x->$n(), 'NaN'); ok ($x->$d(),'NaN');
+$x = $cr->new('1e2e2'); is ($x,'NaN'); is ($x->$n(), 'NaN'); is ($x->$d(),'NaN');
+$x = $cr->new('1+2+2'); is ($x,'NaN'); is ($x->$n(), 'NaN'); is ($x->$d(),'NaN');
# failed due to BigFloat bug
-$x = $cr->new('1.2.2'); ok ($x,'NaN'); ok ($x->$n(), 'NaN'); ok ($x->$d(),'NaN');
+$x = $cr->new('1.2.2'); is ($x,'NaN'); is ($x->$n(), 'NaN'); is ($x->$d(),'NaN');
-ok ($cr->new('123a4'),'NaN');
-ok ($cr->new('123e4'),'1230000');
-ok ($cr->new('-NaN'),'NaN');
-ok ($cr->new('NaN'),'NaN');
-ok ($cr->new('+inf'),'inf');
-ok ($cr->new('-inf'),'-inf');
+is ($cr->new('123a4'),'NaN');
+is ($cr->new('123e4'),'1230000');
+is ($cr->new('-NaN'),'NaN');
+is ($cr->new('NaN'),'NaN');
+is ($cr->new('+inf'),'inf');
+is ($cr->new('-inf'),'-inf');
##############################################################################
# two Bigints
-ok ($cr->new($mbi->new(3),$mbi->new(7))->badd(1),'10/7');
-ok ($cr->new($mbi->new(-13),$mbi->new(7)),'-13/7');
-ok ($cr->new($mbi->new(13),$mbi->new(-7)),'-13/7');
-ok ($cr->new($mbi->new(-13),$mbi->new(-7)),'13/7');
+is ($cr->new($mbi->new(3),$mbi->new(7))->badd(1),'10/7');
+is ($cr->new($mbi->new(-13),$mbi->new(7)),'-13/7');
+is ($cr->new($mbi->new(13),$mbi->new(-7)),'-13/7');
+is ($cr->new($mbi->new(-13),$mbi->new(-7)),'13/7');
##############################################################################
# mixed arguments
-ok ($cr->new('3/7')->badd(1),'10/7');
-ok ($cr->new('3/10')->badd(1.1),'7/5');
-ok ($cr->new('3/7')->badd($mbi->new(1)),'10/7');
-ok ($cr->new('3/10')->badd($mbf->new('1.1')),'7/5');
+is ($cr->new('3/7')->badd(1),'10/7');
+is ($cr->new('3/10')->badd(1.1),'7/5');
+is ($cr->new('3/7')->badd($mbi->new(1)),'10/7');
+is ($cr->new('3/10')->badd($mbf->new('1.1')),'7/5');
-ok ($cr->new('3/7')->bsub(1),'-4/7');
-ok ($cr->new('3/10')->bsub(1.1),'-4/5');
-ok ($cr->new('3/7')->bsub($mbi->new(1)),'-4/7');
-ok ($cr->new('3/10')->bsub($mbf->new('1.1')),'-4/5');
+is ($cr->new('3/7')->bsub(1),'-4/7');
+is ($cr->new('3/10')->bsub(1.1),'-4/5');
+is ($cr->new('3/7')->bsub($mbi->new(1)),'-4/7');
+is ($cr->new('3/10')->bsub($mbf->new('1.1')),'-4/5');
-ok ($cr->new('3/7')->bmul(1),'3/7');
-ok ($cr->new('3/10')->bmul(1.1),'33/100');
-ok ($cr->new('3/7')->bmul($mbi->new(1)),'3/7');
-ok ($cr->new('3/10')->bmul($mbf->new('1.1')),'33/100');
+is ($cr->new('3/7')->bmul(1),'3/7');
+is ($cr->new('3/10')->bmul(1.1),'33/100');
+is ($cr->new('3/7')->bmul($mbi->new(1)),'3/7');
+is ($cr->new('3/10')->bmul($mbf->new('1.1')),'33/100');
-ok ($cr->new('3/7')->bdiv(1),'3/7');
-ok ($cr->new('3/10')->bdiv(1.1),'3/11');
-ok ($cr->new('3/7')->bdiv($mbi->new(1)),'3/7');
-ok ($cr->new('3/10')->bdiv($mbf->new('1.1')),'3/11');
+is ($cr->new('3/7')->bdiv(1),'3/7');
+is ($cr->new('3/10')->bdiv(1.1),'3/11');
+is ($cr->new('3/7')->bdiv($mbi->new(1)),'3/7');
+is ($cr->new('3/10')->bdiv($mbf->new('1.1')),'3/11');
##############################################################################
$x = $cr->new('1/4'); $y = $cr->new('1/3');
-ok ($x + $y, '7/12');
-ok ($x * $y, '1/12');
-ok ($x / $y, '3/4');
+is ($x + $y, '7/12');
+is ($x * $y, '1/12');
+is ($x / $y, '3/4');
$x = $cr->new('7/5'); $x *= '3/2';
-ok ($x,'21/10');
+is ($x,'21/10');
$x -= '0.1';
-ok ($x,'2'); # not 21/10
+is ($x,'2'); # not 21/10
$x = $cr->new('2/3'); $y = $cr->new('3/2');
-ok ($x > $y,'');
-ok ($x < $y,1);
-ok ($x == $y,'');
+is ($x > $y,'');
+is ($x < $y,1);
+is ($x == $y,'');
$x = $cr->new('-2/3'); $y = $cr->new('3/2');
-ok ($x > $y,'');
-ok ($x < $y,'1');
-ok ($x == $y,'');
+is ($x > $y,'');
+is ($x < $y,'1');
+is ($x == $y,'');
$x = $cr->new('-2/3'); $y = $cr->new('-2/3');
-ok ($x > $y,'');
-ok ($x < $y,'');
-ok ($x == $y,'1');
+is ($x > $y,'');
+is ($x < $y,'');
+is ($x == $y,'1');
$x = $cr->new('-2/3'); $y = $cr->new('-1/3');
-ok ($x > $y,'');
-ok ($x < $y,'1');
-ok ($x == $y,'');
+is ($x > $y,'');
+is ($x < $y,'1');
+is ($x == $y,'');
$x = $cr->new('-124'); $y = $cr->new('-122');
-ok ($x->bacmp($y),1);
+is ($x->bacmp($y),1);
$x = $cr->new('-124'); $y = $cr->new('-122');
-ok ($x->bcmp($y),-1);
+is ($x->bcmp($y),-1);
$x = $cr->new('3/7'); $y = $cr->new('5/7');
-ok ($x+$y,'8/7');
+is ($x+$y,'8/7');
$x = $cr->new('3/7'); $y = $cr->new('5/7');
-ok ($x*$y,'15/49');
+is ($x*$y,'15/49');
$x = $cr->new('3/5'); $y = $cr->new('5/7');
-ok ($x*$y,'3/7');
+is ($x*$y,'3/7');
$x = $cr->new('3/5'); $y = $cr->new('5/7');
-ok ($x/$y,'21/25');
+is ($x/$y,'21/25');
$x = $cr->new('7/4'); $y = $cr->new('1');
-ok ($x % $y,'3/4');
+is ($x % $y,'3/4');
$x = $cr->new('7/4'); $y = $cr->new('5/13');
-ok ($x % $y,'11/52');
+is ($x % $y,'11/52');
$x = $cr->new('7/4'); $y = $cr->new('5/9');
-ok ($x % $y,'1/12');
+is ($x % $y,'1/12');
-$x = $cr->new('-144/9')->bsqrt(); ok ($x,'NaN');
-$x = $cr->new('144/9')->bsqrt(); ok ($x,'4');
-$x = $cr->new('3/4')->bsqrt(); ok ($x,
+$x = $cr->new('-144/9')->bsqrt(); is ($x,'NaN');
+$x = $cr->new('144/9')->bsqrt(); is ($x,'4');
+$x = $cr->new('3/4')->bsqrt(); is ($x,
'1732050807568877293527446341505872366943/'
.'2000000000000000000000000000000000000000');
##############################################################################
# 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');
+$x = $cr->new('2/1'); $z = $x->bpow('3/1'); is ($x,'8');
+$x = $cr->new('1/2'); $z = $x->bpow('3/1'); is ($x,'1/8');
+$x = $cr->new('1/3'); $z = $x->bpow('4/1'); is ($x,'1/81');
+$x = $cr->new('2/3'); $z = $x->bpow('4/1'); is ($x,'16/81');
$x = $cr->new('2/3'); $z = $x->bpow('5/3');
-ok ($x, '31797617848703662994667839220546583581/62500000000000000000000000000000000000');
+is ($x, '31797617848703662994667839220546583581/62500000000000000000000000000000000000');
##############################################################################
# bfac
-$x = $cr->new('1'); $x->bfac(); ok ($x,'1');
+$x = $cr->new('1'); $x->bfac(); is ($x,'1');
for (my $i = 0; $i < 8; $i++)
{
- $x = $cr->new("$i/1")->bfac(); ok ($x,$mbi->new($i)->bfac());
+ $x = $cr->new("$i/1")->bfac(); is ($x,$mbi->new($i)->bfac());
}
# test for $self->bnan() vs. $x->bnan();
-$x = $cr->new('-1'); $x->bfac(); ok ($x,'NaN');
+$x = $cr->new('-1'); $x->bfac(); is ($x,'NaN');
##############################################################################
# binc/bdec
-$x = $cr->new('3/2'); ok ($x->binc(),'5/2');
-$x = $cr->new('15/6'); ok ($x->bdec(),'3/2');
+$x = $cr->new('3/2'); is ($x->binc(),'5/2');
+$x = $cr->new('15/6'); is ($x->bdec(),'3/2');
##############################################################################
# bfloor/bceil
-$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');
+$x = $cr->new('-7/7'); is ($x->$n(), '-1'); is ($x->$d(), '1');
+$x = $cr->new('-7/7')->bfloor(); is ($x->$n(), '-1'); is ($x->$d(), '1');
##############################################################################
# bsstr
-$x = $cr->new('7/5')->bsstr(); ok ($x,'7/5');
-$x = $cr->new('-7/5')->bsstr(); ok ($x,'-7/5');
+$x = $cr->new('7/5')->bsstr(); is ($x,'7/5');
+$x = $cr->new('-7/5')->bsstr(); is ($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('-8/1'); ok ($array[$x],2); # -8 => 2
+$x = $cr->new('8/8'); is ($array[$x],2);
+$x = $cr->new('16/8'); is ($array[$x],3);
+$x = $cr->new('17/8'); is ($array[$x],3);
+$x = $cr->new('33/8'); is ($array[$x],5);
+$x = $cr->new('-33/8'); is ($array[$x],6);
+$x = $cr->new('-8/1'); is ($array[$x],2); # -8 => 2
-$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');
+$x = $cr->new('33/8'); is ($x->numify() * 1000, 4125);
+$x = $cr->new('-33/8'); is ($x->numify() * 1000, -4125);
+$x = $cr->new('inf'); is ($x->numify(), 'inf');
+$x = $cr->new('-inf'); is ($x->numify(), '-inf');
+$x = $cr->new('NaN'); is ($x->numify(), 'NaN');
-$x = $cr->new('4/3'); ok ($x->numify(), 4/3);
+$x = $cr->new('4/3'); is ($x->numify(), 4/3);
##############################################################################
# as_hex(), as_bin(), as_oct()
$x = $cr->new('8/8');
-ok ($x->as_hex(), '0x1'); ok ($x->as_bin(), '0b1'); ok ($x->as_oct(), '01');
+is ($x->as_hex(), '0x1'); is ($x->as_bin(), '0b1'); is ($x->as_oct(), '01');
$x = $cr->new('80/8');
-ok ($x->as_hex(), '0xa'); ok ($x->as_bin(), '0b1010'); ok ($x->as_oct(), '012');
+is ($x->as_hex(), '0xa'); is ($x->as_bin(), '0b1010'); is ($x->as_oct(), '012');
##############################################################################
# broot(), blog(), bmodpow() and bmodinv()
@@ -266,65 +258,65 @@ $x = $cr->new(2) ** 32;
$y = $cr->new(4);
$z = $cr->new(3);
-ok ($x->copy()->broot($y), 2 ** 8);
-ok (ref($x->copy()->broot($y)), $cr);
+is ($x->copy()->broot($y), 2 ** 8);
+is (ref($x->copy()->broot($y)), $cr);
-ok ($x->copy()->bmodpow($y,$z), 1);
-ok (ref($x->copy()->bmodpow($y,$z)), $cr);
+is ($x->copy()->bmodpow($y,$z), 1);
+is (ref($x->copy()->bmodpow($y,$z)), $cr);
$x = $cr->new(8);
$y = $cr->new(5033);
$z = $cr->new(4404);
-ok ($x->copy()->bmodinv($y), $z);
-ok (ref($x->copy()->bmodinv($y)), $cr);
+is ($x->copy()->bmodinv($y), $z);
+is (ref($x->copy()->bmodinv($y)), $cr);
# square root with exact result
$x = $cr->new('1.44');
-ok ($x->copy()->broot(2), '6/5');
-ok (ref($x->copy()->broot(2)), $cr);
+is ($x->copy()->broot(2), '6/5');
+is (ref($x->copy()->broot(2)), $cr);
# log with exact result
$x = $cr->new('256.1');
-ok ($x->copy()->blog(2), '8000563442710106079310294693803606983661/1000000000000000000000000000000000000000');
-ok (ref($x->copy()->blog(2)), $cr);
+is ($x->copy()->blog(2), '8000563442710106079310294693803606983661/1000000000000000000000000000000000000000');
+is (ref($x->copy()->blog(2)), $cr);
$x = $cr->new(144);
-ok ($x->copy()->broot('2'), 12, 'v/144 = 12');
+is ($x->copy()->broot('2'), 12, 'v/144 = 12');
$x = $cr->new(12*12*12);
-ok ($x->copy()->broot('3'), 12, '(12*12*12) ** 1/3 = 12');
+is ($x->copy()->broot('3'), 12, '(12*12*12) ** 1/3 = 12');
##############################################################################
# from_hex(), from_bin(), from_oct()
$x = Math::BigRat->from_hex('0x100');
-ok ($x, '256', 'from_hex');
+is ($x, '256', 'from_hex');
$x = $cr->from_hex('0x100');
-ok ($x, '256', 'from_hex');
+is ($x, '256', 'from_hex');
$x = Math::BigRat->from_bin('0b100');
-ok ($x, '4', 'from_bin');
+is ($x, '4', 'from_bin');
$x = $cr->from_bin('0b100');
-ok ($x, '4', 'from_bin');
+is ($x, '4', 'from_bin');
$x = Math::BigRat->from_oct('0100');
-ok ($x, '64', 'from_oct');
+is ($x, '64', 'from_oct');
$x = $cr->from_oct('0100');
-ok ($x, '64', 'from_oct');
+is ($x, '64', 'from_oct');
##############################################################################
# as_float()
$x = Math::BigRat->new('1/2'); my $f = $x->as_float();
-ok ($x, '1/2', '$x unmodified');
-ok ($f, '0.5', 'as_float(0.5)');
+is ($x, '1/2', '$x unmodified');
+is ($f, '0.5', 'as_float(0.5)');
$x = Math::BigRat->new('2/3'); $f = $x->as_float(5);
-ok ($x, '2/3', '$x unmodified');
-ok ($f, '0.66667', 'as_float(2/3,5)');
+is ($x, '2/3', '$x unmodified');
+is ($f, '0.66667', 'as_float(2/3,5)');
##############################################################################
# done
diff --git a/cpan/Math-BigRat/t/bigratpm.inc b/cpan/Math-BigRat/t/bigratpm.inc
index 3a9b851f84..11028569a1 100644
--- a/cpan/Math-BigRat/t/bigratpm.inc
+++ b/cpan/Math-BigRat/t/bigratpm.inc
@@ -1,6 +1,6 @@
#include this file into another test for subclass testing...
-ok ($class->config()->{lib},$CL);
+is ($class->config()->{lib},$CL);
$setup = '';
@@ -126,31 +126,24 @@ while (<DATA>)
if ($ans =~ m|^/(.*)$|)
{
my $pat = $1;
- if ($ans1 =~ /$pat/)
- {
- ok (1,1);
- }
- else
- {
- print "# '$try' expected: /$pat/ got: '$ans1'\n" if !ok(1,0);
- }
+ like ($ans1, qr/$pat/);
}
else
{
if ($ans eq "")
{
- ok_undef ($ans1);
+ is ($ans1, undef);
}
else
{
- print "# Tried: '$try'\n" if !ok ($ans1, $ans);
+ is ($ans1, $ans) or diag("Tried: '$try'");
# if (ref($ans1) eq "$class")
# {
# # float numbers are normalized (for now), so mantissa shouldn't have
# # trailing zeros
# #print $ans1->_trailing_zeros(),"\n";
# print "# Has trailing zeros after '$try'\n"
-# if !ok ($ans1->{_m}->_trailing_zeros(), 0);
+# if !is ($ans1->{_m}->_trailing_zeros(), 0);
# }
}
} # end pattern or string
@@ -160,28 +153,15 @@ while (<DATA>)
# check whether $class->new( Math::BigInt->new()) destroys it
# ($y == 12 in this case)
$x = Math::BigInt->new(1200); $y = $class->new($x);
-ok ($y,1200); ok ($x,1200);
+is ($y,1200); is ($x,1200);
###############################################################################
# zero,inf,one,nan
-$x = $class->new(2); $x->bzero(); ok_undef ($x->{_a}); ok_undef ($x->{_p});
-$x = $class->new(2); $x->binf(); ok_undef ($x->{_a}); ok_undef ($x->{_p});
-$x = $class->new(2); $x->bone(); ok_undef ($x->{_a}); ok_undef ($x->{_p});
-$x = $class->new(2); $x->bnan(); ok_undef ($x->{_a}); ok_undef ($x->{_p});
-
-1; # all done
-
-###############################################################################
-# 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');
- }
+$x = $class->new(2); $x->bzero(); is ($x->{_a}, undef); is ($x->{_p}, undef);
+$x = $class->new(2); $x->binf(); is ($x->{_a}, undef); is ($x->{_p}, undef);
+$x = $class->new(2); $x->bone(); is ($x->{_a}, undef); is ($x->{_p}, undef);
+$x = $class->new(2); $x->bnan(); is ($x->{_a}, undef); is ($x->{_p}, undef);
__DATA__
&digit
diff --git a/cpan/Math-BigRat/t/bigratpm.t b/cpan/Math-BigRat/t/bigratpm.t
index 465d698c37..d6bb22b1cf 100644
--- a/cpan/Math-BigRat/t/bigratpm.t
+++ b/cpan/Math-BigRat/t/bigratpm.t
@@ -1,33 +1,7 @@
#!/usr/bin/perl -w
-use Test;
use strict;
-
-BEGIN
- {
- $| = 1;
- # to locate the testing files
- my $location = $0; $location =~ s/bigratpm.t//i;
- if ($ENV{PERL_CORE})
- {
- # testing with the core distribution
- @INC = qw(../lib);
- }
- unshift @INC, '../lib';
- if (-d 't')
- {
- chdir 't';
- require File::Spec;
- unshift @INC, File::Spec->catdir(File::Spec->updir, $location);
- }
- else
- {
- unshift @INC, $location;
- }
- print "# INC = @INC\n";
-
- plan tests => 686;
- }
+use Test::More tests => 686;
use Math::BigRat lib => 'Calc';
@@ -35,4 +9,4 @@ use vars qw ($class $try $x $y $f @args $ans $ans1 $ans1_str $setup $CL);
$class = "Math::BigRat";
$CL = "Math::BigInt::Calc";
-require 'bigratpm.inc'; # all tests here for sharing
+require 't/bigratpm.inc'; # all tests here for sharing
diff --git a/cpan/Math-BigRat/t/bigratup.t b/cpan/Math-BigRat/t/bigratup.t
index 8b17a31835..e963da3afc 100644
--- a/cpan/Math-BigRat/t/bigratup.t
+++ b/cpan/Math-BigRat/t/bigratup.t
@@ -2,16 +2,8 @@
# Test whether $Math::BigInt::upgrade breaks our neck
-use Test::More;
use strict;
-
-BEGIN
- {
- $| = 1;
- chdir 't' if -d 't';
- unshift @INC, '../lib';
- plan tests => 5;
- }
+use Test::More tests => 5;
use Math::BigInt upgrade => 'Math::BigRat';
use Math::BigRat;
diff --git a/cpan/Math-BigRat/t/bigroot.t b/cpan/Math-BigRat/t/bigroot.t
index 5b147e18c5..26bcacc5cb 100644
--- a/cpan/Math-BigRat/t/bigroot.t
+++ b/cpan/Math-BigRat/t/bigroot.t
@@ -8,34 +8,8 @@
# But it is better to test the numerical functionality, instead of not testing
# it at all.
-use Test::More;
use strict;
-
-BEGIN
- {
- $| = 1;
- # to locate the testing files
- my $location = $0; $location =~ s/bigroot.t//i;
- if ($ENV{PERL_CORE})
- {
- # testing with the core distribution
- @INC = qw(../lib);
- }
- unshift @INC, '../lib';
- if (-d 't')
- {
- chdir 't';
- require File::Spec;
- unshift @INC, File::Spec->catdir(File::Spec->updir, $location);
- }
- else
- {
- unshift @INC, $location;
- }
- print "# INC = @INC\n";
-
- plan tests => 8 * 2;
- }
+use Test::More tests => 8 * 2;
use Math::BigFloat;
use Math::BigInt;
diff --git a/cpan/Math-BigRat/t/hang.t b/cpan/Math-BigRat/t/hang.t
index 5cb2b78ced..cf4d65c678 100644
--- a/cpan/Math-BigRat/t/hang.t
+++ b/cpan/Math-BigRat/t/hang.t
@@ -3,15 +3,7 @@
# test for bug #34584: hang in exp(1/2)
use strict;
-use Test::More;
-
-BEGIN
- {
- $| = 1;
- chdir 't' if -d 't';
- unshift @INC, '../lib'; # for running manually
- plan tests => 1;
- }
+use Test::More tests => 1;
use Math::BigRat;
diff --git a/cpan/Math-BigRat/t/requirer.t b/cpan/Math-BigRat/t/requirer.t
index 8be2fa831a..488ed1ecba 100644
--- a/cpan/Math-BigRat/t/requirer.t
+++ b/cpan/Math-BigRat/t/requirer.t
@@ -3,33 +3,7 @@
# check that simple requiring BigRat works
use strict;
-use Test::More;
-
-BEGIN
- {
- $| = 1;
- # to locate the testing files
- my $location = $0; $location =~ s/requirer.t//i;
- if ($ENV{PERL_CORE})
- {
- # testing with the core distribution
- @INC = qw(../t/lib);
- }
- unshift @INC, qw(../lib); # to locate the modules
- if (-d 't')
- {
- chdir 't';
- require File::Spec;
- unshift @INC, File::Spec->catdir(File::Spec->updir, $location);
- }
- else
- {
- unshift @INC, $location;
- }
- print "# INC = @INC\n";
-
- plan tests => 1;
- }
+use Test::More tests => 1;
my ($x);
diff --git a/cpan/Math-BigRat/t/trap.t b/cpan/Math-BigRat/t/trap.t
index ccd9ae8143..cd3f442f2d 100644
--- a/cpan/Math-BigRat/t/trap.t
+++ b/cpan/Math-BigRat/t/trap.t
@@ -3,15 +3,7 @@
# test that config ( trap_nan => 1, trap_inf => 1) really works/dies
use strict;
-use Test;
-
-BEGIN
- {
- $| = 1;
- chdir 't' if -d 't';
- unshift @INC, '../lib'; # for running manually
- plan tests => 29;
- }
+use Test::More tests => 29;
use Math::BigRat;
@@ -21,45 +13,45 @@ my ($cfg,$x);
foreach my $class ($mbi)
{
# can do and defaults are okay?
- ok ($class->can('config'));
- ok ($class->config()->{trap_nan}, 0);
- ok ($class->config()->{trap_inf}, 0);
+ can_ok ($class, 'config');
+ is ($class->config()->{trap_nan}, 0);
+ is ($class->config()->{trap_inf}, 0);
# can set?
- $cfg = $class->config( trap_nan => 1 ); ok ($cfg->{trap_nan},1);
+ $cfg = $class->config( trap_nan => 1 ); is ($cfg->{trap_nan},1);
# can set via hash ref?
- $cfg = $class->config( { trap_nan => 1 } ); ok ($cfg->{trap_nan},1);
+ $cfg = $class->config( { trap_nan => 1 } ); is ($cfg->{trap_nan},1);
# also test that new() still works normally
eval ("\$x = \$class->new('42'); \$x->bnan();");
- ok ($@ =~/^Tried to set/, 1);
- ok ($x,42); # after new() never modified
+ like ($@, qr/^Tried to set/);
+ is ($x,42); # after new() never modified
# can reset?
- $cfg = $class->config( trap_nan => 0 ); ok ($cfg->{trap_nan},0);
+ $cfg = $class->config( trap_nan => 0 ); is ($cfg->{trap_nan},0);
# can set?
- $cfg = $class->config( trap_inf => 1 ); ok ($cfg->{trap_inf},1);
+ $cfg = $class->config( trap_inf => 1 ); is ($cfg->{trap_inf},1);
eval ("\$x = \$class->new('4711'); \$x->binf();");
- ok ($@ =~/^Tried to set/, 1);
- ok ($x,4711); # after new() never modified
+ like ($@, qr/^Tried to set/);
+ is ($x,4711); # after new() never modified
# +$x/0 => +inf
eval ("\$x = \$class->new('4711'); \$x->bdiv(0);");
- ok ($@ =~/^Tried to set/, 1);
- ok ($x,4711); # after new() never modified
+ like ($@, qr/^Tried to set/);
+ is ($x,4711); # after new() never modified
# -$x/0 => -inf
eval ("\$x = \$class->new('-0815'); \$x->bdiv(0);");
- ok ($@ =~/^Tried to set/, 1);
- ok ($x,-815); # after new() never modified
+ like ($@, qr/^Tried to set/);
+ is ($x,-815); # after new() never modified
$cfg = $class->config( trap_nan => 1 );
# 0/0 => NaN
eval ("\$x = \$class->new('0'); \$x->bdiv(0);");
- ok ($@ =~/^Tried to set/, 1);
- ok ($x,0); # after new() never modified
+ like ($@, qr/^Tried to set/);
+ is ($x,0); # after new() never modified
}
##############################################################################
@@ -72,14 +64,11 @@ for my $trap (qw/0.1a +inf inf -inf/)
my $x = Math::BigRat->new('7/4');
eval ("\$x = \$mbi->new('$trap');");
- print "# Got: $x\n" unless
- ok ($x,'7/4'); # never modified since it dies
+ is ($x,'7/4'); # never modified since it dies
eval ("\$x = \$mbi->new('$trap');");
- print "# Got: $x\n" unless
- ok ($x,'7/4'); # never modified since it dies
+ is ($x,'7/4'); # never modified since it dies
eval ("\$x = \$mbi->new('$trap/7');");
- print "# Got: $x\n" unless
- ok ($x,'7/4'); # never modified since it dies
+ is ($x,'7/4'); # never modified since it dies
}
# all tests done