summary refs log tree commit diff stats
path: root/tests/async
diff options
context:
space:
mode:
authorDominik Picheta <dominikpicheta@gmail.com>2017-12-22 21:14:27 +0000
committerDominik Picheta <dominikpicheta@gmail.com>2017-12-27 22:37:11 +0000
commit52cc925e0e34580403b1a405ec8b4fa44c844de5 (patch)
treeef96f547e0d8975133a1ad1a0373285bbe9ab45e /tests/async
parent7937e38423ee77100d99e84d4710edd6d9ec93ec (diff)
downloadNim-52cc925e0e34580403b1a405ec8b4fa44c844de5.tar.gz
Fixes #6100.
Diffstat (limited to 'tests/async')
-rw-r--r--tests/async/t6100.nim15
-rw-r--r--tests/async/tfuturestream.nim2
2 files changed, 16 insertions, 1 deletions
diff --git a/tests/async/t6100.nim b/tests/async/t6100.nim
new file mode 100644
index 000000000..b4dc0f146
--- /dev/null
+++ b/tests/async/t6100.nim
@@ -0,0 +1,15 @@
+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()
\ No newline at end of file
diff --git a/tests/async/tfuturestream.nim b/tests/async/tfuturestream.nim
index 9a8e986a0..d76752b7e 100644
--- a/tests/async/tfuturestream.nim
+++ b/tests/async/tfuturestream.nim
@@ -18,8 +18,8 @@ var fs = newFutureStream[int]()
 
 proc alpha() {.async.} =
   for i in 0 .. 5:
-    await sleepAsync(1000)
     await fs.write(i)
+    await sleepAsync(1000)
 
   echo("Done")
   fs.complete()