You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Add tests based on recent runtests.sh failures...
These run quicker and are distilled to simple examples.
This commit is contained in:
BIN
test/bytecode_2.7_run/05_control_flow_bugs.pyc
Normal file
BIN
test/bytecode_2.7_run/05_control_flow_bugs.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_3.5_run/05_control_flow_bugs.pyc-notyet
Normal file
BIN
test/bytecode_3.5_run/05_control_flow_bugs.pyc-notyet
Normal file
Binary file not shown.
BIN
test/bytecode_3.6_run/05_control_flow_bugs.pyc
Normal file
BIN
test/bytecode_3.6_run/05_control_flow_bugs.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_3.7_run/05_control_flow_bugs.pyc
Normal file
BIN
test/bytecode_3.7_run/05_control_flow_bugs.pyc
Normal file
Binary file not shown.
59
test/simple_source/operation_logic/05_control_flow_bugs.py
Normal file
59
test/simple_source/operation_logic/05_control_flow_bugs.py
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
# From 3.6.10 test_binascii.py
|
||||||
|
# Bug was getting "while c and noise" parsed correclty
|
||||||
|
# and not put into the "ifelsesmt"
|
||||||
|
|
||||||
|
# RUNNABLE!
|
||||||
|
def addnoise(c, noise):
|
||||||
|
while c and noise:
|
||||||
|
if c < 3:
|
||||||
|
c = 2
|
||||||
|
else:
|
||||||
|
c = 3
|
||||||
|
noise = False
|
||||||
|
return c
|
||||||
|
|
||||||
|
assert addnoise(0, True) == 0
|
||||||
|
assert addnoise(1, False) == 1
|
||||||
|
assert addnoise(2, True) == 2
|
||||||
|
assert addnoise(3, True) == 3
|
||||||
|
assert addnoise(4, True) == 3
|
||||||
|
assert addnoise(5, False) == 5
|
||||||
|
|
||||||
|
# From 3.6.10 test_dbm_dumb.py
|
||||||
|
# Bug was getting attaching "else" to the right "if" in the
|
||||||
|
# presense of a loop.
|
||||||
|
def test_random(a, r):
|
||||||
|
x = 0
|
||||||
|
for dummy in r:
|
||||||
|
if dummy:
|
||||||
|
if a:
|
||||||
|
x += 2
|
||||||
|
else:
|
||||||
|
x += 1
|
||||||
|
return x
|
||||||
|
|
||||||
|
assert test_random(True, [1]) == 2
|
||||||
|
assert test_random(True, [1, 1]) == 4
|
||||||
|
assert test_random(False, [1]) == 0
|
||||||
|
assert test_random(False, [1, 1]) == 0
|
||||||
|
|
||||||
|
# From 2.7.17 test_frozen.py
|
||||||
|
# Bug was getting making sure we have "try" not
|
||||||
|
# "try"/"else"
|
||||||
|
def test_frozen(a, b):
|
||||||
|
try:
|
||||||
|
x = 1 / a
|
||||||
|
except:
|
||||||
|
x = 2
|
||||||
|
|
||||||
|
try:
|
||||||
|
x += 3 / b
|
||||||
|
except:
|
||||||
|
x += 4
|
||||||
|
|
||||||
|
return x
|
||||||
|
|
||||||
|
assert test_frozen(1, 1) == 4.0
|
||||||
|
assert test_frozen(0, 1) == 5.0
|
||||||
|
assert test_frozen(0.5, 0) == 6.0
|
||||||
|
assert test_frozen(0, 0.5) == 8.0
|
Reference in New Issue
Block a user