summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorMark Dickinson <mdickinson@enthought.com>2019-12-09 14:36:34 (GMT)
committerGitHub <noreply@github.com>2019-12-09 14:36:34 (GMT)
commitbba873e633f0f1e88ea12fb935cbd58faa77f976 (patch)
tree5cb3c02fad1450c50e0842c35e75a36a18c0b30d /Lib/test
parentab513a38c98695f271e448fe2cb7c5e39eeaaaaf (diff)
downloadcpython-bba873e633f0f1e88ea12fb935cbd58faa77f976.zip
cpython-bba873e633f0f1e88ea12fb935cbd58faa77f976.tar.gz
cpython-bba873e633f0f1e88ea12fb935cbd58faa77f976.tar.bz2
bpo-38992: avoid fsum test failure from constant-folding (GH-17513)
* Issue 38992: avoid fsum test failure * Add NEWS entry
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_math.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py
index f832246..5c35c8c 100644
--- a/Lib/test/test_math.py
+++ b/Lib/test/test_math.py
@@ -676,7 +676,6 @@ class MathTests(unittest.TestCase):
float.fromhex('0x1.df11f45f4e61ap+2')),
([(-1.)**n/n for n in range(1, 1001)],
float.fromhex('-0x1.62a2af1bd3624p-1')),
- ([1.7**(i+1)-1.7**i for i in range(1000)] + [-1.7**1000], -1.0),
([1e16, 1., 1e-16], 10000000000000002.0),
([1e16-2., 1.-2.**-53, -(1e16-2.), -(1.-2.**-53)], 0.0),
# exercise code for resizing partials array
@@ -685,6 +684,13 @@ class MathTests(unittest.TestCase):
float.fromhex('0x1.5555555555555p+970')),
]
+ # Telescoping sum, with exact differences (due to Sterbenz)
+ terms = [1.7**i for i in range(1001)]
+ test_values.append((
+ [terms[i+1] - terms[i] for i in range(1000)] + [-terms[1000]],
+ -terms[0]
+ ))
+
for i, (vals, expected) in enumerate(test_values):
try:
actual = math.fsum(vals)