diff options
Diffstat (limited to 'tests/exception/tfinally.nim')
-rw-r--r-- | tests/exception/tfinally.nim | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/tests/exception/tfinally.nim b/tests/exception/tfinally.nim new file mode 100644 index 000000000..c5b1dd841 --- /dev/null +++ b/tests/exception/tfinally.nim @@ -0,0 +1,62 @@ +discard """ + output: ''' +came +here +3 +msg1 +msg2 +finally2 +finally1 +----------- +except1 +finally1 +except2 +finally2 +''' +""" +# Test return in try statement: + +proc main: int = + try: + try: + return 1 + finally: + echo("came") + return 2 + finally: + echo("here") + return 3 + +echo main() #OUT came here 3 + +#bug 7204 +proc nested_finally = + try: + raise newException(KeyError, "msg1") + except KeyError as ex: + echo ex.msg + try: + raise newException(ValueError, "msg2") + except: + echo getCurrentExceptionMsg() + finally: + echo "finally2" + finally: + echo "finally1" + +nested_finally() + +echo "-----------" +#bug 7414 +try: + try: + raise newException(Exception, "Hello") + except: + echo "except1" + raise + finally: + echo "finally1" +except: + echo "except2" +finally: + echo "finally2" |