Async await try statement fixes.
This commit is contained in:
parent
703633bf0c
commit
03019849fc
3 changed files with 89 additions and 11 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue