From dbed8f576d71ea373add62a6e35dfb6ad65720f2 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Tue, 4 Feb 2020 16:34:38 +0100 Subject: tests/basics: Move test for "return" outside function to own file. Because its behaviour is conditional on MICROPY_CPYTHON_COMPAT. --- tests/basics/syntaxerror_return.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tests/basics/syntaxerror_return.py (limited to 'tests/basics/syntaxerror_return.py') diff --git a/tests/basics/syntaxerror_return.py b/tests/basics/syntaxerror_return.py new file mode 100644 index 000000000..a32bfbd33 --- /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') -- cgit v1.2.3