diff options
author | Audun Wilhelmsen <skyfex@gmail.com> | 2014-02-23 00:20:16 +0100 |
---|---|---|
committer | Audun Wilhelmsen <skyfex@gmail.com> | 2014-02-23 00:20:16 +0100 |
commit | ef379d0a10e800982d4a10ad623d2426d68e830d (patch) | |
tree | b382c7cbc5eeb10875706d0db81d583c7e5f2bea /tests | |
parent | 66675d174b044c7e63cabfce1a235702f1da64aa (diff) | |
download | Nim-ef379d0a10e800982d4a10ad623d2426d68e830d.tar.gz |
Added test cases for return in except statements.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/exception/tnestedreturn.nim | 40 | ||||
-rw-r--r-- | tests/exception/tnestedreturn2.nim | 20 |
2 files changed, 60 insertions, 0 deletions
diff --git a/tests/exception/tnestedreturn.nim b/tests/exception/tnestedreturn.nim new file mode 100644 index 000000000..b9f7843f6 --- /dev/null +++ b/tests/exception/tnestedreturn.nim @@ -0,0 +1,40 @@ +discard """ + file: "tnestedreturn.nim" + output: "A\nB\nC\n" +""" + +# Various tests of return nested in double try/except statements + +proc test1() = + + finally: echo "A" + + try: + raise newException(EOS, "Problem") + except EOS: + return + +test1() + + +proc test2() = + + finally: echo "B" + + try: + return + except EOS: + discard + +test2() + +proc test3() = + try: + try: + raise newException(EOS, "Problem") + except EOS: + return + finally: + echo "C" + +test3() diff --git a/tests/exception/tnestedreturn2.nim b/tests/exception/tnestedreturn2.nim new file mode 100644 index 000000000..14a2dab92 --- /dev/null +++ b/tests/exception/tnestedreturn2.nim @@ -0,0 +1,20 @@ +discard """ + file: "tnestedreturn.nim" + outputsub: "Error: unhandled exception: Problem [EOS]" + exitcode: "1" +""" + +proc test4() = + try: + try: + raise newException(EOS, "Problem") + except EOS: + return + finally: + discard + +# Should cause unhandled exception error, +# but could cause segmentation fault if +# exceptions are not handled properly. +test4() +raise newException(EOS, "Problem") |