Added == tests and doc

This commit is contained in:
Andrea Ferretti 2015-07-04 15:01:43 +02:00
commit aa68f7be50
3 changed files with 35 additions and 9 deletions

View file

@ -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()