gh-109802: Add coverage test for complex_abs() (GH-117449)

* gh-109802: Add coverage test for complex_abs()

This tests overflow on L594.

// line numbers wrt to 0f2fa6150b
This commit is contained in:
Sergey B Kirpichev 2024-04-04 17:54:17 +03:00 committed by GitHub
parent df912c913a
commit 63bbe77d9b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 0 deletions

View 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)