summaryrefslogtreecommitdiff
path: root/cpan/Math-BigInt/t/bpi-mbf.t
diff options
context:
space:
mode:
Diffstat (limited to 'cpan/Math-BigInt/t/bpi-mbf.t')
-rw-r--r--cpan/Math-BigInt/t/bpi-mbf.t53
1 files changed, 53 insertions, 0 deletions
diff --git a/cpan/Math-BigInt/t/bpi-mbf.t b/cpan/Math-BigInt/t/bpi-mbf.t
new file mode 100644
index 0000000000..38b9350b2d
--- /dev/null
+++ b/cpan/Math-BigInt/t/bpi-mbf.t
@@ -0,0 +1,53 @@
+# -*- mode: perl; -*-
+
+use strict;
+use warnings;
+
+use Test::More tests => 10;
+
+use Math::BigFloat;
+use Scalar::Util qw< refaddr >;
+
+my $x;
+
+################################################################################
+
+note('class method');
+
+# When no accuracy is specified, default accuracy shall be used.
+
+$x = Math::BigFloat -> bpi();
+is($x, '3.141592653589793238462643383279502884197',
+ '$x = Math::BigFloat -> bpi();');
+is(ref($x), "Math::BigFloat", '$x is a Math::BigFloat');
+
+# When accuracy is specified, it shall be used.
+
+$x = Math::BigFloat -> bpi(10);
+is($x, '3.141592654',
+ '$x = Math::BigFloat -> bpi(10);');
+is(ref($x), "Math::BigFloat", '$x is a Math::BigFloat');
+
+################################################################################
+
+note('instance method');
+
+my $y;
+
+# When no accuracy is specified, default accuracy shall be used.
+
+$x = Math::BigFloat -> new(100);
+$y = $x -> bpi();
+is($x, '3.141592653589793238462643383279502884197',
+ '$x = Math::BigFloat -> new(100); $y = $x -> bpi();');
+is(ref($x), "Math::BigFloat", '$x is a Math::BigFloat');
+is(refaddr($x), refaddr($y), '$x and $y are the same object');
+
+# When accuracy is specified, it shall be used.
+
+$x = Math::BigFloat -> new(100);
+$y = $x -> bpi(10);
+is($x, '3.141592654',
+ '$x = Math::BigFloat -> new(100); $y = $x -> bpi(10);');
+is(ref($x), "Math::BigFloat", '$x is a Math::BigFloat');
+is(refaddr($x), refaddr($y), '$x and $y are the same object');