summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_complex.py
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2010-06-30 11:13:36 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2010-06-30 11:13:36 (GMT)
commit50b79a80bd3fe400fe60ead0ed563080fe0cac88 (patch)
tree3ebf1bd5f060cd3d77e8cfc2d09103605f32b09e /Lib/test/test_complex.py
parentaf0e1544bfce6ea500672d2140c88ad351a73c5e (diff)
downloadcpython-50b79a80bd3fe400fe60ead0ed563080fe0cac88.zip
cpython-50b79a80bd3fe400fe60ead0ed563080fe0cac88.tar.gz
cpython-50b79a80bd3fe400fe60ead0ed563080fe0cac88.tar.bz2
Issue #9011: Tests for Python 3.2's treatment of negated imaginary literals.
Diffstat (limited to 'Lib/test/test_complex.py')
-rw-r--r--Lib/test/test_complex.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_complex.py b/Lib/test/test_complex.py
index f6c7cc3..cecf38f 100644
--- a/Lib/test/test_complex.py
+++ b/Lib/test/test_complex.py
@@ -437,6 +437,23 @@ class ComplexTest(unittest.TestCase):
@unittest.skipUnless(float.__getformat__("double").startswith("IEEE"),
"test requires IEEE 754 doubles")
+ def test_negated_imaginary_literal(self):
+ z0 = -0j
+ z1 = -7j
+ z2 = -1e1000j
+ # Note: In versions of Python < 3.2, a negated imaginary literal
+ # accidentally ended up with real part 0.0 instead of -0.0, thanks to a
+ # modification during CST -> AST translation (see issue #9011). That's
+ # fixed in Python 3.2.
+ self.assertFloatsAreIdentical(z0.real, -0.0)
+ self.assertFloatsAreIdentical(z0.imag, -0.0)
+ self.assertFloatsAreIdentical(z1.real, -0.0)
+ self.assertFloatsAreIdentical(z1.imag, -7.0)
+ self.assertFloatsAreIdentical(z2.real, -0.0)
+ self.assertFloatsAreIdentical(z2.imag, -INF)
+
+ @unittest.skipUnless(float.__getformat__("double").startswith("IEEE"),
+ "test requires IEEE 754 doubles")
def test_overflow(self):
self.assertEqual(complex("1e500"), complex(INF, 0.0))
self.assertEqual(complex("-1e500j"), complex(0.0, -INF))