summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_math.py
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2009-04-24 16:39:07 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2009-04-24 16:39:07 (GMT)
commit5c56708f68699377aea76d8b9d04da5e7b02dbda (patch)
treeb0db5330dd2c8db12b8b329fc08186d5a0833a36 /Lib/test/test_math.py
parentd4d95f8eac4718809cfb68f97c9881586596100a (diff)
downloadcpython-5c56708f68699377aea76d8b9d04da5e7b02dbda.zip
cpython-5c56708f68699377aea76d8b9d04da5e7b02dbda.tar.gz
cpython-5c56708f68699377aea76d8b9d04da5e7b02dbda.tar.bz2
Merged revisions 71837-71838 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r71837 | mark.dickinson | 2009-04-24 17:34:14 +0100 (Fri, 24 Apr 2009) | 4 lines Issue #5593: Use more robust test for double-rounding in test_fsum. While we're at it, use new unittest.skipUnless decorator to implement skipping for that test. ........ r71838 | mark.dickinson | 2009-04-24 17:37:22 +0100 (Fri, 24 Apr 2009) | 2 lines Remove unnecessary double negative ........
Diffstat (limited to 'Lib/test/test_math.py')
-rw-r--r--Lib/test/test_math.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py
index 9e646ac..d74f01f 100644
--- a/Lib/test/test_math.py
+++ b/Lib/test/test_math.py
@@ -13,6 +13,11 @@ NAN = float('nan')
INF = float('inf')
NINF = float('-inf')
+# detect evidence of double-rounding: fsum is not always correctly
+# rounded on machines that suffer from double rounding.
+x, y = 1e16, 2.9999 # use temporary values to defeat peephole optimizer
+HAVE_DOUBLE_ROUNDING = (x + y == 1e16 + 4)
+
# locate file with test values
if __name__ == '__main__':
file = sys.argv[0]
@@ -359,6 +364,10 @@ class MathTests(unittest.TestCase):
self.assertEquals(math.frexp(NINF)[0], NINF)
self.assert_(math.isnan(math.frexp(NAN)[0]))
+ @unittest.skipUnless(float.__getformat__("double").startswith("IEEE"),
+ "test requires IEEE 754 doubles")
+ @unittest.skipIf(HAVE_DOUBLE_ROUNDING,
+ "fsum is not exact on machines with double rounding")
def testFsum(self):
# math.fsum relies on exact rounding for correct operation.
# There's a known problem with IA32 floating-point that causes
@@ -368,14 +377,6 @@ class MathTests(unittest.TestCase):
# problem described in issue #2937, we simply skip the whole
# test.
- if not float.__getformat__("double").startswith("IEEE"):
- return
-
- # on IEEE 754 compliant machines, both of the expressions
- # below should round to 10000000000000002.0.
- if 1e16+2.0 != 1e16+2.9999:
- return
-
# Python version of math.fsum, for comparison. Uses a
# different algorithm based on frexp, ldexp and integer
# arithmetic.