summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2010-06-30 10:55:51 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2010-06-30 10:55:51 (GMT)
commitbf9f79b185719e1471d03983e40a88f49d6e0ffc (patch)
tree579b420aeb69a02f595ada1aaa4f0213d2f14650 /Lib
parentce5b6c43bfbd1e016463c92f43c9075f64fafaa6 (diff)
downloadcpython-bf9f79b185719e1471d03983e40a88f49d6e0ffc.zip
cpython-bf9f79b185719e1471d03983e40a88f49d6e0ffc.tar.gz
cpython-bf9f79b185719e1471d03983e40a88f49d6e0ffc.tar.bz2
Tests for Python 3.1's treatment of negated imaginary literals.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_complex.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_complex.py b/Lib/test/test_complex.py
index a84e949..f28bb69 100644
--- a/Lib/test/test_complex.py
+++ b/Lib/test/test_complex.py
@@ -409,6 +409,25 @@ 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
+ # This behaviour is actually incorrect: the real part of a negated
+ # imaginary literal should be -0.0, not 0.0. It's fixed in Python 3.2.
+ # However, the behaviour is already out in the wild in Python 2.x and
+ # Python <= 3.1.2, and it would be too disruptive to change it in a
+ # bugfix release, so we call it a 'feature' of Python 3.1, and test to
+ # ensure that the behaviour remains consistent across 3.1.x releases.
+ 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))