Mercurial > cpython-lru_cache-weakref
diff Lib/test/test_complex.py @ 62649:2bc54da4b82c
Issue #9011: Tests for Python 3.2's treatment of negated imaginary literals.
| author | Mark Dickinson <dickinsm@gmail.com> |
|---|---|
| date | Wed, 30 Jun 2010 11:13:36 +0000 |
| parents | d6016fa58df6 |
| children | 897fd51051bb |
line wrap: on
line diff
--- a/Lib/test/test_complex.py Wed Jun 30 09:14:43 2010 +0000 +++ b/Lib/test/test_complex.py Wed Jun 30 11:13:36 2010 +0000 @@ -437,6 +437,23 @@ @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))
