Skip to content

Commit a1d2c1a

Browse files
committed
pythongh-102837: Increase test coverage for the math module
* fsum: L1367, L1377, L1381, L1410 // line numbers wrt to 54fbfa8
1 parent 99fba5f commit a1d2c1a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Lib/test/test_math.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,8 @@ def msum(iterable):
685685
([], 0.0),
686686
([0.0], 0.0),
687687
([1e100, 1.0, -1e100, 1e-100, 1e50, -1.0, -1e50], 1e-100),
688+
([1e100, 1.0, -1e100, 1e-100, 1e50, -1, -1e50], 1e-100),
689+
([1e100, FloatLike(1.0), -1e100, 1e-100, 1e50, FloatLike(-1.0), -1e50], 1e-100),
688690
([2.0**53, -0.5, -2.0**-54], 2.0**53-1.0),
689691
([2.0**53, 1.0, 2.0**-100], 2.0**53+2.0),
690692
([2.0**53+10.0, 1.0, 2.0**-100], 2.0**53+12.0),
@@ -733,9 +735,18 @@ def msum(iterable):
733735
self.assertEqual(msum(vals), math.fsum(vals))
734736

735737
self.assertEqual(math.fsum([1.0, math.inf]), math.inf)
738+
self.assertTrue(math.isnan(math.fsum([math.nan, 1.0])))
736739
self.assertRaises(OverflowError, math.fsum, [1e+308, 1e+308])
737740
self.assertRaises(ValueError, math.fsum, [math.inf, -math.inf])
738741
self.assertRaises(TypeError, math.fsum, ['spam'])
742+
self.assertRaises(TypeError, math.fsum, 1)
743+
self.assertRaises(OverflowError, math.fsum, [10**1000])
744+
745+
def bad_iter():
746+
yield 1.0
747+
raise ZeroDivisionError
748+
749+
self.assertRaises(ZeroDivisionError, math.fsum, bad_iter())
739750

740751
def testGcd(self):
741752
gcd = math.gcd

0 commit comments

Comments
 (0)