summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_long.py
diff options
context:
space:
mode:
authorHongWeipeng <961365124@qq.com>2019-11-26 07:54:49 (GMT)
committerInada Naoki <songofacandy@gmail.com>2019-11-26 07:54:49 (GMT)
commit036fe85bd3e6cd01093d836d71792a1966f961e8 (patch)
treecc1147b732a9913d34134641b321b15ddff47707 /Lib/test/test_long.py
parent386d00cc341b549800776b906bfc6b20ea40c7db (diff)
downloadcpython-036fe85bd3e6cd01093d836d71792a1966f961e8.zip
cpython-036fe85bd3e6cd01093d836d71792a1966f961e8.tar.gz
cpython-036fe85bd3e6cd01093d836d71792a1966f961e8.tar.bz2
bpo-27145: small_ints[x] could be returned in long_add and long_sub (GH-15716)
Diffstat (limited to 'Lib/test/test_long.py')
-rw-r--r--Lib/test/test_long.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_long.py b/Lib/test/test_long.py
index 53101b3..7ce37e8 100644
--- a/Lib/test/test_long.py
+++ b/Lib/test/test_long.py
@@ -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)