summaryrefslogtreecommitdiff
path: root/tests/basics
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2018-04-04 01:43:16 +1000
committerDamien George <damien.p.george@gmail.com>2018-04-04 01:43:16 +1000
commit430efb044400ae191edc0d1a1654b875284313a7 (patch)
treee9d8b92594abdf98452c7c5412d4bad9c9f2b123 /tests/basics
parentbc36521386a2c608be06fa8a5bf110b050dd1052 (diff)
tests/basics: Add test for use of return within try-except.
The case of a return statement in the try suite of a try-except statement was previously only tested by builtin_compile.py, and only then in the part of this test which checked for the existence of the compile builtin. So this patch adds an explicit unit test for this case.
Diffstat (limited to 'tests/basics')
-rw-r--r--tests/basics/try_return.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/basics/try_return.py b/tests/basics/try_return.py
new file mode 100644
index 000000000..492c18d95
--- /dev/null
+++ b/tests/basics/try_return.py
@@ -0,0 +1,11 @@
+# test use of return with try-except
+
+def f(l, i):
+ try:
+ return l[i]
+ except IndexError:
+ print('IndexError')
+ return -1
+
+print(f([1], 0))
+print(f([], 0))