]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-123811: test that round() can return signed zero (GH-123829) (#123939)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 11 Sep 2024 12:26:35 +0000 (14:26 +0200)
committerGitHub <noreply@github.com>
Wed, 11 Sep 2024 12:26:35 +0000 (12:26 +0000)
gh-123811: test that round() can return signed zero (GH-123829)
(cherry picked from commit d2b9b6f919e92184420c8e13d078e83447ce7917)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Lib/test/test_float.py

index 74c7c17993d9a6989f81356c4f4b1b881d144542..9afaa55765e708ea2026428774e05d8af1a10225 100644 (file)
@@ -829,7 +829,7 @@ class ReprTestCase(unittest.TestCase):
             self.assertEqual(repr(float(negs)), str(float(negs)))
 
 @support.requires_IEEE_754
-class RoundTestCase(unittest.TestCase):
+class RoundTestCase(unittest.TestCase, FloatsAreIdenticalMixin):
 
     def test_inf_nan(self):
         self.assertRaises(OverflowError, round, INF)
@@ -859,10 +859,10 @@ class RoundTestCase(unittest.TestCase):
 
     def test_small_n(self):
         for n in [-308, -309, -400, 1-2**31, -2**31, -2**31-1, -2**100]:
-            self.assertEqual(round(123.456, n), 0.0)
-            self.assertEqual(round(-123.456, n), -0.0)
-            self.assertEqual(round(1e300, n), 0.0)
-            self.assertEqual(round(1e-320, n), 0.0)
+            self.assertFloatsAreIdentical(round(123.456, n), 0.0)
+            self.assertFloatsAreIdentical(round(-123.456, n), -0.0)
+            self.assertFloatsAreIdentical(round(1e300, n), 0.0)
+            self.assertFloatsAreIdentical(round(1e-320, n), 0.0)
 
     def test_overflow(self):
         self.assertRaises(OverflowError, round, 1.6e308, -308)