Author: Ronan Lamy <[email protected]>
Branch: py3.5
Changeset: r91640:f2b370578863
Date: 2017-06-23 18:49 +0100
http://bitbucket.org/pypy/pypy/changeset/f2b370578863/
Log: Use correct implementation for Decimal.compare_total{,_mag}(). Fixes
#2586 and #2587
diff --git a/extra_tests/test_decimal.py b/extra_tests/test_decimal.py
--- a/extra_tests/test_decimal.py
+++ b/extra_tests/test_decimal.py
@@ -1,3 +1,5 @@
+import pytest
+
import pickle
import sys
@@ -8,6 +10,11 @@
# import _decimal as C
# import _pydecimal as P
[email protected]_fixture(params=[C, P], ids=['_decimal', '_pydecimal'])
+def module(request):
+ yield request.param
+
+
def test_C():
sys.modules["decimal"] = C
import decimal
@@ -54,3 +61,10 @@
r = pickle.loads(p)
assert isinstance(r, P.DecimalTuple)
assert r == pdt
+
+def test_compare_total(module):
+ assert module.Decimal('12').compare_total(module.Decimal('12.0')) == 1
+ assert module.Decimal('4367').compare_total(module.Decimal('NaN')) == -1
+
+def test_compare_total_mag(module):
+ assert module.Decimal(1).compare_total_mag(-2) == -1
diff --git a/lib_pypy/_decimal.py b/lib_pypy/_decimal.py
--- a/lib_pypy/_decimal.py
+++ b/lib_pypy/_decimal.py
@@ -719,8 +719,8 @@
compare = _make_binary_operation('compare')
compare_signal = _make_binary_operation('compare_signal')
- compare_total = _make_binary_operation('compare')
- compare_total_mag = _make_binary_operation('compare')
+ compare_total = _make_binary_operation('compare_total')
+ compare_total_mag = _make_binary_operation('compare_total_mag')
logical_and = _make_binary_operation('logical_and')
logical_or = _make_binary_operation('logical_or')
logical_xor = _make_binary_operation('logical_xor')
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit