Commit 453c2e8f authored by Damien George's avatar Damien George
Browse files

tests/cmdline: Improve coverage test for printing bytecode.

parent 799ccdc7
......@@ -34,12 +34,14 @@ def f():
# subscript
p = b[0]
b[0] = p
b[0] += p
# slice
a = b[::]
# sequenc unpacking
a, b = c
a, *a = a
# tuple swapping
a, b = b, a
......@@ -79,6 +81,7 @@ def f():
b
while not a:
b
a = a or a
# for loop
for a in b:
......@@ -92,6 +95,11 @@ def f():
b
finally:
c
while a:
try:
break
except:
pass
# with
with a:
......@@ -117,6 +125,12 @@ def f():
return
return 1
# function with lots of locals
def f():
l1 = l2 = l3 = l4 = l5 = l6 = l7 = l8 = l9 = l10 = 1
m1 = m2 = m3 = m4 = m5 = m6 = m7 = m8 = m9 = m10 = 2
l10 + m10
# functions with default args
def f(a=1):
pass
......@@ -133,3 +147,6 @@ def f():
# class
class Class:
pass
# delete name
del Class
......@@ -7,9 +7,11 @@ arg names:
(N_EXC_STACK 0)
bc=-1 line=1
########
bc=\\d\+ line=134
bc=\\d\+ line=152
00 MAKE_FUNCTION \.\+
\\d\+ STORE_NAME f
\\d\+ MAKE_FUNCTION \.\+
\\d\+ STORE_NAME f
\\d\+ LOAD_CONST_SMALL_INT 1
\\d\+ BUILD_TUPLE 1
\\d\+ LOAD_NULL
......@@ -22,6 +24,7 @@ arg names:
\\d\+ LOAD_CONST_STRING 'Class'
\\d\+ CALL_FUNCTION n=2 nkw=0
\\d\+ STORE_NAME Class
\\d\+ DELETE_NAME Class
\\d\+ LOAD_CONST_NONE
\\d\+ RETURN_VALUE
File cmdline/cmd_showbc.py, code block 'f' (descriptor: \.\+, bytecode @\.\+ bytes)
......@@ -35,7 +38,7 @@ Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+):
(INIT_CELL 16)
bc=-4 line=1
########
bc=\\d\+ line=118
bc=\\d\+ line=126
00 LOAD_CONST_NONE
01 LOAD_CONST_FALSE
02 BINARY_OP 5 __add__
......@@ -123,6 +126,14 @@ Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+):
\\d\+ LOAD_CONST_SMALL_INT 0
\\d\+ STORE_SUBSCR
\\d\+ LOAD_DEREF 14
\\d\+ LOAD_CONST_SMALL_INT 0
\\d\+ DUP_TOP_TWO
\\d\+ LOAD_SUBSCR
\\d\+ LOAD_FAST 12
\\d\+ BINARY_OP 18 __iadd__
\\d\+ ROT_THREE
\\d\+ STORE_SUBSCR
\\d\+ LOAD_DEREF 14
\\d\+ LOAD_CONST_NONE
\\d\+ LOAD_CONST_NONE
\\d\+ BUILD_SLICE 2
......@@ -132,6 +143,10 @@ Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+):
\\d\+ UNPACK_SEQUENCE 2
\\d\+ STORE_FAST 0
\\d\+ STORE_DEREF 14
\\d\+ LOAD_FAST 0
\\d\+ UNPACK_EX 1
\\d\+ STORE_FAST 0
\\d\+ STORE_FAST 0
\\d\+ LOAD_DEREF 14
\\d\+ LOAD_FAST 0
\\d\+ ROT_TWO
......@@ -225,6 +240,10 @@ Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+):
\\d\+ POP_TOP
\\d\+ LOAD_FAST 0
\\d\+ POP_JUMP_IF_FALSE \\d\+
\\d\+ LOAD_FAST 0
\\d\+ JUMP_IF_TRUE_OR_POP \\d\+
\\d\+ LOAD_FAST 0
\\d\+ STORE_FAST 0
\\d\+ LOAD_DEREF 14
\\d\+ GET_ITER
\\d\+ FOR_ITER \\d\+
......@@ -251,6 +270,17 @@ Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+):
\\d\+ LOAD_FAST 1
\\d\+ POP_TOP
\\d\+ END_FINALLY
\\d\+ JUMP \\d\+
\\d\+ SETUP_EXCEPT \\d\+
\\d\+ UNWIND_JUMP \\d\+ 1
\\d\+ POP_BLOCK
\\d\+ JUMP \\d\+
\\d\+ POP_TOP
\\d\+ POP_EXCEPT
\\d\+ JUMP \\d\+
\\d\+ END_FINALLY
\\d\+ LOAD_FAST 0
\\d\+ POP_JUMP_IF_TRUE \\d\+
\\d\+ LOAD_FAST 0
\\d\+ SETUP_WITH \\d\+
\\d\+ POP_TOP
......@@ -291,13 +321,68 @@ Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+):
File cmdline/cmd_showbc.py, code block 'f' (descriptor: \.\+, bytecode @\.\+ bytes)
Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+):
########
\.\+rg names:
(N_STATE 22)
(N_EXC_STACK 0)
bc=-1 line=1
########
bc=\\d\+ line=132
00 LOAD_CONST_SMALL_INT 1
01 DUP_TOP
02 STORE_FAST 0
03 DUP_TOP
04 STORE_FAST 1
05 DUP_TOP
06 STORE_FAST 2
07 DUP_TOP
08 STORE_FAST 3
09 DUP_TOP
10 STORE_FAST 4
11 DUP_TOP
12 STORE_FAST 5
13 DUP_TOP
14 STORE_FAST 6
15 DUP_TOP
16 STORE_FAST 7
17 DUP_TOP
18 STORE_FAST 8
19 STORE_FAST 9
20 LOAD_CONST_SMALL_INT 2
21 DUP_TOP
22 STORE_FAST 10
23 DUP_TOP
24 STORE_FAST 11
25 DUP_TOP
26 STORE_FAST 12
27 DUP_TOP
28 STORE_FAST 13
29 DUP_TOP
30 STORE_FAST 14
31 DUP_TOP
32 STORE_FAST 15
33 DUP_TOP
34 STORE_FAST_N 16
36 DUP_TOP
37 STORE_FAST_N 17
39 DUP_TOP
40 STORE_FAST_N 18
42 STORE_FAST_N 19
44 LOAD_FAST 9
45 LOAD_FAST_N 19
47 BINARY_OP 5 __add__
48 POP_TOP
49 LOAD_CONST_NONE
50 RETURN_VALUE
File cmdline/cmd_showbc.py, code block 'f' (descriptor: \.\+, bytecode @\.\+ bytes)
Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+):
########
\.\+5b
arg names: a
(N_STATE 5)
(N_EXC_STACK 0)
(INIT_CELL 0)
########
bc=\\d\+ line=124
bc=\\d\+ line=138
00 LOAD_CONST_SMALL_INT 2
01 BUILD_TUPLE 1
03 LOAD_NULL
......@@ -314,9 +399,9 @@ arg names:
(N_STATE 2)
(N_EXC_STACK 0)
bc=-1 line=1
bc=0 line=129
bc=3 line=130
bc=6 line=131
bc=0 line=143
bc=3 line=144
bc=6 line=145
00 LOAD_CONST_NONE
01 YIELD_VALUE
02 POP_TOP
......@@ -338,7 +423,7 @@ arg names:
(N_STATE 1)
(N_EXC_STACK 0)
bc=-1 line=1
bc=13 line=135
bc=13 line=149
00 LOAD_NAME __name__ (cache=0)
04 STORE_NAME __module__
07 LOAD_CONST_STRING 'Class'
......@@ -411,7 +496,7 @@ arg names: *
(N_EXC_STACK 0)
bc=-\\d\+ line=1
########
bc=\\d\+ line=105
bc=\\d\+ line=113
00 LOAD_DEREF 0
02 LOAD_CONST_SMALL_INT 1
03 BINARY_OP 5 __add__
......@@ -430,7 +515,7 @@ arg names: * b
(N_EXC_STACK 0)
bc=-\\d\+ line=1
########
bc=\\d\+ line=125
bc=\\d\+ line=139
00 LOAD_FAST 1
01 LOAD_DEREF 0
03 BINARY_OP 5 __add__
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment