Skip to content

Commit

Permalink
pythongh-102837: Increase test coverage for the math module
Browse files Browse the repository at this point in the history
* fsum: L1367, L1377, L1381, L1410

// line numbers wrt to 54fbfa8
  • Loading branch information
skirpichev committed Sep 28, 2023
1 parent 99fba5f commit a1d2c1a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Lib/test/test_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a1d2c1a

Please sign in to comment.