mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
Issue 23229: add cmath.inf, cmath.nan, cmath.infj and cmath.nanj.
This commit is contained in:
parent
8631da64bb
commit
84e6311dee
4 changed files with 103 additions and 0 deletions
|
@ -154,6 +154,23 @@ class CMathTests(unittest.TestCase):
|
|||
self.assertAlmostEqual(cmath.e, e_expected, places=9,
|
||||
msg="cmath.e is {}; should be {}".format(cmath.e, e_expected))
|
||||
|
||||
def test_infinity_and_nan_constants(self):
|
||||
self.assertEqual(cmath.inf.real, math.inf)
|
||||
self.assertEqual(cmath.inf.imag, 0.0)
|
||||
self.assertEqual(cmath.infj.real, 0.0)
|
||||
self.assertEqual(cmath.infj.imag, math.inf)
|
||||
|
||||
self.assertTrue(math.isnan(cmath.nan.real))
|
||||
self.assertEqual(cmath.nan.imag, 0.0)
|
||||
self.assertEqual(cmath.nanj.real, 0.0)
|
||||
self.assertTrue(math.isnan(cmath.nanj.imag))
|
||||
|
||||
# Check consistency with reprs.
|
||||
self.assertEqual(repr(cmath.inf), "inf")
|
||||
self.assertEqual(repr(cmath.infj), "infj")
|
||||
self.assertEqual(repr(cmath.nan), "nan")
|
||||
self.assertEqual(repr(cmath.nanj), "nanj")
|
||||
|
||||
def test_user_object(self):
|
||||
# Test automatic calling of __complex__ and __float__ by cmath
|
||||
# functions
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue