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