2019-10-23 02:20:06 +00:00
|
|
|
# this is some template to help mimicking unittest at compile time
|
|
|
|
# perhaps we can implement a real compile time unittest?
|
|
|
|
|
|
|
|
template ctCheck*(cond: untyped) =
|
|
|
|
doAssert(cond)
|
|
|
|
|
|
|
|
template ctTest*(name: string, body: untyped) =
|
2023-06-13 12:03:43 +00:00
|
|
|
block:
|
|
|
|
body
|
|
|
|
echo "[OK] compile time ", name
|
2023-06-14 15:26:44 +00:00
|
|
|
|
|
|
|
template ctExpect*(errTypes, body: untyped) =
|
|
|
|
try:
|
|
|
|
body
|
|
|
|
except errTypes:
|
|
|
|
discard
|
|
|
|
except CatchableError:
|
|
|
|
doAssert(false, "unexpected error")
|
|
|
|
except Defect:
|
|
|
|
doAssert(false, "unexpected defect")
|