summaryrefslogtreecommitdiff
path: root/tests/basics
diff options
context:
space:
mode:
Diffstat (limited to 'tests/basics')
-rw-r--r--tests/basics/try_finally_break2.py19
-rw-r--r--tests/basics/try_finally_continue.py17
-rw-r--r--tests/basics/try_finally_continue.py.exp9
-rw-r--r--tests/basics/try_finally_return5.py17
4 files changed, 62 insertions, 0 deletions
diff --git a/tests/basics/try_finally_break2.py b/tests/basics/try_finally_break2.py
new file mode 100644
index 000000000..086e92e90
--- /dev/null
+++ b/tests/basics/try_finally_break2.py
@@ -0,0 +1,19 @@
+def foo(x):
+ for i in range(x):
+ for j in range(x):
+ try:
+ print(x, i, j, 1)
+ finally:
+ try:
+ try:
+ print(x, i, j, 2)
+ finally:
+ try:
+ 1 / 0
+ finally:
+ print(x, i, j, 3)
+ break
+ finally:
+ print(x, i, j, 4)
+ break
+print(foo(4))
diff --git a/tests/basics/try_finally_continue.py b/tests/basics/try_finally_continue.py
new file mode 100644
index 000000000..50040e5de
--- /dev/null
+++ b/tests/basics/try_finally_continue.py
@@ -0,0 +1,17 @@
+def foo(x):
+ for i in range(x):
+ try:
+ pass
+ finally:
+ try:
+ try:
+ print(x, i)
+ finally:
+ try:
+ 1 / 0
+ finally:
+ return 42
+ finally:
+ print('continue')
+ continue
+print(foo(4))
diff --git a/tests/basics/try_finally_continue.py.exp b/tests/basics/try_finally_continue.py.exp
new file mode 100644
index 000000000..2901997b1
--- /dev/null
+++ b/tests/basics/try_finally_continue.py.exp
@@ -0,0 +1,9 @@
+4 0
+continue
+4 1
+continue
+4 2
+continue
+4 3
+continue
+None
diff --git a/tests/basics/try_finally_return5.py b/tests/basics/try_finally_return5.py
new file mode 100644
index 000000000..aa2327e65
--- /dev/null
+++ b/tests/basics/try_finally_return5.py
@@ -0,0 +1,17 @@
+def foo(x):
+ for i in range(x):
+ try:
+ pass
+ finally:
+ try:
+ try:
+ print(x, i)
+ finally:
+ try:
+ 1 / 0
+ finally:
+ return 42
+ finally:
+ print('return')
+ return 43
+print(foo(4))