From a1d2c1afbf2f435f6fabf6dc0b3df8502907e9c5 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Mon, 18 Sep 2023 09:15:07 +0300 Subject: [PATCH] gh-102837: Increase test coverage for the math module * fsum: L1367, L1377, L1381, L1410 // line numbers wrt to 54fbfa8d5e --- Lib/test/test_math.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py index d5d2197c36b254..b1ba16d7aeca97 100644 --- a/Lib/test/test_math.py +++ b/Lib/test/test_math.py @@ -685,6 +685,8 @@ def msum(iterable): ([], 0.0), ([0.0], 0.0), ([1e100, 1.0, -1e100, 1e-100, 1e50, -1.0, -1e50], 1e-100), + ([1e100, 1.0, -1e100, 1e-100, 1e50, -1, -1e50], 1e-100), + ([1e100, FloatLike(1.0), -1e100, 1e-100, 1e50, FloatLike(-1.0), -1e50], 1e-100), ([2.0**53, -0.5, -2.0**-54], 2.0**53-1.0), ([2.0**53, 1.0, 2.0**-100], 2.0**53+2.0), ([2.0**53+10.0, 1.0, 2.0**-100], 2.0**53+12.0), @@ -733,9 +735,18 @@ def msum(iterable): self.assertEqual(msum(vals), math.fsum(vals)) self.assertEqual(math.fsum([1.0, math.inf]), math.inf) + self.assertTrue(math.isnan(math.fsum([math.nan, 1.0]))) self.assertRaises(OverflowError, math.fsum, [1e+308, 1e+308]) self.assertRaises(ValueError, math.fsum, [math.inf, -math.inf]) self.assertRaises(TypeError, math.fsum, ['spam']) + self.assertRaises(TypeError, math.fsum, 1) + self.assertRaises(OverflowError, math.fsum, [10**1000]) + + def bad_iter(): + yield 1.0 + raise ZeroDivisionError + + self.assertRaises(ZeroDivisionError, math.fsum, bad_iter()) def testGcd(self): gcd = math.gcd