diff options
Diffstat (limited to 'tests/async/tasynctry.nim')
-rw-r--r-- | tests/async/tasynctry.nim | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/async/tasynctry.nim b/tests/async/tasynctry.nim index 66ea40d49..99433b9d8 100644 --- a/tests/async/tasynctry.nim +++ b/tests/async/tasynctry.nim @@ -49,3 +49,44 @@ proc catch() {.async.} = assert false asyncCheck catch() + +proc test(): Future[bool] {.async.} = + result = false + try: + raise newException(OSError, "Foobar") + except: + result = true + return + +proc foo(): Future[bool] {.async.} = discard + +proc test2(): Future[bool] {.async.} = + result = false + try: + discard await foo() + raise newException(OSError, "Foobar") + except: + result = true + return + +proc test3(): Future[int] {.async.} = + result = 0 + try: + try: + discard await foo() + raise newException(OSError, "Hello") + except: + result = 1 + raise + except: + result = 2 + return + +var x = test() +assert x.read + +x = test2() +assert x.read + +var y = test3() +assert y.read == 2 |