Issue #9165: Add math.isfinite and cmath.isfinite.

This commit is contained in:
Mark Dickinson 2010-07-11 17:38:24 +00:00
parent 3e7428995f
commit 8e0c996873
7 changed files with 61 additions and 0 deletions

View file

@ -915,6 +915,15 @@ class MathTests(unittest.TestCase):
self.assertRaises(TypeError, math.trunc, 1, 2)
self.assertRaises(TypeError, math.trunc, TestNoTrunc())
def testIsfinite(self):
self.assertTrue(math.isfinite(0.0))
self.assertTrue(math.isfinite(-0.0))
self.assertTrue(math.isfinite(1.0))
self.assertTrue(math.isfinite(-1.0))
self.assertFalse(math.isfinite(float("nan")))
self.assertFalse(math.isfinite(float("inf")))
self.assertFalse(math.isfinite(float("-inf")))
def testIsnan(self):
self.assertTrue(math.isnan(float("nan")))
self.assertTrue(math.isnan(float("inf")* 0.))