|
|
05b63a3 |
From bc6b3c66ce09ecd2e787702954029f18a44aa776 Mon Sep 17 00:00:00 2001
|
|
|
05b63a3 |
From: Karel Miko <karel.miko@gmail.com>
|
|
|
05b63a3 |
Date: Sat, 19 Oct 2019 19:28:41 +0200
|
|
|
05b63a3 |
Subject: [PATCH] fix #56 Math::BigInt 1.999817 breaks the tests of CryptX
|
|
|
05b63a3 |
MIME-Version: 1.0
|
|
|
05b63a3 |
Content-Type: text/plain; charset=UTF-8
|
|
|
05b63a3 |
Content-Transfer-Encoding: 8bit
|
|
|
05b63a3 |
|
|
|
05b63a3 |
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
|
|
05b63a3 |
---
|
|
|
05b63a3 |
t/mbi_ltm/bigintpm.inc | 8 +++----
|
|
|
05b63a3 |
t/mbi_ltm_bigintpm.t | 2 +-
|
|
|
05b63a3 |
t/mbi_ltm_bugs.t | 54 +++++++++++-------------------------------
|
|
|
05b63a3 |
3 files changed, 19 insertions(+), 45 deletions(-)
|
|
|
05b63a3 |
|
|
|
05b63a3 |
diff --git a/t/mbi_ltm/bigintpm.inc b/t/mbi_ltm/bigintpm.inc
|
|
|
05b63a3 |
index 35efeca4..2792cca7 100644
|
|
|
05b63a3 |
--- a/t/mbi_ltm/bigintpm.inc
|
|
|
05b63a3 |
+++ b/t/mbi_ltm/bigintpm.inc
|
|
|
05b63a3 |
@@ -2643,10 +2643,10 @@ abc:12:NaN
|
|
|
05b63a3 |
-2:3:-8
|
|
|
05b63a3 |
-2:4:16
|
|
|
05b63a3 |
-2:5:-32
|
|
|
05b63a3 |
-2:-1:NaN
|
|
|
05b63a3 |
--2:-1:NaN
|
|
|
05b63a3 |
-2:-2:NaN
|
|
|
05b63a3 |
--2:-2:NaN
|
|
|
05b63a3 |
+2:-1:0
|
|
|
05b63a3 |
+-2:-1:0
|
|
|
05b63a3 |
+2:-2:0
|
|
|
05b63a3 |
+-2:-2:0
|
|
|
05b63a3 |
# inf tests
|
|
|
05b63a3 |
+inf:1234500012:inf
|
|
|
05b63a3 |
-inf:1234500012:inf
|
|
|
05b63a3 |
diff --git a/t/mbi_ltm_bigintpm.t b/t/mbi_ltm_bigintpm.t
|
|
|
05b63a3 |
index 976e7b1e..b90213f7 100644
|
|
|
05b63a3 |
--- a/t/mbi_ltm_bigintpm.t
|
|
|
05b63a3 |
+++ b/t/mbi_ltm_bigintpm.t
|
|
|
05b63a3 |
@@ -6,7 +6,7 @@ use warnings;
|
|
|
05b63a3 |
use Test::More;
|
|
|
05b63a3 |
|
|
|
05b63a3 |
BEGIN {
|
|
|
05b63a3 |
- plan skip_all => "requires Math::BigInt 1.999712+" unless eval { require Math::BigInt && eval($Math::BigInt::VERSION) >= 1.999712 };
|
|
|
05b63a3 |
+ plan skip_all => "requires Math::BigInt 1.999817+" unless eval { require Math::BigInt && eval($Math::BigInt::VERSION) >= 1.999817 };
|
|
|
05b63a3 |
plan tests => 3712 # tests in require'd file
|
|
|
05b63a3 |
+ 6; # tests in this file
|
|
|
05b63a3 |
}
|
|
|
05b63a3 |
diff --git a/t/mbi_ltm_bugs.t b/t/mbi_ltm_bugs.t
|
|
|
05b63a3 |
index 976e7b1e..3c535285 100644
|
|
|
05b63a3 |
--- a/t/mbi_ltm_bugs.t
|
|
|
05b63a3 |
+++ b/t/mbi_ltm_bugs.t
|
|
|
05b63a3 |
@@ -6,47 +6,21 @@ use warnings;
|
|
|
05b63a3 |
use Test::More;
|
|
|
05b63a3 |
|
|
|
05b63a3 |
BEGIN {
|
|
|
05b63a3 |
- plan skip_all => "requires Math::BigInt 1.999712+" unless eval { require Math::BigInt && eval($Math::BigInt::VERSION) >= 1.999712 };
|
|
|
05b63a3 |
- plan tests => 3712 # tests in require'd file
|
|
|
05b63a3 |
- + 6; # tests in this file
|
|
|
05b63a3 |
+ plan skip_all => "requires Math::BigInt" unless eval { require Math::BigInt };
|
|
|
05b63a3 |
+ plan tests => 2;
|
|
|
05b63a3 |
}
|
|
|
05b63a3 |
|
|
|
05b63a3 |
use Math::BigInt lib => 'LTM';
|
|
|
05b63a3 |
|
|
|
05b63a3 |
-our ($CLASS, $CALC);
|
|
|
05b63a3 |
-$CLASS = "Math::BigInt";
|
|
|
05b63a3 |
-$CALC = "Math::BigInt::LTM";
|
|
|
05b63a3 |
-
|
|
|
05b63a3 |
-my $x;
|
|
|
05b63a3 |
-
|
|
|
05b63a3 |
-#############################################################################
|
|
|
05b63a3 |
-# from_hex(), from_bin() and from_oct() tests
|
|
|
05b63a3 |
-
|
|
|
05b63a3 |
-$x = Math::BigInt->from_hex('0xcafe');
|
|
|
05b63a3 |
-is($x, "51966",
|
|
|
05b63a3 |
- qq|Math::BigInt->from_hex("0xcafe")|);
|
|
|
05b63a3 |
-
|
|
|
05b63a3 |
-$x = Math::BigInt->from_hex('0xcafebabedead');
|
|
|
05b63a3 |
-is($x, "223195403574957",
|
|
|
05b63a3 |
- qq|Math::BigInt->from_hex("0xcafebabedead")|);
|
|
|
05b63a3 |
-
|
|
|
05b63a3 |
-$x = Math::BigInt->from_bin('0b1001');
|
|
|
05b63a3 |
-is($x, "9",
|
|
|
05b63a3 |
- qq|Math::BigInt->from_bin("0b1001")|);
|
|
|
05b63a3 |
-
|
|
|
05b63a3 |
-$x = Math::BigInt->from_bin('0b1001100110011001100110011001');
|
|
|
05b63a3 |
-is($x, "161061273",
|
|
|
05b63a3 |
- qq|Math::BigInt->from_bin("0b1001100110011001100110011001");|);
|
|
|
05b63a3 |
-
|
|
|
05b63a3 |
-$x = Math::BigInt->from_oct('0775');
|
|
|
05b63a3 |
-is($x, "509",
|
|
|
05b63a3 |
- qq|Math::BigInt->from_oct("0775");|);
|
|
|
05b63a3 |
-
|
|
|
05b63a3 |
-$x = Math::BigInt->from_oct('07777777777777711111111222222222');
|
|
|
05b63a3 |
-is($x, "9903520314281112085086151826",
|
|
|
05b63a3 |
- qq|Math::BigInt->from_oct("07777777777777711111111222222222");|);
|
|
|
05b63a3 |
-
|
|
|
05b63a3 |
-#############################################################################
|
|
|
05b63a3 |
-# all the other tests
|
|
|
05b63a3 |
-
|
|
|
05b63a3 |
-require './t/mbi_ltm/bigintpm.inc'; # all tests here for sharing
|
|
|
05b63a3 |
+my $V = $Math::BigInt::VERSION;
|
|
|
05b63a3 |
+
|
|
|
05b63a3 |
+# https://github.com/DCIT/perl-CryptX/issues/56
|
|
|
05b63a3 |
+{
|
|
|
05b63a3 |
+ my ($x, $y);
|
|
|
05b63a3 |
+ $x = Math::BigInt->new("2");
|
|
|
05b63a3 |
+ $y = Math::BigInt->new("-1");
|
|
|
05b63a3 |
+ is($x ** $y, $V < 1.999817 ? 'NaN' : 0);
|
|
|
05b63a3 |
+ $x = Math::BigInt->new("-2");
|
|
|
05b63a3 |
+ $y = Math::BigInt->new("-2");
|
|
|
05b63a3 |
+ is($x ** $y, $V < 1.999817 ? 'NaN' : 0);
|
|
|
05b63a3 |
+}
|
|
|
05b63a3 |
--
|
|
|
05b63a3 |
2.21.0
|
|
|
05b63a3 |
|