diff options
Diffstat (limited to 'cpan/Math-BigInt/t/sparts-mbi.t')
-rw-r--r-- | cpan/Math-BigInt/t/sparts-mbi.t | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/cpan/Math-BigInt/t/sparts-mbi.t b/cpan/Math-BigInt/t/sparts-mbi.t index 648de7e828..86620b7faf 100644 --- a/cpan/Math-BigInt/t/sparts-mbi.t +++ b/cpan/Math-BigInt/t/sparts-mbi.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 784; +use Test::More tests => 792; use Math::BigInt; @@ -44,6 +44,37 @@ while (<DATA>) { } +# Verify that the accuracy of the significand and the exponent depends on the +# accuracy of the invocand, if set, not the class. + +note(qq|\nVerify that accuracy depends on invocand, not class.\n\n|); + +{ + Math::BigInt -> accuracy(20); + my $x = Math::BigInt -> new("3"); # accuracy is 20 + $x -> accuracy(10); # reduce accuracy to 10 + + my ($mant, $expo) = $x -> sparts(); + cmp_ok($mant, '==', 3, "value of significand"); + cmp_ok($expo, '==', 0, "value of exponent"); + cmp_ok($mant -> accuracy(), '==', 10, "accuracy of significand"); + cmp_ok($expo -> accuracy(), '==', 20, "accuracy of exponent"); +} + +note(qq|\nVerify that precision depends on invocand, not class.\n\n|); + +{ + Math::BigInt -> precision(20); + my $x = Math::BigInt -> new("3"); # precision is 20 + $x -> precision(10); # reduce precision to 10 + + my ($mant, $expo) = $x -> sparts(); + cmp_ok($mant, '==', 3, "value of significand"); + cmp_ok($expo, '==', 0, "value of exponent"); + cmp_ok($mant -> precision(), '==', 10, "precision of significand"); + cmp_ok($expo -> precision(), '==', 20, "precision of exponent"); +} + __DATA__ NaN:NaN:NaN |