]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-109802: Add coverage test for complex_abs() (GH-117449)
authorSergey B Kirpichev <skirpichev@gmail.com>
Thu, 4 Apr 2024 14:54:17 +0000 (17:54 +0300)
committerGitHub <noreply@github.com>
Thu, 4 Apr 2024 14:54:17 +0000 (14:54 +0000)
* gh-109802: Add coverage test for complex_abs()

This tests overflow on L594.

// line numbers wrt to 0f2fa6150b

Lib/test/test_complex.py

index b057121f285dc78a624bdeeb76de30bb87e026f5..fa3017b24e16c84d8a77d91c9ecdeaae72d40f24 100644 (file)
@@ -10,6 +10,7 @@ import operator
 
 INF = float("inf")
 NAN = float("nan")
+DBL_MAX = sys.float_info.max
 # These tests ensure that complex math does the right thing
 
 ZERO_DIVISION = (
@@ -597,6 +598,8 @@ class ComplexTest(unittest.TestCase):
         for num in nums:
             self.assertAlmostEqual((num.real**2 + num.imag**2)  ** 0.5, abs(num))
 
+        self.assertRaises(OverflowError, abs, complex(DBL_MAX, DBL_MAX))
+
     def test_repr_str(self):
         def test(v, expected, test_fn=self.assertEqual):
             test_fn(repr(v), expected)