diff options
author | Christian Heimes <christian@cheimes.de> | 2007-11-28 10:04:30 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2007-11-28 10:04:30 (GMT) |
commit | 69a79638adc180e9c29f2171448326262e249761 (patch) | |
tree | dfbd8c3929236831b40e43492aa3abe27d3c2306 /Lib/test | |
parent | 084dc4c2f7b4b51dd9894b12d1239712ceb07548 (diff) | |
download | cpython-69a79638adc180e9c29f2171448326262e249761.zip cpython-69a79638adc180e9c29f2171448326262e249761.tar.gz cpython-69a79638adc180e9c29f2171448326262e249761.tar.bz2 |
Merged revisions 59202-59211 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59203 | guido.van.rossum | 2007-11-27 23:38:36 +0100 (Tue, 27 Nov 2007) | 4 lines
Patch # 1507 by Mark Dickinson. Make complex(x, -0) retain the sign of
the imaginary part (as long as it's not complex).
Backport candidate?
........
r59204 | christian.heimes | 2007-11-28 00:16:44 +0100 (Wed, 28 Nov 2007) | 2 lines
Expose Py_Py3kWarningFlag as sys.py3kwarning as discussed in #1504
Also added a warning.warnpy3k() as convenient method for Python 3.x related deprecation warnings.
........
r59206 | christian.heimes | 2007-11-28 00:53:14 +0100 (Wed, 28 Nov 2007) | 1 line
I forgot to fix one occurence of new in test_descr
........
r59208 | christian.heimes | 2007-11-28 09:02:36 +0100 (Wed, 28 Nov 2007) | 1 line
Added py3kwarning to the documentation of the sys module.
........
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_complex.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_complex.py b/Lib/test/test_complex.py index 5397ad6..1bb31dd 100644 --- a/Lib/test/test_complex.py +++ b/Lib/test/test_complex.py @@ -2,6 +2,7 @@ import unittest, os from test import test_support from random import random +from math import atan2 # These tests ensure that complex math does the right thing @@ -207,6 +208,18 @@ class ComplexTest(unittest.TestCase): self.assertAlmostEqual(complex(real=17+23j, imag=23), 17+46j) self.assertAlmostEqual(complex(real=1+2j, imag=3+4j), -3+5j) + # check that the sign of a zero in the real or imaginary part + # is preserved when constructing from two floats. (These checks + # are harmless on systems without support for signed zeros.) + def split_zeros(x): + """Function that produces different results for 0. and -0.""" + return atan2(x, -1.) + + self.assertEqual(split_zeros(complex(1., 0.).imag), split_zeros(0.)) + self.assertEqual(split_zeros(complex(1., -0.).imag), split_zeros(-0.)) + self.assertEqual(split_zeros(complex(0., 1.).real), split_zeros(0.)) + self.assertEqual(split_zeros(complex(-0., 1.).real), split_zeros(-0.)) + c = 3.14 + 1j self.assert_(complex(c) is c) del c |