summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-08-29 12:59:48 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-08-29 12:59:48 (GMT)
commit2be278c70c128f67e6fa7a1790543a8990f384b8 (patch)
tree8775157c422cf880ee5477b765739c676fc00b5c /Lib/test
parent1f9326196ecce5373aa788fa403c3361c59fce4e (diff)
parent84e6311dee71bb104e1779c89cf22ff703799086 (diff)
downloadcpython-2be278c70c128f67e6fa7a1790543a8990f384b8.zip
cpython-2be278c70c128f67e6fa7a1790543a8990f384b8.tar.gz
cpython-2be278c70c128f67e6fa7a1790543a8990f384b8.tar.bz2
Merge heads
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_cmath.py17
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