diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2016-08-29 12:56:58 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2016-08-29 12:56:58 (GMT) |
commit | 84e6311dee71bb104e1779c89cf22ff703799086 (patch) | |
tree | 24edd9ad6b2909704f43a402f65ea31e6095be90 /Lib/test/test_cmath.py | |
parent | 8631da64bb1f163026b7be82884f8e5b506e0e66 (diff) | |
download | cpython-84e6311dee71bb104e1779c89cf22ff703799086.zip cpython-84e6311dee71bb104e1779c89cf22ff703799086.tar.gz cpython-84e6311dee71bb104e1779c89cf22ff703799086.tar.bz2 |
Issue 23229: add cmath.inf, cmath.nan, cmath.infj and cmath.nanj.
Diffstat (limited to 'Lib/test/test_cmath.py')
-rw-r--r-- | Lib/test/test_cmath.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_cmath.py b/Lib/test/test_cmath.py index 1f884e5..11b0c61 100644 --- a/Lib/test/test_cmath.py +++ b/Lib/test/test_cmath.py @@ -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 |