Fix fail proc
This commit is contained in:
@@ -13,5 +13,5 @@ proc ok*[T](val: T): OI[T] =
|
||||
proc fail*(oi: OI, msg: string): OI =
|
||||
OI(isOK: false, error: msg)
|
||||
|
||||
proc fail*(msg: string): OI[auto] =
|
||||
OI[auto](isOK: false, error: msg)
|
||||
proc fail*[T](msg: string): OI[T] =
|
||||
OI[T](isOK: false, error: msg)
|
||||
|
||||
@@ -8,7 +8,7 @@ test "Check OK":
|
||||
check test.isOk == true
|
||||
|
||||
test "Check fail":
|
||||
let test = fail "no data here"
|
||||
let test = oi.fail[int] "no data here"
|
||||
check test.isOk == false
|
||||
|
||||
test "Check proc results":
|
||||
@@ -31,7 +31,7 @@ test "Check changing result":
|
||||
proc checker(): OI[int] =
|
||||
result = ok 42
|
||||
# something happend here
|
||||
result = fail "data got corrupted"
|
||||
result = result.fail "data got corrupted"
|
||||
|
||||
let data = checker()
|
||||
check data.isOk == false
|
||||
|
||||
Reference in New Issue
Block a user