[Python-checkins] r87044 - python/branches/py3k/Lib/test/test_complex.py
eric.smith
python-checkins at python.org
Sat Dec 4 16:26:14 CET 2010
Author: eric.smith
Date: Sat Dec 4 16:26:13 2010
New Revision: 87044
Log:
Issue 10625: Add tests for negative zeros in complex str and repr.
Modified:
python/branches/py3k/Lib/test/test_complex.py
Modified: python/branches/py3k/Lib/test/test_complex.py
==============================================================================
--- python/branches/py3k/Lib/test/test_complex.py (original)
+++ python/branches/py3k/Lib/test/test_complex.py Sat Dec 4 16:26:13 2010
@@ -408,6 +408,22 @@
self.assertEqual(-6j,complex(repr(-6j)))
self.assertEqual(6j,complex(repr(6j)))
+ @support.requires_IEEE_754
+ def test_negative_zero_repr_str(self):
+ def test(v, expected, test_fn=self.assertEqual):
+ test_fn(repr(v), expected)
+ test_fn(str(v), expected)
+
+ test(complex(0., 1.), "1j")
+ test(complex(-0., 1.), "(-0+1j)")
+ test(complex(0., -1.), "-1j")
+ test(complex(-0., -1.), "(-0-1j)")
+
+ test(complex(0., 0.), "0j")
+ test(complex(0., -0.), "-0j")
+ test(complex(-0., 0.), "(-0+0j)")
+ test(complex(-0., -0.), "(-0-0j)")
+
def test_neg(self):
self.assertEqual(-(1+6j), -1-6j)
More information about the Python-checkins
mailing list