got rid of 'accept' dir in the tests

This commit is contained in:
Araq 2011-11-19 15:45:51 +01:00
commit a274f3bf5b
264 changed files with 5 additions and 7 deletions

29
tests/run/tmultim1.nim Executable file
View file

@ -0,0 +1,29 @@
discard """
file: "tmultim1.nim"
output: "7"
"""
# 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