summaryrefslogtreecommitdiff
path: root/Lib/test/test_complex.py
diff options
context:
space:
mode:
authorEric Smith <eric@trueblade.com>2010-12-04 15:26:13 +0000
committerEric Smith <eric@trueblade.com>2010-12-04 15:26:13 +0000
commit481d041a8e0de2f6737353a779a31efcfc32e3ab (patch)
tree9601b38c855706cc7bf8bd6ff01b53e957366fe3 /Lib/test/test_complex.py
parent9c91999aaca559943bbd919daffb96cae79b9256 (diff)
downloadcpython-481d041a8e0de2f6737353a779a31efcfc32e3ab.tar.gz
Issue 10625: Add tests for negative zeros in complex str and repr.
Diffstat (limited to 'Lib/test/test_complex.py')
-rw-r--r--Lib/test/test_complex.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_complex.py b/Lib/test/test_complex.py
index f9bed06a00..6b34ddc0a6 100644
--- a/Lib/test/test_complex.py
+++ b/Lib/test/test_complex.py
@@ -408,6 +408,22 @@ class ComplexTest(unittest.TestCase):
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)