This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Upgraded Math::BigRat, Math::BigInt::FastCalc, Math::BigInt, & bignum
[perl5.git] / cpan / Math-BigRat / t / new-mbr.t
diff --git a/cpan/Math-BigRat/t/new-mbr.t b/cpan/Math-BigRat/t/new-mbr.t
new file mode 100644 (file)
index 0000000..dad9942
--- /dev/null
@@ -0,0 +1,28 @@
+#!perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 4;
+use Math::BigRat;
+
+use Scalar::Util qw< refaddr >;
+
+# CPAN RT #132712.
+
+my $q1 = Math::BigRat -> new("-1/2");
+my ($n, $d) = $q1 -> parts();
+
+my $n_orig = $n -> copy();
+my $d_orig = $d -> copy();
+my $q2 = Math::BigRat -> new($n, $d);
+
+cmp_ok($n, "==", $n_orig,
+       "The value of the numerator hasn't changed");
+cmp_ok($d, "==", $d_orig,
+       "The value of the denominator hasn't changed");
+
+isnt(refaddr($n), refaddr($n_orig),
+     "The addresses of the numerators have changed");
+isnt(refaddr($d), refaddr($d_orig),
+     "The addresses of the denominators have changed");