t7758.nim 454 B

12345678910111213141516171819202122
  1. import asyncdispatch
  2. import std/unittest
  3. proc task() {.async.} =
  4. const tSleep = 40
  5. await sleepAsync(tSleep)
  6. proc main() =
  7. var counter = 0
  8. var f = task()
  9. while not f.finished:
  10. inc(counter)
  11. poll(10)
  12. const slack = 1
  13. # because there is overhead in `async` + `sleepAsync`
  14. # as can be seen by increasing `tSleep` from 40 to 49, which increases the number
  15. # of failures.
  16. check counter <= 4 + slack
  17. for i in 0 .. 10: main()