diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2023-05-17 06:02:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-17 06:02:11 +0200 |
commit | 1314ea75169b877f458e8b4eb1455d5f6428227b (patch) | |
tree | 8cda1978c0227ff5a9f840d2d4f7ce4be015275f /tests/stdlib/ttasks.nim | |
parent | f22e5067c5e0f375cb2263ec779d6e6ede108155 (diff) | |
download | Nim-1314ea75169b877f458e8b4eb1455d5f6428227b.tar.gz |
tasks that support return values (#21859)
tasks.nim: Code cleanups and support expressions that produce a value
Diffstat (limited to 'tests/stdlib/ttasks.nim')
-rw-r--r-- | tests/stdlib/ttasks.nim | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/stdlib/ttasks.nim b/tests/stdlib/ttasks.nim index 4889d49d9..347c3347a 100644 --- a/tests/stdlib/ttasks.nim +++ b/tests/stdlib/ttasks.nim @@ -505,3 +505,21 @@ block: b.invoke() doAssert called == 36 + + block: + proc returnsSomething(a, b: int): int = a + b + + proc noArgsButReturnsSomething(): string = "abcdef" + + proc testReturnValues() = + let t = toTask returnsSomething(2233, 11) + var res: int + t.invoke(addr res) + doAssert res == 2233+11 + + let tb = toTask noArgsButReturnsSomething() + var resB: string + tb.invoke(addr resB) + doAssert resB == "abcdef" + + testReturnValues() |