tests: Get builtin_compile to skin properly on pyboard.
This commit is contained in:
parent
480a7ce58f
commit
b2f19b8d34
@ -1,21 +1,29 @@
|
||||
# test compile builtin
|
||||
|
||||
try:
|
||||
compile
|
||||
except NameError:
|
||||
print("SKIP")
|
||||
import sys
|
||||
sys.exit()
|
||||
|
||||
c = compile("print(x)", "file", "exec")
|
||||
|
||||
try:
|
||||
exec(c)
|
||||
except NameError:
|
||||
print("NameError")
|
||||
def have_compile():
|
||||
try:
|
||||
compile
|
||||
return True
|
||||
except NameError:
|
||||
return False
|
||||
|
||||
# global variable for compiled code to access
|
||||
x = 1
|
||||
exec(c)
|
||||
|
||||
exec(c, {"x":2})
|
||||
exec(c, {}, {"x":3})
|
||||
def test():
|
||||
c = compile("print(x)", "file", "exec")
|
||||
|
||||
try:
|
||||
exec(c)
|
||||
except NameError:
|
||||
print("NameError")
|
||||
|
||||
exec(c)
|
||||
|
||||
exec(c, {"x":2})
|
||||
exec(c, {}, {"x":3})
|
||||
|
||||
if have_compile():
|
||||
test()
|
||||
else:
|
||||
print("SKIP")
|
||||
|
Loading…
x
Reference in New Issue
Block a user