diff options
Diffstat (limited to 'tests/async/tasync_misc.nim')
-rw-r--r-- | tests/async/tasync_misc.nim | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/tests/async/tasync_misc.nim b/tests/async/tasync_misc.nim index 1febdedb3..ec1418e8c 100644 --- a/tests/async/tasync_misc.nim +++ b/tests/async/tasync_misc.nim @@ -1,19 +1,14 @@ -discard """ - exitcode: 0 - output: "ok" -""" - import json, asyncdispatch block: #6100 let done = newFuture[int]() done.complete(1) proc asyncSum: Future[int] {.async.} = - for _ in 1..10_000_000: + for _ in 1..1_000_000: result += await done let res = waitFor asyncSum() - doAssert(res == 10000000) + doAssert(res == 1_000_000) block: #7985 proc getData(): Future[JsonNode] {.async.} = @@ -53,4 +48,36 @@ block: # nkCheckedFieldExpr waitFor foo() -echo "ok" +block: # 12743 + + template templ = await sleepAsync 0 + + proc prc {.async.} = templ + + waitFor prc() + +block: # issue #13899 + proc someConnect() {.async.} = + await sleepAsync(1) + proc someClose() {.async.} = + await sleepAsync(2) + proc testFooFails(): Future[bool] {.async.} = + await someConnect() + defer: + await someClose() + result = true + proc testFooSucceed(): Future[bool] {.async.} = + try: + await someConnect() + finally: + await someClose() + result = true + doAssert waitFor testFooSucceed() + doAssert waitFor testFooFails() + +block: # issue #9313 + doAssert compiles(block: + proc a() {.async.} = + echo "Hi" + quit(0) + ) |