diff options
| author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-11-07 14:14:27 (GMT) |
|---|---|---|
| committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-11-07 14:14:27 (GMT) |
| commit | be3da38e0a84a271c1111f756a1826b786c221ad (patch) | |
| tree | 676f1e7ee7fdf8ff096ffdad7f20d0dba18e6c4c /Lib/test/test_math.py | |
| parent | 7089a4e127ca88f8eafe904a307e002b48d0ad8d (diff) | |
| download | cpython-be3da38e0a84a271c1111f756a1826b786c221ad.zip cpython-be3da38e0a84a271c1111f756a1826b786c221ad.tar.gz cpython-be3da38e0a84a271c1111f756a1826b786c221ad.tar.bz2 | |
Issue #10337: skip tests of tanh() sign in test_math and test_cmath if tanh()
doesn't preserve the zero sign (if TANH_PRESERVES_ZERO_SIGN define is 0).
Diffstat (limited to 'Lib/test/test_math.py')
| -rw-r--r-- | Lib/test/test_math.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py index 1499ff9..b7a516c 100644 --- a/Lib/test/test_math.py +++ b/Lib/test/test_math.py @@ -8,6 +8,7 @@ import os import sys import random import struct +import sysconfig eps = 1E-05 NAN = float('nan') @@ -891,11 +892,15 @@ class MathTests(unittest.TestCase): self.ftest('tanh(inf)', math.tanh(INF), 1) self.ftest('tanh(-inf)', math.tanh(NINF), -1) self.assertTrue(math.isnan(math.tanh(NAN))) + + @requires_IEEE_754 + @unittest.skipIf(sysconfig.get_config_var('TANH_PRESERVES_ZERO_SIGN') == 0, + "system tanh() function doesn't copy the sign") + def testTanhSign(self): # check that tanh(-0.) == -0. on IEEE 754 systems - if float.__getformat__("double").startswith("IEEE"): - self.assertEqual(math.tanh(-0.), -0.) - self.assertEqual(math.copysign(1., math.tanh(-0.)), - math.copysign(1., -0.)) + self.assertEqual(math.tanh(-0.), -0.) + self.assertEqual(math.copysign(1., math.tanh(-0.)), + math.copysign(1., -0.)) def test_trunc(self): self.assertEqual(math.trunc(1), 1) @@ -1008,8 +1013,7 @@ class MathTests(unittest.TestCase): self.fail(message) self.ftest("%s:%s(%r)" % (id, fn, ar), result, er) - @unittest.skipUnless(float.__getformat__("double").startswith("IEEE"), - "test requires IEEE 754 doubles") + @requires_IEEE_754 def test_mtestfile(self): ALLOWED_ERROR = 20 # permitted error, in ulps fail_fmt = "{}:{}({!r}): expected {!r}, got {!r}" |
