diff options
author | Clyybber <darkmine956@gmail.com> | 2020-04-06 16:25:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-06 16:25:24 +0200 |
commit | 92c4aad2059a350e95bc7a64932873b41b085976 (patch) | |
tree | 44875504f0e02d04851cbec909777437d8774e94 /tests/async | |
parent | 1e25e16c8834324006e8ce00e20e6d59e6c5cf6f (diff) | |
download | Nim-92c4aad2059a350e95bc7a64932873b41b085976.tar.gz |
Fix #13889 with testcase (#13896) [backport]
* Fix https://github.com/nim-lang/Nim/issues/13889 * Add testcase * Reduce test time Co-authored-by: Elie Zedeck RANDRIAMIANDRIRAY <elie.zedeck@gmail.com>
Diffstat (limited to 'tests/async')
-rw-r--r-- | tests/async/t13889.nim | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/async/t13889.nim b/tests/async/t13889.nim new file mode 100644 index 000000000..fe75fe38a --- /dev/null +++ b/tests/async/t13889.nim @@ -0,0 +1,27 @@ +discard """ + output: ''' +believer Foo is saved:true +believer Bar is saved:true +believer Baz is saved:true +''' +""" + +import asyncdispatch + +var + promise = newFuture[bool]() + +proc believers(name: string) {.async.} = + let v = await promise + echo "believer " & name & " is saved:" & $v + +asyncCheck believers("Foo") +asyncCheck believers("Bar") +asyncCheck believers("Baz") + +proc savior() {.async.} = + await sleepAsync(50) + complete(promise, true) + await sleepAsync(50) # give enough time to see who was saved + +waitFor(savior()) |