diff options
author | Petr Viktorin <encukou@gmail.com> | 2020-02-04 16:34:38 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2020-02-06 00:42:34 +1100 |
commit | dbed8f576d71ea373add62a6e35dfb6ad65720f2 (patch) | |
tree | 479ee49817cbf03f3733c2a1895b9f81aed73b6d | |
parent | e6c9800645ba70db6289f9d81b76320454a1938f (diff) | |
download | micropython-dbed8f576d71ea373add62a6e35dfb6ad65720f2.tar.gz micropython-dbed8f576d71ea373add62a6e35dfb6ad65720f2.zip |
tests/basics: Move test for "return" outside function to own file.
Because its behaviour is conditional on MICROPY_CPYTHON_COMPAT.
-rw-r--r-- | tests/basics/syntaxerror.py | 1 | ||||
-rw-r--r-- | tests/basics/syntaxerror_return.py | 18 |
2 files changed, 18 insertions, 1 deletions
diff --git a/tests/basics/syntaxerror.py b/tests/basics/syntaxerror.py index 8e706c6e23..c0702cb245 100644 --- a/tests/basics/syntaxerror.py +++ b/tests/basics/syntaxerror.py @@ -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") diff --git a/tests/basics/syntaxerror_return.py b/tests/basics/syntaxerror_return.py new file mode 100644 index 0000000000..a32bfbd33c --- /dev/null +++ b/tests/basics/syntaxerror_return.py @@ -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') |