mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-42246: Don't eliminate jumps to jumps, if it will break PEP 626. (GH-23896)
This commit is contained in:
parent
d90ff37681
commit
28b75c80dc
7 changed files with 4355 additions and 4253 deletions
|
@ -810,6 +810,70 @@ class TraceTestCase(unittest.TestCase):
|
|||
(6, 'line'),
|
||||
(6, 'return')])
|
||||
|
||||
def test_break_to_continue1(self):
|
||||
|
||||
def func():
|
||||
TRUE = 1
|
||||
x = [1]
|
||||
while x:
|
||||
x.pop()
|
||||
while TRUE:
|
||||
break
|
||||
continue
|
||||
|
||||
self.run_and_compare(func,
|
||||
[(0, 'call'),
|
||||
(1, 'line'),
|
||||
(2, 'line'),
|
||||
(3, 'line'),
|
||||
(4, 'line'),
|
||||
(5, 'line'),
|
||||
(6, 'line'),
|
||||
(7, 'line'),
|
||||
(3, 'line'),
|
||||
(3, 'return')])
|
||||
|
||||
def test_break_to_continue2(self):
|
||||
|
||||
def func():
|
||||
TRUE = 1
|
||||
x = [1]
|
||||
while x:
|
||||
x.pop()
|
||||
while TRUE:
|
||||
break
|
||||
else:
|
||||
continue
|
||||
|
||||
self.run_and_compare(func,
|
||||
[(0, 'call'),
|
||||
(1, 'line'),
|
||||
(2, 'line'),
|
||||
(3, 'line'),
|
||||
(4, 'line'),
|
||||
(5, 'line'),
|
||||
(6, 'line'),
|
||||
(3, 'line'),
|
||||
(3, 'return')])
|
||||
|
||||
def test_break_to_break(self):
|
||||
|
||||
def func():
|
||||
TRUE = 1
|
||||
while TRUE:
|
||||
while TRUE:
|
||||
break
|
||||
break
|
||||
|
||||
self.run_and_compare(func,
|
||||
[(0, 'call'),
|
||||
(1, 'line'),
|
||||
(2, 'line'),
|
||||
(3, 'line'),
|
||||
(4, 'line'),
|
||||
(5, 'line'),
|
||||
(5, 'return')])
|
||||
|
||||
|
||||
class SkipLineEventsTraceTestCase(TraceTestCase):
|
||||
"""Repeat the trace tests, but with per-line events skipped"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue