diff options
Diffstat (limited to 'tests/async')
-rw-r--r-- | tests/async/t6846.nim | 16 | ||||
-rw-r--r-- | tests/async/t7758.nim | 19 | ||||
-rw-r--r-- | tests/async/tfuturevar.nim | 2 |
3 files changed, 36 insertions, 1 deletions
diff --git a/tests/async/t6846.nim b/tests/async/t6846.nim new file mode 100644 index 000000000..687a3f865 --- /dev/null +++ b/tests/async/t6846.nim @@ -0,0 +1,16 @@ +discard """ + exitcode: 0 + output: "hello world" + disabled: windows +""" + +import asyncdispatch +import asyncfile +import times + +var asyncStdout = 1.AsyncFD.newAsyncFile() +proc doStuff: Future[void] {.async.} = + await asyncStdout.write "hello world\n" + +let fut = doStuff() +doAssert fut.finished, "Poll is needed unnecessarily. See #6846." \ No newline at end of file diff --git a/tests/async/t7758.nim b/tests/async/t7758.nim new file mode 100644 index 000000000..102a4ce4c --- /dev/null +++ b/tests/async/t7758.nim @@ -0,0 +1,19 @@ +discard """ + file: "t7758.nim" + exitcode: 0 +""" +import asyncdispatch + +proc task() {.async.} = + await sleepAsync(40) + +proc main() = + var counter = 0 + var f = task() + while not f.finished: + inc(counter) + poll(10) + + doAssert counter <= 4 + +for i in 0 .. 10: main() \ No newline at end of file diff --git a/tests/async/tfuturevar.nim b/tests/async/tfuturevar.nim index 73c0fddf7..ea2c63e03 100644 --- a/tests/async/tfuturevar.nim +++ b/tests/async/tfuturevar.nim @@ -35,7 +35,7 @@ proc main() {.async.} = fut = newFutureVar[string]() let retFut = failureTest(fut, true) yield retFut - doAssert(fut.read().isNil) + doAssert(fut.read().len == 0) doAssert(fut.finished) fut = newFutureVar[string]() |