start of tests refactoring; sqlite3 new wrapper fixes
This commit is contained in:
parent
6bc16904ed
commit
d913fdb280
173 changed files with 206 additions and 238 deletions
23
tests/accept/run/tmultim1.nim
Normal file
23
tests/accept/run/tmultim1.nim
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# Test multi methods
|
||||
|
||||
type
|
||||
TExpr = object
|
||||
TLiteral = object of TExpr
|
||||
x: int
|
||||
TPlusExpr = object of TExpr
|
||||
a, b: ref TExpr
|
||||
|
||||
method eval(e: ref TExpr): int = quit "to override!"
|
||||
method eval(e: ref TLiteral): int = return e.x
|
||||
method eval(e: ref TPlusExpr): int = return eval(e.a) + eval(e.b)
|
||||
|
||||
proc newLit(x: int): ref TLiteral =
|
||||
new(result)
|
||||
result.x = x
|
||||
|
||||
proc newPlus(a, b: ref TExpr): ref TPlusExpr =
|
||||
new(result)
|
||||
result.a = a
|
||||
result.b = b
|
||||
|
||||
echo eval(newPlus(newPlus(newLit(1), newLit(2)), newLit(4))) #OUT 7
|
||||
Loading…
Add table
Add a link
Reference in a new issue