summaryrefslogtreecommitdiff
path: root/Lib/test/test_math.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_math.py')
-rw-r--r--Lib/test/test_math.py23
1 files changed, 21 insertions, 2 deletions
diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py
index 48f84ba732..023dea9465 100644
--- a/Lib/test/test_math.py
+++ b/Lib/test/test_math.py
@@ -422,9 +422,17 @@ class MathTests(unittest.TestCase):
self.assertEqual(math.factorial(i), py_factorial(i))
self.assertRaises(ValueError, math.factorial, -1)
self.assertRaises(ValueError, math.factorial, -1.0)
+ self.assertRaises(ValueError, math.factorial, -10**100)
+ self.assertRaises(ValueError, math.factorial, -1e100)
self.assertRaises(ValueError, math.factorial, math.pi)
- self.assertRaises(OverflowError, math.factorial, sys.maxsize+1)
- self.assertRaises(OverflowError, math.factorial, 10e100)
+
+ # Other implementations may place different upper bounds.
+ @support.cpython_only
+ def testFactorialHugeInputs(self):
+ # Currently raises ValueError for inputs that are too large
+ # to fit into a C long.
+ self.assertRaises(OverflowError, math.factorial, 10**100)
+ self.assertRaises(OverflowError, math.factorial, 1e100)
def testFloor(self):
self.assertRaises(TypeError, math.floor)
@@ -975,6 +983,17 @@ class MathTests(unittest.TestCase):
self.assertFalse(math.isinf(0.))
self.assertFalse(math.isinf(1.))
+ @requires_IEEE_754
+ def test_nan_constant(self):
+ self.assertTrue(math.isnan(math.nan))
+
+ @requires_IEEE_754
+ def test_inf_constant(self):
+ self.assertTrue(math.isinf(math.inf))
+ self.assertGreater(math.inf, 0.0)
+ self.assertEqual(math.inf, float("inf"))
+ self.assertEqual(-math.inf, float("-inf"))
+
# RED_FLAG 16-Oct-2000 Tim
# While 2.0 is more consistent about exceptions than previous releases, it
# still fails this part of the test on some platforms. For now, we only