diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2020-11-02 14:17:09 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-02 14:17:09 +0100 |
commit | dfd8a83f3557164fd41714c11c6f92b65eef9018 (patch) | |
tree | aa0fcff8f308e8b59137d28dd9e72f4883a69664 /tests | |
parent | eb429988cd15555f2af35389d52256b06e00e900 (diff) | |
download | Nim-dfd8a83f3557164fd41714c11c6f92b65eef9018.tar.gz |
fixes #15804 (#15820)
* fixes #15804 * fix the existing test * add the testcase for #15804 Co-authored-by: narimiran <narimiran@disroot.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/async/t15804.nim | 15 | ||||
-rw-r--r-- | tests/async/tasync_noasync.nim | 6 |
2 files changed, 18 insertions, 3 deletions
diff --git a/tests/async/t15804.nim b/tests/async/t15804.nim new file mode 100644 index 000000000..8de012196 --- /dev/null +++ b/tests/async/t15804.nim @@ -0,0 +1,15 @@ +import asyncdispatch + +type + Foo*[E] = ref object + op: proc(): Future[bool] {.gcsafe.} + +proc newFoo*[E](): Foo[E] = + result = Foo[E]() + result.op = proc(): Future[bool] {.gcsafe,async.} = + await sleepAsync(100) + result = false + +when isMainModule: + let f = newFoo[int]() + echo waitFor f.op() diff --git a/tests/async/tasync_noasync.nim b/tests/async/tasync_noasync.nim index 812b40da6..54f4f597f 100644 --- a/tests/async/tasync_noasync.nim +++ b/tests/async/tasync_noasync.nim @@ -1,7 +1,7 @@ discard """ - errormsg: "undeclared identifier: 'await'" + errormsg: "'yield' only allowed in an iterator" cmd: "nim c $file" - file: "tasync_noasync.nim" + file: "asyncmacro.nim" """ import async @@ -12,4 +12,4 @@ await a() # if we overload a fallback handler to get # await only available within {.async.} -# we would need `{.dirty.}` templates for await \ No newline at end of file +# we would need `{.dirty.}` templates for await |