Fix Nim's issue #13889 https://github.com/nim-lang/Nim/issues/13889. (#90)
This commit is contained in:
parent
4e2810cfe0
commit
3d745a4b0c
|
@ -47,9 +47,7 @@ template createCb(retFutureSym, iteratorNameSym,
|
|||
raise newException(AssertionError, msg % strName)
|
||||
else:
|
||||
{.gcsafe.}:
|
||||
{.push hint[ConvFromXtoItselfNotNeeded]: off.}
|
||||
next.callback = identName
|
||||
{.pop.}
|
||||
next.addCallback(identName)
|
||||
except CancelledError:
|
||||
retFutureSym.cancel()
|
||||
except CatchableError as exc:
|
||||
|
|
|
@ -56,6 +56,23 @@ suite "Asynchronous issues test suite":
|
|||
discard await withTimeout(sleepAsync(4.milliseconds), 4.milliseconds)
|
||||
result = true
|
||||
|
||||
proc testMultipleAwait(): Future[bool] {.async.} =
|
||||
var promise = newFuture[void]()
|
||||
var checkstr = ""
|
||||
|
||||
proc believers(name: string) {.async.} =
|
||||
await promise
|
||||
checkstr = checkstr & name
|
||||
|
||||
asyncCheck believers("Foo")
|
||||
asyncCheck believers("Bar")
|
||||
asyncCheck believers("Baz")
|
||||
|
||||
await sleepAsync(100.milliseconds)
|
||||
promise.complete()
|
||||
await sleepAsync(100.milliseconds)
|
||||
result = (checkstr == "FooBarBaz")
|
||||
|
||||
test "Issue #6":
|
||||
check waitFor(issue6()) == true
|
||||
|
||||
|
@ -64,3 +81,6 @@ suite "Asynchronous issues test suite":
|
|||
|
||||
test "Callback-race double completion [withTimeout()] test":
|
||||
check waitFor(testWithTimeout()) == true
|
||||
|
||||
test "Multiple await on single future test [Nim's issue #13889]":
|
||||
check waitFor(testMultipleAwait()) == true
|
||||
|
|
Loading…
Reference in New Issue