diff options
author | Daniil Yarancev <21169548+Yardanico@users.noreply.github.com> | 2018-01-07 21:02:00 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-07 21:02:00 +0300 |
commit | fb44c522e6173528efa8035ecc459c84887d0167 (patch) | |
tree | a2f5e98606be265981a5f72748896967033e23d7 /tests/async/tasyncall.nim | |
parent | ccf99fa5ce4fe992fb80dc89271faa51456c3fa5 (diff) | |
parent | e23ea64c41e101d4e1d933f0b015f51cc6c2f7de (diff) | |
download | Nim-fb44c522e6173528efa8035ecc459c84887d0167.tar.gz |
Merge pull request #1 from nim-lang/devel
upstream
Diffstat (limited to 'tests/async/tasyncall.nim')
-rw-r--r-- | tests/async/tasyncall.nim | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/tests/async/tasyncall.nim b/tests/async/tasyncall.nim index 7daecd9ef..775dd0c6f 100644 --- a/tests/async/tasyncall.nim +++ b/tests/async/tasyncall.nim @@ -40,8 +40,17 @@ proc testVarargs(x, y, z: int): seq[int] = result = waitFor all(a, b, c) -suite "tasyncall": - test "testFuturesWithValue": +proc testWithDupes() = + var + tasks = newSeq[Future[void]](taskCount) + fut = futureWithoutValue() + + for i in 0..<taskCount: + tasks[i] = fut + + waitFor all(tasks) + +block: let startTime = cpuTime() results = testFuturesWithValue(42) @@ -51,14 +60,21 @@ suite "tasyncall": doAssert execTime * 1000 < taskCount * sleepDuration doAssert results == expected - test "testFuturesWithoutValues": +block: let startTime = cpuTime() testFuturesWithoutValues() let execTime = cpuTime() - startTime doAssert execTime * 1000 < taskCount * sleepDuration - test "testVarargs": +block: + let startTime = cpuTime() + testWithDupes() + let execTime = cpuTime() - startTime + + doAssert execTime * 1000 < taskCount * sleepDuration + +block: let startTime = cpuTime() results = testVarargs(1, 2, 3) @@ -68,7 +84,7 @@ suite "tasyncall": doAssert execTime * 100 < taskCount * sleepDuration doAssert results == expected - test "all on seq[Future]": +block: let noIntFuturesFut = all(newSeq[Future[int]]()) noVoidFuturesFut = all(newSeq[Future[void]]()) |