Skip to content

Commit

Permalink
* sumprod: L2829, L2833, L2836
Browse files Browse the repository at this point in the history
  • Loading branch information
skirpichev committed Sep 28, 2023
1 parent 7956447 commit 052d7de
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Lib/test/test_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -1269,6 +1269,9 @@ def testSumProd(self):
self.assertEqual(sumprod(iter([10, 20, 30]), (1, 2, 3)), 140)
self.assertEqual(sumprod([1.5, 2.5], [3.5, 4.5]), 16.5)
self.assertEqual(sumprod([], []), 0)
self.assertEqual(sumprod([-1], [1.]), -1)
self.assertEqual(sumprod([1.], [-1]), -1)
self.assertEqual(sumprod([True], [1.0]), 1)

# Type preservation and coercion
for v in [
Expand All @@ -1294,6 +1297,7 @@ def testSumProd(self):
self.assertRaises(TypeError, sumprod, [], [], []) # Three args
self.assertRaises(TypeError, sumprod, None, [10]) # Non-iterable
self.assertRaises(TypeError, sumprod, [10], None) # Non-iterable
self.assertRaises(TypeError, sumprod, ['x'], [1.0])

# Uneven lengths
self.assertRaises(ValueError, sumprod, [10, 20], [30])
Expand All @@ -1304,6 +1308,8 @@ def testSumProd(self):
self.assertEqual(sumprod([1], [10**20]), 10**20)
self.assertEqual(sumprod([10**10], [10**10]), 10**20)
self.assertEqual(sumprod([10**7]*10**5, [10**7]*10**5), 10**19)
self.assertRaises(OverflowError, sumprod, [10**1000], [1.0])
self.assertRaises(OverflowError, sumprod, [1.0], [10**1000])

# Error in iterator
def raise_after(n):
Expand Down

0 comments on commit 052d7de

Please sign in to comment.