]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-123811: test that round() can return signed zero (#123829)
authorSergey B Kirpichev <skirpichev@gmail.com>
Wed, 11 Sep 2024 09:21:05 +0000 (12:21 +0300)
committerGitHub <noreply@github.com>
Wed, 11 Sep 2024 09:21:05 +0000 (11:21 +0200)
Lib/test/test_float.py

index 42fc99131472c51446f4c1a96aae2034bf1a2107..048bb14509064beee6e35db65b5668ffc6e2f6c8 100644 (file)
@@ -863,7 +863,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)
@@ -893,10 +893,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)