parent
9379f9353a
commit
2094209837
4 changed files with 48 additions and 35 deletions
|
|
@ -588,7 +588,7 @@ proc lowerStmtListExprs(ctx: var Ctx, n: PNode, needsSplit: var bool): PNode =
|
||||||
let branch = n[i]
|
let branch = n[i]
|
||||||
case branch.kind
|
case branch.kind
|
||||||
of nkOfBranch:
|
of nkOfBranch:
|
||||||
branch[1] = ctx.convertExprBodyToAsgn(branch[1], tmp)
|
branch[^1] = ctx.convertExprBodyToAsgn(branch[^1], tmp)
|
||||||
of nkElse:
|
of nkElse:
|
||||||
branch[0] = ctx.convertExprBodyToAsgn(branch[0], tmp)
|
branch[0] = ctx.convertExprBodyToAsgn(branch[0], tmp)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
discard """
|
|
||||||
file: "t6100.nim"
|
|
||||||
exitcode: 0
|
|
||||||
output: "10000000"
|
|
||||||
"""
|
|
||||||
import asyncdispatch
|
|
||||||
|
|
||||||
let done = newFuture[int]()
|
|
||||||
done.complete(1)
|
|
||||||
|
|
||||||
proc asyncSum: Future[int] {.async.} =
|
|
||||||
for _ in 1..10_000_000:
|
|
||||||
result += await done
|
|
||||||
|
|
||||||
echo waitFor asyncSum()
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
discard """
|
|
||||||
file: "t7985.nim"
|
|
||||||
exitcode: 0
|
|
||||||
output: "(value: 1)"
|
|
||||||
"""
|
|
||||||
import json, asyncdispatch
|
|
||||||
|
|
||||||
proc getData(): Future[JsonNode] {.async.} =
|
|
||||||
result = %*{"value": 1}
|
|
||||||
|
|
||||||
type
|
|
||||||
MyData = object
|
|
||||||
value: BiggestInt
|
|
||||||
|
|
||||||
proc main() {.async.} =
|
|
||||||
let data = to(await(getData()), MyData)
|
|
||||||
echo data
|
|
||||||
|
|
||||||
waitFor(main())
|
|
||||||
47
tests/async/tasync_misc.nim
Normal file
47
tests/async/tasync_misc.nim
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
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:
|
||||||
|
result += await done
|
||||||
|
|
||||||
|
let res = waitFor asyncSum()
|
||||||
|
doAssert(res == 10000000)
|
||||||
|
|
||||||
|
block: #7985
|
||||||
|
proc getData(): Future[JsonNode] {.async.} =
|
||||||
|
result = %*{"value": 1}
|
||||||
|
|
||||||
|
type
|
||||||
|
MyData = object
|
||||||
|
value: BiggestInt
|
||||||
|
|
||||||
|
proc main() {.async.} =
|
||||||
|
let data = to(await(getData()), MyData)
|
||||||
|
doAssert($data == "(value: 1)")
|
||||||
|
|
||||||
|
waitFor(main())
|
||||||
|
|
||||||
|
block: #8399
|
||||||
|
proc bar(): Future[string] {.async.} = discard
|
||||||
|
|
||||||
|
proc foo(line: string) {.async.} =
|
||||||
|
var res =
|
||||||
|
case line[0]
|
||||||
|
of '+', '-': @[]
|
||||||
|
of '$': (let x = await bar(); @[""])
|
||||||
|
else:
|
||||||
|
nil
|
||||||
|
|
||||||
|
doAssert(res == @[""])
|
||||||
|
|
||||||
|
waitFor foo("$asd")
|
||||||
|
|
||||||
|
echo "ok"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue