Async await try statement fixes.

This commit is contained in:
Dominik Picheta 2015-02-09 23:00:07 +00:00
commit 03019849fc
3 changed files with 89 additions and 11 deletions

View file

@ -19,7 +19,6 @@ proc processClient(fd: int) {.async.} =
var foo = line[0]
if foo == 'g':
raise newException(EBase, "foobar")
proc serve() {.async.} =

View file

@ -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