aboutsummaryrefslogtreecommitdiffstats
path: root/testing/php7-pecl-decimal
diff options
context:
space:
mode:
authorAndy Postnikov <apostnikov@gmail.com>2020-02-25 00:08:09 +0200
committerAndy Postnikov <apostnikov@gmail.com>2020-02-25 00:50:59 +0200
commite424355aaf74dda28656083345e3c7288f7fc713 (patch)
tree3e6d7c563b8242cf263292a95aa9ccca5f869fdb /testing/php7-pecl-decimal
parent7104bdddaeab24d5b27377126b82581b443b7d2a (diff)
downloadaports-e424355aaf74dda28656083345e3c7288f7fc713.tar.bz2
aports-e424355aaf74dda28656083345e3c7288f7fc713.tar.xz
testing/php7-pecl-decimal: upgrade to 2.0.0
Diffstat (limited to 'testing/php7-pecl-decimal')
-rw-r--r--testing/php7-pecl-decimal/APKBUILD12
-rw-r--r--testing/php7-pecl-decimal/fix-build.patch61
-rw-r--r--testing/php7-pecl-decimal/fix-test.patch49
-rw-r--r--testing/php7-pecl-decimal/fix-tests.patch138
4 files changed, 257 insertions, 3 deletions
diff --git a/testing/php7-pecl-decimal/APKBUILD b/testing/php7-pecl-decimal/APKBUILD
index 440bdc2be1..95ca57b219 100644
--- a/testing/php7-pecl-decimal/APKBUILD
+++ b/testing/php7-pecl-decimal/APKBUILD
@@ -1,7 +1,7 @@
# Maintainer: Andy Postnikov <apostnikov@gmail.com>
pkgname=php7-pecl-decimal
_pkgreal=decimal
-pkgver=1.3.1
+pkgver=2.0.0
pkgrel=0
pkgdesc="Correctly-rounded arbitrary precision decimal floating-point arithmetic in PHP."
url="https://pecl.php.net/package/decimal"
@@ -9,7 +9,10 @@ arch="all"
license="MIT"
depends="php7-json"
makedepends="php7-dev re2c mpdecimal"
-source="https://pecl.php.net/get/$_pkgreal-$pkgver.tgz"
+source="https://pecl.php.net/get/$_pkgreal-$pkgver.tgz
+ fix-build.patch
+ fix-test.patch
+ fix-tests.patch"
builddir="$srcdir/$_pkgreal-$pkgver"
provides="php7-decimal=$pkgver-r$pkgrel" # for backward compatibility
replaces="php7-decimal" # for backward compatibility
@@ -32,4 +35,7 @@ package() {
echo "extension=$_pkgreal.so" > "$pkgdir"/etc/php7/conf.d/$_pkgreal.ini
}
-sha512sums="8e3fa73c875d6b4df09c1a23569abd1487226112e9e91f2e1e02ad8118fc06e5002e4e6f2e16e1ca18b5913faa43e2ac5585f86ef489395e68e573a14de4e45a decimal-1.3.1.tgz"
+sha512sums="765a2871af38338d1020730936d70c7d493e07c4d0fe6da5b07bf1b5f6bd7ae45239351f9202ced8f579ad1e1c909fbfede1350cc1ec85e0f4cb5f1ef8617cfe decimal-2.0.0.tgz
+8db95e40c19806d2fbb88e8132a3f679f5856ce73548d0b72bb1c806fdb59bfadad0260dd89962f4ac4c41b388d98e8ec988b5bd989e582c9cffc521e832b6d7 fix-build.patch
+36d24c2c2fd310d64f6c326ac5241c4732d323608d6dfc7e76d906cd30282e94bdbc5851f1de3e4e2056f005761af52c22afc7a7b672dc4a718f46a74bb75714 fix-test.patch
+f972d727fba7bbdf827c2b5ba0cf7588b7e9234f3e5989f06dc92c1a8c34516fdca3e1089e98e3a8c092328a04f524d7d6a0a017869188e219f4bcc1e869a261 fix-tests.patch"
diff --git a/testing/php7-pecl-decimal/fix-build.patch b/testing/php7-pecl-decimal/fix-build.patch
new file mode 100644
index 0000000000..dc6b75ec02
--- /dev/null
+++ b/testing/php7-pecl-decimal/fix-build.patch
@@ -0,0 +1,61 @@
+From d983b8f76f59996339a434c40d1f57703fadbd42 Mon Sep 17 00:00:00 2001
+From: Remi Collet <remi@remirepo.net>
+Date: Tue, 4 Feb 2020 08:25:35 +0100
+Subject: [PATCH] fix #33 remomve unused function
+
+---
+ src/convert.c | 15 +--------------
+ src/convert.h | 2 --
+ 2 files changed, 1 insertion(+), 16 deletions(-)
+
+diff --git a/src/convert.c b/src/convert.c
+index 4136a35..77581e3 100644
+--- a/src/convert.c
++++ b/src/convert.c
+@@ -444,19 +444,6 @@ zend_string *php_decimal_rational_to_sci(const php_rational_t *obj, zend_long pr
+ return str;
+ }
+
+-zend_string *php_decimal_rational_to_eng(const php_rational_t *obj, zend_long prec)
+-{
+- zend_string *str;
+-
+- PHP_DECIMAL_TEMP_MPD(tmp);
+- php_decimal_rational_evaluate(&tmp, obj, prec);
+-
+- str = php_decimal_mpd_to_eng(&tmp);
+- mpd_del(&tmp);
+-
+- return str;
+-}
+-
+ zend_string *php_decimal_rational_to_fixed(const php_rational_t *obj, zend_long places, zend_bool commas, php_decimal_rounding_t mode)
+ {
+ PHP_DECIMAL_TEMP_MPD(tmp);
+@@ -597,4 +584,4 @@ void php_decimal_number_to_num_den(mpd_t *num, mpd_t *den, const zval *obj)
+
+ assert(status == 0);
+ zval_ptr_dtor(&result);
+-}
+\ No newline at end of file
++}
+diff --git a/src/convert.h b/src/convert.h
+index cb5e031..a3924e3 100644
+--- a/src/convert.h
++++ b/src/convert.h
+@@ -56,7 +56,6 @@ php_decimal_success_t php_decimal_mpd_set_string(mpd_t *mpd, const zend_string *
+ php_decimal_success_t php_decimal_mpd_set_charptr(mpd_t *mpd, const char *str);
+
+ zend_string *php_decimal_mpd_to_serialized(const mpd_t *mpd);
+-zend_string *php_decimal_mpd_to_eng(const mpd_t *mpd);
+ zend_string *php_decimal_mpd_to_sci(const mpd_t *mpd);
+ zend_string *php_decimal_mpd_to_string(const mpd_t *mpd);
+ zend_string *php_decimal_mpd_to_fixed(const mpd_t *mpd, zend_long places, zend_bool commas, php_decimal_rounding_t mode);
+@@ -69,7 +68,6 @@ void php_decimal_rational_set_nan(php_rational_t *obj);
+ void php_decimal_rational_set_zero(php_rational_t *obj);
+
+ zend_string *php_decimal_rational_to_sci(const php_rational_t *obj, zend_long prec);
+-zend_string *php_decimal_rational_to_eng(const php_rational_t *obj, zend_long prec);
+ zend_string *php_decimal_rational_to_string(const php_rational_t *obj);
+ zend_string *php_decimal_rational_to_fixed(const php_rational_t *obj, zend_long places, zend_bool commas, php_decimal_rounding_t mode);
+ zend_long php_decimal_rational_to_long(const php_rational_t *obj);
diff --git a/testing/php7-pecl-decimal/fix-test.patch b/testing/php7-pecl-decimal/fix-test.patch
new file mode 100644
index 0000000000..8ed7831e51
--- /dev/null
+++ b/testing/php7-pecl-decimal/fix-test.patch
@@ -0,0 +1,49 @@
+From e71f1488b666e30e4f0121a10fee3eeab22bd327 Mon Sep 17 00:00:00 2001
+From: Remi Collet <remi@remirepo.net>
+Date: Tue, 4 Feb 2020 08:23:05 +0100
+Subject: [PATCH] fix harcoded path in test
+
+---
+ tests/Number/methods/pow.phpt | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/tests/Number/methods/pow.phpt b/tests/Number/methods/pow.phpt
+index 5ce6582..2c78f16 100644
+--- a/tests/Number/methods/pow.phpt
++++ b/tests/Number/methods/pow.phpt
+@@ -87,7 +87,7 @@ Number Object
+ )
+ Number::pow
+
+-Warning: Decimal arithmetic operand truncated to integer in /Users/rtheunissen/dev/decimal/ext-decimal/tests/Number/helpers/Number.php on line 63
++Warning: Decimal arithmetic operand truncated to integer in %sNumber.php on line 63
+ Number Object
+ (
+ [value:protected] => Decimal\Rational Object
+@@ -99,7 +99,7 @@ Number Object
+ )
+ Number::pow
+
+-Warning: Decimal arithmetic operand truncated to integer in /Users/rtheunissen/dev/decimal/ext-decimal/tests/Number/helpers/Number.php on line 63
++Warning: Decimal arithmetic operand truncated to integer in %sNumber.php on line 63
+ Number Object
+ (
+ [value:protected] => Decimal\Rational Object
+@@ -123,7 +123,7 @@ Decimal\Decimal Object
+ )
+ Number::toRational
+
+-Warning: Decimal arithmetic operand truncated to integer in /Users/rtheunissen/dev/decimal/ext-decimal/tests/Number/methods/pow.php on line 38
++Warning: Decimal arithmetic operand truncated to integer in %spow.php on line 38
+ Decimal\Rational Object
+ (
+ [num] => 16
+@@ -131,7 +131,7 @@ Decimal\Rational Object
+ )
+ Number::toRational
+
+-Warning: Decimal arithmetic operand truncated to integer in /Users/rtheunissen/dev/decimal/ext-decimal/tests/Number/methods/pow.php on line 41
++Warning: Decimal arithmetic operand truncated to integer in %spow.php on line 41
+ Decimal\Rational Object
+ (
+ [num] => 16
diff --git a/testing/php7-pecl-decimal/fix-tests.patch b/testing/php7-pecl-decimal/fix-tests.patch
new file mode 100644
index 0000000000..efbf27bba7
--- /dev/null
+++ b/testing/php7-pecl-decimal/fix-tests.patch
@@ -0,0 +1,138 @@
+diff --git a/tests/Number/helpers/Number.php b/tests/Number/helpers/Number.php
+new file mode 100644
+index 0000000..07ca222
+--- /dev/null
++++ b/tests/Number/helpers/Number.php
+@@ -0,0 +1,132 @@
++<?php
++
++/**
++ *
++ */
++class Number extends \Decimal\Number
++{
++ protected $value;
++
++ private static function parse($number)
++ {
++ $value = $number instanceof self ? $number->value : $number;
++
++ if ($value === "INF") $value = INF;
++ else if ($value === "-INF") $value = -INF;
++ else if ($value === "NAN") $value = NAN;
++
++ return $value;
++ }
++
++ protected function __construct($value)
++ {
++ $this->value = self::parse($value);
++ }
++
++ public static function valueOf($value): \Decimal\Number
++ {
++ return new static($value);
++ }
++
++ public function add($other): \Decimal\Number
++ {
++ printf("%s\n", __METHOD__);
++
++ return new static($this->value + $this->parse($other));
++ }
++
++ public function sub($other): \Decimal\Number
++ {
++ printf("%s\n", __METHOD__);
++
++ return new static($this->value - $this->parse($other));
++ }
++
++ public function mul($other): \Decimal\Number
++ {
++ printf("%s\n", __METHOD__);
++
++ return new static($this->value * $this->parse($other));
++ }
++
++ public function div($other): \Decimal\Number
++ {
++ printf("%s\n", __METHOD__);
++
++ return new static($this->value / $this->parse($other));
++ }
++
++ public function pow($other): \Decimal\Number
++ {
++ printf("%s\n", __METHOD__);
++
++ return new static($this->value ** $this->parse($other));
++ }
++
++ public function mod($other): \Decimal\Number
++ {
++ printf("%s\n", __METHOD__);
++
++ return new static($this->value % $this->parse($other));
++ }
++
++ public function shiftl($places): \Decimal\Number
++ {
++ printf("%s\n", __METHOD__);
++
++ return new static($this->value * (10 ** $places));
++ }
++
++ public function shiftr($places): \Decimal\Number
++ {
++ printf("%s\n", __METHOD__);
++
++ return new static($this->value / (10 ** $places));
++ }
++
++ public function round(int $places = NULL, int $mode = NULL): \Decimal\Number
++ {
++ return new static($this->toDecimal(\Decimal\Decimal::MAX_PRECISION)->round($places, $mode)->toString());
++ }
++
++ public function toFixed(int $places = NULL, bool $commas = NULL, int $mode = NULL): string
++ {
++ return new static($this->toDecimal(\Decimal\Decimal::MAX_PRECISION)->toFixed($places, $commas, $mode));
++ }
++
++ public function toDecimal(int $precision): \Decimal\Decimal
++ {
++ printf("%s\n", __METHOD__);
++
++ return parent::toDecimal($precision);
++ }
++
++ public function toRational(): \Decimal\Rational
++ {
++ printf("%s\n", __METHOD__);
++
++ return parent::toRational();
++ }
++
++ public function toString(): string
++ {
++ return (string) $this->value;
++ }
++
++ public function toInt(): int
++ {
++ return (int) $this->value;
++ }
++
++ public function toFloat(): float
++ {
++ return (float) $this->value;
++ }
++
++ public function compareTo($other): int
++ {
++ printf("%s\n", __METHOD__);
++
++ return $this->value <=> self::parse($other);
++ }
++}