summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics/builtin_compile.py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-10-26 15:38:28 +0000
committerDamien George <damien.p.george@gmail.com>2014-10-26 15:38:28 +0000
commitb2f19b8d349314baba640e1dd99ea833d0bc4b8f (patch)
treea614beb205858390e8ca110141c497db84483208 /tests/basics/builtin_compile.py
parent480a7ce58f6e5dc6179373f1f8b69d6a5434b2d4 (diff)
downloadmicropython-b2f19b8d349314baba640e1dd99ea833d0bc4b8f.tar.gz
micropython-b2f19b8d349314baba640e1dd99ea833d0bc4b8f.zip
tests: Get builtin_compile to skin properly on pyboard.
Diffstat (limited to 'tests/basics/builtin_compile.py')
-rw-r--r--tests/basics/builtin_compile.py36
1 files changed, 22 insertions, 14 deletions
diff --git a/tests/basics/builtin_compile.py b/tests/basics/builtin_compile.py
index b6f65a2fa3..ef3ff014d4 100644
--- a/tests/basics/builtin_compile.py
+++ b/tests/basics/builtin_compile.py
@@ -1,21 +1,29 @@
# test compile builtin
-try:
- compile
-except NameError:
- print("SKIP")
- import sys
- sys.exit()
+def have_compile():
+ try:
+ compile
+ return True
+ except NameError:
+ return False
+
+# global variable for compiled code to access
+x = 1
-c = compile("print(x)", "file", "exec")
+def test():
+ c = compile("print(x)", "file", "exec")
+
+ try:
+ exec(c)
+ except NameError:
+ print("NameError")
-try:
exec(c)
-except NameError:
- print("NameError")
-x = 1
-exec(c)
+ exec(c, {"x":2})
+ exec(c, {}, {"x":3})
-exec(c, {"x":2})
-exec(c, {}, {"x":3})
+if have_compile():
+ test()
+else:
+ print("SKIP")