Skip to content

Commit

Permalink
Version 0.0011
Browse files Browse the repository at this point in the history
- Sync with Math-BigInt.
  • Loading branch information
pjacklam committed Apr 3, 2023
1 parent 631c7c7 commit 6fd6fa2
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 17 deletions.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
0.0011 2023-04-03

* Sync test files with Math-BigInt.

0.0010 2022-05-21

* Add a check to Makefile.PL to verify that GMP 5.1.0 or higher is available.
Expand Down
2 changes: 1 addition & 1 deletion Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ WriteMakefile
# A hash of modules that are needed to run the module.

'PREREQ_PM' => {
'Math::BigInt' => 1.999831,
'Math::BigInt' => 1.999838,
'Math::GMPz' => 0.36,
},

Expand Down
9 changes: 5 additions & 4 deletions t/01load.t
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- mode: perl; -*-

use strict; # restrict unsafe constructs
use warnings; # enable optional warnings
use strict;
use warnings;

use Test::More tests => 2;

Expand All @@ -10,11 +10,12 @@ BEGIN {
use_ok('Math::BigInt'); # Math::BigInt is required for the tests
};

my @mods = ('Math::BigInt',
my @mods = (
'Math::BigInt',
'Math::BigInt::Lib',
'Math::BigInt::GMPz',
'Math::GMPz',
);
);

diag("");
diag("Testing with Perl $], $^X");
Expand Down
71 changes: 59 additions & 12 deletions t/mbimbf.t
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use strict;
use warnings;

use Test::More tests => 712 # tests in require'd file
+ 26; # tests in this file
+ 52; # tests in this file

use Math::BigInt only => 'GMPz';
use Math::BigFloat;
Expand Down Expand Up @@ -58,24 +58,71 @@ foreach my $class (qw/Math::BigInt Math::BigFloat/) {
}

foreach my $class (qw/Math::BigInt Math::BigFloat/) {
$class->accuracy(42);
my $x;

# $x gets A of 42, too!
my $x = $class->new(123);
# Accuracy

# really?
is($x->accuracy(), 42, '$x has A of 42');
# set and check the class accuracy
$class->accuracy(1);
is($class->accuracy(), 1, "$class has A of 1");

# $x has no A, but the global is still in effect for $x so the return value
# of that operation should be 42, not undef
is($x->accuracy(undef), 42, '$x has A from global');
# a new instance gets the class accuracy
$x = $class->new(123);
is($x->accuracy(), 1, '$x has A of 1');

# so $x should still have A = 42
is($x->accuracy(), 42, '$x has still A of 42');
# set and check the instance accuracy
$x->accuracy(2);
is($x->accuracy(), 2, '$x has A of 2');

# reset for further tests
# change the class accuracy
$class->accuracy(3);
is($class->accuracy(), 3, "$class has A of 3");

# verify that the instance accuracy hasn't changed
is($x->accuracy(), 2, '$x still has A of 2');

# change the instance accuracy
$x->accuracy(undef);
is($x->accuracy(), undef, '$x now has A of undef');

# check the class accuracy
is($class->accuracy(), 3, "$class still has A of 3");

# change the class accuracy again
$class->accuracy(undef);
is($class->accuracy(), undef, "$class now has A of undef");

# Precision

# set and check the class precision
$class->precision(1);
is($class->precision(), 1, "$class has A of 1");

# a new instance gets the class precision
$x = $class->new(123);
is($x->precision(), 1, '$x has A of 1');

# set and check the instance precision
$x->precision(2);
is($x->precision(), 2, '$x has A of 2');

# change the class precision
$class->precision(3);
is($class->precision(), 3, "$class has A of 3");

# verify that the instance precision hasn't changed
is($x->precision(), 2, '$x still has A of 2');

# change the instance precision
$x->precision(undef);
is($x->precision(), undef, '$x now has A of undef');

# check the class precision
is($class->precision(), 3, "$class still has A of 3");

# change the class precision again
$class->precision(undef);
is($class->precision(), undef, "$class now has A of undef");
}

# bug with blog(Math::BigFloat, Math::BigInt)
Expand Down

0 comments on commit 6fd6fa2

Please sign in to comment.