diff options
author | Eric Smith <eric@trueblade.com> | 2010-12-04 15:26:13 (GMT) |
---|---|---|
committer | Eric Smith <eric@trueblade.com> | 2010-12-04 15:26:13 (GMT) |
commit | 1ed77f300b713166b0508eacd183c32f1d7437b2 (patch) | |
tree | cc26274486b937a1d6ea27228e21c94033291e74 /Lib/test | |
parent | 3ab08cadaebd694533edee03ad2b4eba2055d4e3 (diff) | |
download | cpython-1ed77f300b713166b0508eacd183c32f1d7437b2.zip cpython-1ed77f300b713166b0508eacd183c32f1d7437b2.tar.gz cpython-1ed77f300b713166b0508eacd183c32f1d7437b2.tar.bz2 |
Issue 10625: Add tests for negative zeros in complex str and repr.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_complex.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_complex.py b/Lib/test/test_complex.py index f9bed06..6b34ddc 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) |