mirror of
https://github.com/python/cpython.git
synced 2025-12-04 16:43:27 +00:00
Issue 10625: Add tests for negative zeros in complex str and repr.
This commit is contained in:
parent
3ab08cadae
commit
1ed77f300b
1 changed files with 16 additions and 0 deletions
|
|
@ -408,6 +408,22 @@ class ComplexTest(unittest.TestCase):
|
||||||
self.assertEqual(-6j,complex(repr(-6j)))
|
self.assertEqual(-6j,complex(repr(-6j)))
|
||||||
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):
|
def test_neg(self):
|
||||||
self.assertEqual(-(1+6j), -1-6j)
|
self.assertEqual(-(1+6j), -1-6j)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue