Added == tests and doc
This commit is contained in:
parent
35fef5c605
commit
aa68f7be50
3 changed files with 35 additions and 9 deletions
|
|
@ -145,9 +145,9 @@ proc defineEquality(tp, body: NimNode): NimNode {. compileTime .} =
|
|||
)
|
||||
|
||||
result = newProc(
|
||||
name = ident("`==`"),
|
||||
name = ident("=="),
|
||||
params = [ident("bool"), newIdentDefs(ident("a"), tp), newIdentDefs(ident("b"), tp)],
|
||||
body = body
|
||||
body = newStmtList(body)
|
||||
)
|
||||
# result = getAst(compare(condition, tp))
|
||||
|
||||
|
|
@ -159,11 +159,6 @@ macro adt*(e: expr, body: stmt): stmt {. immediate .} =
|
|||
when defined(pattydebug):
|
||||
echo toStrLit(result)
|
||||
|
||||
adt Shape:
|
||||
Circle(r: float, x: float, y: float)
|
||||
Rectangle(w: float, h: float)
|
||||
Square(side: int)
|
||||
|
||||
macro match*(e: expr, body: stmt): stmt {. immediate .} =
|
||||
# A fresh symbol used to hold the evaluation of e
|
||||
let sym = genSym()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue