tests/basics: Move test for "return" outside function to own file.
Because its behaviour is conditional on MICROPY_CPYTHON_COMPAT.
This commit is contained in:
parent
e6c9800645
commit
dbed8f576d
|
@ -82,7 +82,6 @@ test_syntax("break")
|
|||
test_syntax("continue")
|
||||
|
||||
# must be in a function
|
||||
test_syntax("return")
|
||||
test_syntax("yield")
|
||||
test_syntax("nonlocal a")
|
||||
test_syntax("await 1")
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
# With MICROPY_CPYTHON_COMPAT, the "return" statement can only appear in a
|
||||
# function.
|
||||
# Otherwise (in minimal builds), it ends execution of a module/class.
|
||||
|
||||
try:
|
||||
exec
|
||||
except NameError:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
try:
|
||||
exec('return; print("this should not be executed.")')
|
||||
# if we get here then MICROPY_CPYTHON_COMPAT is disabled and test
|
||||
# should be skipped.
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
except SyntaxError:
|
||||
print('SyntaxError')
|
Loading…
Reference in New Issue