summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2016-12-22 11:26:06 +1100
committerDamien George <damien.p.george@gmail.com>2016-12-22 11:26:06 +1100
commitcdec7ba30ed6d527c2d007b7fd37413f0c71a1fd (patch)
tree8c6e20f1c4d3b19c1587a1d4e025605c7e29bc52
parentebb84131788ca1134d0c9cf38fcb1e5162c14bc3 (diff)
downloadmicropython-cdec7ba30ed6d527c2d007b7fd37413f0c71a1fd.tar.gz
micropython-cdec7ba30ed6d527c2d007b7fd37413f0c71a1fd.zip
tests: Add a coverage test for printing the parse-tree.
-rw-r--r--tests/cmdline/cmd_parsetree.py11
-rw-r--r--tests/cmdline/cmd_parsetree.py.exp67
-rw-r--r--tests/feature_check/coverage.py5
-rw-r--r--tests/feature_check/coverage.py.exp0
-rwxr-xr-xtests/run-tests4
5 files changed, 87 insertions, 0 deletions
diff --git a/tests/cmdline/cmd_parsetree.py b/tests/cmdline/cmd_parsetree.py
new file mode 100644
index 0000000000..5f698eeae3
--- /dev/null
+++ b/tests/cmdline/cmd_parsetree.py
@@ -0,0 +1,11 @@
+# cmdline: -v -v -v
+# test printing of the parse-tree
+
+for i in ():
+ pass
+a = None
+b = 'str'
+c = 'a very long str that will not be interned'
+d = b'bytes'
+e = b'a very long bytes that will not be interned'
+f = 123456789012345678901234567890
diff --git a/tests/cmdline/cmd_parsetree.py.exp b/tests/cmdline/cmd_parsetree.py.exp
new file mode 100644
index 0000000000..06fbeadfc8
--- /dev/null
+++ b/tests/cmdline/cmd_parsetree.py.exp
@@ -0,0 +1,67 @@
+----------------
+[ 4] rule(2) (n=8)
+ tok(5)
+[ 4] rule(78) (n=4)
+ id(i)
+[ 4] rule(131) (n=1)
+ NULL
+[ 5] rule(42) (n=0)
+ NULL
+[ 6] rule(32) (n=2)
+ id(a)
+ tok(15)
+[ 7] rule(32) (n=2)
+ id(b)
+ str(str)
+[ 8] rule(32) (n=2)
+ id(c)
+[ 8] literal str(a very long str that will not be interned)
+[ 9] rule(32) (n=2)
+ id(d)
+ bytes(bytes)
+[ 10] rule(32) (n=2)
+ id(e)
+[ 10] literal bytes(a very long bytes that will not be interned)
+[ 11] rule(32) (n=2)
+ id(f)
+[ 11] literal \.\+
+----------------
+File cmdline/cmd_parsetree.py, code block '<module>' (descriptor: \.\+, bytecode @\.\+ bytes)
+Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+):
+########
+\.\+5b
+arg names:
+(N_STATE 2)
+(N_EXC_STACK 0)
+ bc=-1 line=1
+ bc=0 line=4
+ bc=9 line=5
+ bc=12 line=6
+ bc=16 line=7
+ bc=22 line=8
+ bc=27 line=9
+ bc=32 line=10
+ bc=37 line=11
+00 BUILD_TUPLE 0
+02 GET_ITER
+03 FOR_ITER 12
+06 STORE_NAME i
+09 JUMP 3
+12 LOAD_CONST_NONE
+13 STORE_NAME a
+16 LOAD_CONST_STRING 'str'
+19 STORE_NAME b
+22 LOAD_CONST_OBJ \.\+
+24 STORE_NAME c
+27 LOAD_CONST_OBJ \.\+
+29 STORE_NAME d
+32 LOAD_CONST_OBJ \.\+
+34 STORE_NAME e
+37 LOAD_CONST_OBJ \.\+
+39 STORE_NAME f
+42 LOAD_CONST_NONE
+43 RETURN_VALUE
+mem: total=\\d\+, current=\\d\+, peak=\\d\+
+stack: \\d\+ out of \\d\+
+GC: total: \\d\+, used: \\d\+, free: \\d\+
+ No. of 1-blocks: \\d\+, 2-blocks: \\d\+, max blk sz: \\d\+, max free sz: \\d\+
diff --git a/tests/feature_check/coverage.py b/tests/feature_check/coverage.py
new file mode 100644
index 0000000000..dcda53eae2
--- /dev/null
+++ b/tests/feature_check/coverage.py
@@ -0,0 +1,5 @@
+try:
+ extra_coverage
+ print('coverage')
+except NameError:
+ print('no')
diff --git a/tests/feature_check/coverage.py.exp b/tests/feature_check/coverage.py.exp
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/feature_check/coverage.py.exp
diff --git a/tests/run-tests b/tests/run-tests
index 1a686584c3..d142c998cf 100755
--- a/tests/run-tests
+++ b/tests/run-tests
@@ -208,6 +208,7 @@ def run_tests(pyb, tests, args):
upy_byteorder = run_micropython(pyb, args, 'feature_check/byteorder.py')
has_complex = run_micropython(pyb, args, 'feature_check/complex.py') == b'complex\n'
+ has_coverage = run_micropython(pyb, args, 'feature_check/coverage.py') == b'coverage\n'
cpy_byteorder = subprocess.check_output([CPYTHON3, 'feature_check/byteorder.py'])
skip_endian = (upy_byteorder != cpy_byteorder)
@@ -225,6 +226,9 @@ def run_tests(pyb, tests, args):
skip_tests.add('float/true_value.py')
skip_tests.add('float/types.py')
+ if not has_coverage:
+ skip_tests.add('cmdline/cmd_parsetree.py')
+
# Some tests shouldn't be run on a PC
if pyb is None:
# unix build does not have the GIL so can't run thread mutation tests