Skip to content

Commit

Permalink
restore 1.2 compat in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
arnetheduck committed Feb 19, 2024
1 parent 61f1448 commit 9c933d3
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions tests/test_results.nim
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,18 @@ block:

# Exception on access
doAssert (
try:
(discard rOk.tryError(); false)
except ResultError[int]:
true
block:
try:
(discard rOk.tryError(); false)
except ResultError[int]:
true
)
doAssert (
try:
(discard rErr.tryGet(); false)
except ResultError[string]:
true
block:
try:
(discard rErr.tryGet(); false)
except ResultError[string]:
true
)

# Value access or default
Expand Down Expand Up @@ -591,13 +593,11 @@ block: # `cstring` dangling reference protection
block: # Experiments
# Can formalise it into a template (https://github.com/arnetheduck/nim-result/issues/8)
template `?=`(v: untyped{nkIdent}, vv: Result): bool =
(
let vr = vv
template v(): auto {.used.} =
unsafeGet(vr)
let vr = vv
template v(): auto {.used.} =
unsafeGet(vr)

vr.isOk
)
vr.isOk

if f ?= Result[int, string].ok(42):
doAssert f == 42
Expand Down

0 comments on commit 9c933d3

Please sign in to comment.