Skip to content

Commit cdec7ba

Browse files
committed
tests: Add a coverage test for printing the parse-tree.
1 parent ebb8413 commit cdec7ba

5 files changed

Lines changed: 87 additions & 0 deletions

File tree

tests/cmdline/cmd_parsetree.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# cmdline: -v -v -v
2+
# test printing of the parse-tree
3+
4+
for i in ():
5+
pass
6+
a = None
7+
b = 'str'
8+
c = 'a very long str that will not be interned'
9+
d = b'bytes'
10+
e = b'a very long bytes that will not be interned'
11+
f = 123456789012345678901234567890

tests/cmdline/cmd_parsetree.py.exp

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
----------------
2+
[ 4] rule(2) (n=8)
3+
tok(5)
4+
[ 4] rule(78) (n=4)
5+
id(i)
6+
[ 4] rule(131) (n=1)
7+
NULL
8+
[ 5] rule(42) (n=0)
9+
NULL
10+
[ 6] rule(32) (n=2)
11+
id(a)
12+
tok(15)
13+
[ 7] rule(32) (n=2)
14+
id(b)
15+
str(str)
16+
[ 8] rule(32) (n=2)
17+
id(c)
18+
[ 8] literal str(a very long str that will not be interned)
19+
[ 9] rule(32) (n=2)
20+
id(d)
21+
bytes(bytes)
22+
[ 10] rule(32) (n=2)
23+
id(e)
24+
[ 10] literal bytes(a very long bytes that will not be interned)
25+
[ 11] rule(32) (n=2)
26+
id(f)
27+
[ 11] literal \.\+
28+
----------------
29+
File cmdline/cmd_parsetree.py, code block '<module>' (descriptor: \.\+, bytecode @\.\+ bytes)
30+
Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+):
31+
########
32+
\.\+5b
33+
arg names:
34+
(N_STATE 2)
35+
(N_EXC_STACK 0)
36+
bc=-1 line=1
37+
bc=0 line=4
38+
bc=9 line=5
39+
bc=12 line=6
40+
bc=16 line=7
41+
bc=22 line=8
42+
bc=27 line=9
43+
bc=32 line=10
44+
bc=37 line=11
45+
00 BUILD_TUPLE 0
46+
02 GET_ITER
47+
03 FOR_ITER 12
48+
06 STORE_NAME i
49+
09 JUMP 3
50+
12 LOAD_CONST_NONE
51+
13 STORE_NAME a
52+
16 LOAD_CONST_STRING 'str'
53+
19 STORE_NAME b
54+
22 LOAD_CONST_OBJ \.\+
55+
24 STORE_NAME c
56+
27 LOAD_CONST_OBJ \.\+
57+
29 STORE_NAME d
58+
32 LOAD_CONST_OBJ \.\+
59+
34 STORE_NAME e
60+
37 LOAD_CONST_OBJ \.\+
61+
39 STORE_NAME f
62+
42 LOAD_CONST_NONE
63+
43 RETURN_VALUE
64+
mem: total=\\d\+, current=\\d\+, peak=\\d\+
65+
stack: \\d\+ out of \\d\+
66+
GC: total: \\d\+, used: \\d\+, free: \\d\+
67+
No. of 1-blocks: \\d\+, 2-blocks: \\d\+, max blk sz: \\d\+, max free sz: \\d\+

tests/feature_check/coverage.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
try:
2+
extra_coverage
3+
print('coverage')
4+
except NameError:
5+
print('no')

tests/feature_check/coverage.py.exp

Whitespace-only changes.

tests/run-tests

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ def run_tests(pyb, tests, args):
208208

209209
upy_byteorder = run_micropython(pyb, args, 'feature_check/byteorder.py')
210210
has_complex = run_micropython(pyb, args, 'feature_check/complex.py') == b'complex\n'
211+
has_coverage = run_micropython(pyb, args, 'feature_check/coverage.py') == b'coverage\n'
211212
cpy_byteorder = subprocess.check_output([CPYTHON3, 'feature_check/byteorder.py'])
212213
skip_endian = (upy_byteorder != cpy_byteorder)
213214

@@ -225,6 +226,9 @@ def run_tests(pyb, tests, args):
225226
skip_tests.add('float/true_value.py')
226227
skip_tests.add('float/types.py')
227228

229+
if not has_coverage:
230+
skip_tests.add('cmdline/cmd_parsetree.py')
231+
228232
# Some tests shouldn't be run on a PC
229233
if pyb is None:
230234
# unix build does not have the GIL so can't run thread mutation tests

0 commit comments

Comments
 (0)