You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Improve "if/else" in "for" test
This commit is contained in:
Binary file not shown.
@@ -1,15 +1,17 @@
|
|||||||
# Issue #413 on 2.7
|
# Issue #413 on 2.7
|
||||||
# Bug in handling CONTINUE in else block of if-then-else in a for loop
|
# Bug in handling CONTINUE in else block of if-then-else in a for loop
|
||||||
|
# Bug was "if" and "else" jump back to loop getting detected.
|
||||||
|
# RUNNABLE!
|
||||||
|
|
||||||
"""This program is self-checking!"""
|
"""This program is self-checking!"""
|
||||||
def test1(a, r = None):
|
def test1(a, r = []):
|
||||||
for b in a:
|
for b in a:
|
||||||
if b:
|
if b:
|
||||||
r = b
|
r.append(3)
|
||||||
else:
|
else:
|
||||||
|
r.append(5)
|
||||||
continue
|
continue
|
||||||
raise AssertionError("CONTINUE not followed")
|
if r == []:
|
||||||
if b:
|
|
||||||
pass
|
pass
|
||||||
return r
|
return r
|
||||||
|
|
||||||
@@ -27,7 +29,13 @@ def test2(a, r = None):
|
|||||||
raise AssertionError("CONTINUE not followed")
|
raise AssertionError("CONTINUE not followed")
|
||||||
return r
|
return r
|
||||||
|
|
||||||
assert test1([True]) == True, "Incorrect flow"
|
assert test1([], []) == [], "For loop not taken"
|
||||||
|
assert test1([False], []) == [5], "if 'else' should have been taken"
|
||||||
|
assert test1([True], []) == [3], "if 'then' should have been taken"
|
||||||
|
assert test1([True, True], []) == [3, 3], "if should have been taken"
|
||||||
|
assert test1([True, False], []) == [3, 5], "if and then 'else' should have been taken"
|
||||||
|
assert test1([False, True], []) == [5, 3], "if else and then 'then' should have been taken"
|
||||||
|
assert test1([False, False], []) == [5, 5], "if else should have been taken twice"
|
||||||
|
assert test1([True, True], []) == [3, 3], "if 'then' should have been taken twice"
|
||||||
assert test2([True]) is None, "Incorrect flow"
|
assert test2([True]) is None, "Incorrect flow"
|
||||||
assert test1([False]) is None, "Incorrect flow"
|
|
||||||
assert test2([False]) is None, "Incorrect flow"
|
assert test2([False]) is None, "Incorrect flow"
|
||||||
|
Reference in New Issue
Block a user