Skip to content

Commit 5ad6781

Browse files
committed
update test_folding_subscript
1 parent a4c8db6 commit 5ad6781

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

Lib/test/test_peepholer.py

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -475,36 +475,34 @@ def test_constant_folding(self):
475475

476476
def test_folding_subscript(self):
477477
tests = [
478-
# small ints
479-
('(1, )[0]', True, False),
480-
('(255, )[0]', True, False),
481-
('(1, (1, 2))[1][1]', True, False),
482-
('(1, 2)[2-1]', True, False),
483-
('(1, (1, 2))[1][2-1]', True, False),
484-
('(1, (1, 2))[1:6][0][2-1]', True, False),
485-
# regular ints
486-
('(256, )[0]', False, False),
487-
('(1, (1, 1000))[1][1]', False, False),
488-
('(1, 1000)[2-1]', False, False),
489-
('(1, (1, 1000))[1][2-1]', False, False),
490-
# errors
491-
('(1, )[1]', True, True),
492-
('(1, )[-2]', False, True),
493-
('"a"[1]', True, True),
494-
('"a"[-2]', False, True),
495-
('(1, (1, 2))[2:6][0][2-1]', True, True),
478+
('(1, )[0]', False),
479+
('(1, )[-1]', False),
480+
('(1 + 2, )[0]', False),
481+
('(1, (1, 2))[1][1]', False),
482+
('(1, 2)[2-1]', False),
483+
('(1, (1, 2))[1][2-1]', False),
484+
('(1, (1, 2))[1:6][0][2-1]', False),
485+
('"a"[0]', False),
486+
('("a" + "b")[1]', False),
487+
('("a" + "b", )[0][1]', False),
488+
('("a" * 10)[9]', False),
489+
('(1, )[1]', True),
490+
('(1, )[-2]', True),
491+
('"a"[1]', True),
492+
('"a"[-2]', True),
493+
('("a" + "b")[2]', True),
494+
('("a" + "b", )[0][2]', True),
495+
('("a" + "b", )[1][0]', True),
496+
('("a" * 10)[10]', True),
497+
('(1, (1, 2))[2:6][0][2-1]', True),
496498
]
497-
for expr, has_small_int, has_error in tests:
498-
with self.subTest(expr=expr, has_small_int=has_small_int, has_error=has_error):
499+
for expr, has_error in tests:
500+
with self.subTest(expr=expr, has_error=has_error):
499501
code = compile(expr, '', 'single')
500502
if not has_error:
501503
self.assertNotInBytecode(code, 'BINARY_SUBSCR')
502504
else:
503505
self.assertInBytecode(code, 'BINARY_SUBSCR')
504-
if has_small_int:
505-
self.assertInBytecode(code, 'LOAD_SMALL_INT')
506-
else:
507-
self.assertNotInBytecode(code, 'LOAD_SMALL_INT')
508506
self.check_lnotab(code)
509507

510508
def test_in_literal_list(self):

0 commit comments

Comments
 (0)