diff options
| author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-11-07 14:14:27 +0000 |
|---|---|---|
| committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-11-07 14:14:27 +0000 |
| commit | be3da38e0a84a271c1111f756a1826b786c221ad (patch) | |
| tree | 676f1e7ee7fdf8ff096ffdad7f20d0dba18e6c4c /Lib/test/test_cmath.py | |
| parent | 7089a4e127ca88f8eafe904a307e002b48d0ad8d (diff) | |
| download | cpython-git-be3da38e0a84a271c1111f756a1826b786c221ad.tar.gz | |
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_cmath.py')
| -rw-r--r-- | Lib/test/test_cmath.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/Lib/test/test_cmath.py b/Lib/test/test_cmath.py index a8033635ec..e3cf03e1ad 100644 --- a/Lib/test/test_cmath.py +++ b/Lib/test/test_cmath.py @@ -1,8 +1,9 @@ from test.support import run_unittest -from test.test_math import parse_testfile, test_file +from test.test_math import parse_testfile, test_file, requires_IEEE_754 import unittest import cmath, math from cmath import phase, polar, rect, pi +import sysconfig INF = float('inf') NAN = float('nan') @@ -61,6 +62,12 @@ class CMathTests(unittest.TestCase): def tearDown(self): self.test_values.close() + def assertComplexIdentical(self, a, b): + """Fail if two complex numbers value or sign is different.""" + self.assertEqual(a, b) + self.assertEqual(math.copysign(1., a.real), math.copysign(1., b.real)) + self.assertEqual(math.copysign(1., a.imag), math.copysign(1., b.imag)) + def rAssertAlmostEqual(self, a, b, rel_err = 2e-15, abs_err = 5e-323, msg=None): """Fail if the two floating-point numbers are not almost equal. @@ -473,6 +480,15 @@ class CMathTests(unittest.TestCase): self.assertTrue(cmath.isinf(complex(NAN, INF))) self.assertTrue(cmath.isinf(complex(INF, 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): + self.assertComplexIdentical(cmath.tanh(complex(0., .0j)), complex(0., .0j)) + self.assertComplexIdentical(cmath.tanh(complex(0., -.0j)), complex(0., -.0j)) + self.assertComplexIdentical(cmath.tanh(complex(-0., .0j)), complex(-0., .0j)) + self.assertComplexIdentical(cmath.tanh(complex(-0., -.0j)), complex(-0., -.0j)) + def test_main(): run_unittest(CMathTests) |
