mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-27145: small_ints[x] could be returned in long_add and long_sub (GH-15716)
This commit is contained in:
parent
386d00cc34
commit
036fe85bd3
3 changed files with 18 additions and 7 deletions
|
@ -956,6 +956,14 @@ class LongTest(unittest.TestCase):
|
|||
self.assertEqual(huge >> (sys.maxsize + 1), (1 << 499) + 5)
|
||||
self.assertEqual(huge >> (sys.maxsize + 1000), 0)
|
||||
|
||||
@support.cpython_only
|
||||
def test_small_ints_in_huge_calculation(self):
|
||||
a = 2 ** 100
|
||||
b = -a + 1
|
||||
c = a + 1
|
||||
self.assertIs(a + b, 1)
|
||||
self.assertIs(c - a, 1)
|
||||
|
||||
def test_small_ints(self):
|
||||
for i in range(-5, 257):
|
||||
self.assertIs(i, i + 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue