add a test for `results.?` compatibility (#484)

Finally! (haha)
This commit is contained in:
Jacek Sieka 2023-12-21 15:52:16 +01:00 committed by GitHub
parent c41599a6d6
commit 1598471ed2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 0 deletions

View File

@ -555,3 +555,27 @@ suite "Exceptions tracking":
await raiseException()
waitFor(callCatchAll())
test "Results compatibility":
proc returnOk(): Future[Result[int, string]] {.async: (raises: []).} =
ok(42)
proc returnErr(): Future[Result[int, string]] {.async: (raises: []).} =
err("failed")
proc testit(): Future[Result[void, string]] {.async: (raises: []).} =
let
v = await returnOk()
check:
v.isOk() and v.value() == 42
let
vok = ?v
check:
vok == 42
discard ?await returnErr()
check:
waitFor(testit()).error() == "failed"