Skip to content

Commit 703c009

Browse files
committed
tests: Add cmdline test to test showbc code.
1 parent 42e0c59 commit 703c009

2 files changed

Lines changed: 717 additions & 0 deletions

File tree

tests/cmdline/cmd_showbc.py

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
# cmdline: -v -v
2+
# test printing of all bytecodes
3+
4+
def f():
5+
# constants
6+
a = None + False + True + ...
7+
a = 0
8+
a = 1000
9+
a = -1000
10+
11+
# constructing data
12+
a = 1
13+
b = (1, 2)
14+
c = [1, 2]
15+
d = {1, 2}
16+
e = {}
17+
f = {1:2}
18+
g = 'a'
19+
h = b'a'
20+
21+
# unary/binary ops
22+
i = 1
23+
j = 2
24+
k = a + b
25+
l = -a
26+
m = not a
27+
m = a == b == c
28+
m = not (a == b and b == c)
29+
30+
# attributes
31+
n = b.c
32+
b.c = n
33+
34+
# subscript
35+
p = b[0]
36+
b[0] = p
37+
38+
# slice
39+
a = b[::]
40+
41+
# sequenc unpacking
42+
a, b = c
43+
44+
# tuple swapping
45+
a, b = b, a
46+
a, b, c = c, b, a
47+
48+
# del fast
49+
del a
50+
51+
# globals
52+
global gl
53+
gl = a
54+
del gl
55+
56+
# comprehensions
57+
a = (b for c in d if e)
58+
a = [b for c in d if e]
59+
a = {b:b for c in d if e}
60+
61+
# function calls
62+
a()
63+
a(1)
64+
a(b=1)
65+
a(*b)
66+
67+
# method calls
68+
a.b()
69+
a.b(1)
70+
a.b(c=1)
71+
a.b(*c)
72+
73+
# jumps
74+
if a:
75+
x
76+
else:
77+
y
78+
while a:
79+
b
80+
while not a:
81+
b
82+
83+
# for loop
84+
for a in b:
85+
c
86+
87+
# exceptions
88+
try:
89+
while a:
90+
break
91+
except:
92+
b
93+
finally:
94+
c
95+
96+
# with
97+
with a:
98+
b
99+
100+
# closed over variables
101+
x = 1
102+
def closure():
103+
a = x + 1
104+
x = 1
105+
del x
106+
107+
# import
108+
import a
109+
from a import b
110+
from a import *
111+
112+
# raise
113+
raise
114+
raise 1
115+
116+
# return
117+
return
118+
return 1
119+
120+
# functions with default args
121+
def f(a=1):
122+
pass
123+
124+
def f(b=2):
125+
return b + a
126+
127+
# function which yields
128+
def f():
129+
yield
130+
yield 1
131+
yield from 1
132+
133+
# class
134+
class Class:
135+
pass

0 commit comments

Comments
 (0)