diff options
Diffstat (limited to 'tests/parser/tprecedence.nim')
-rw-r--r-- | tests/parser/tprecedence.nim | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/tests/parser/tprecedence.nim b/tests/parser/tprecedence.nim new file mode 100644 index 000000000..9be79543b --- /dev/null +++ b/tests/parser/tprecedence.nim @@ -0,0 +1,63 @@ +discard """ + output: '''holla +true +defabc 4 +0''' +""" + +# Test top level semicolon works properly: +import os; echo "holla" + +# Test the new predence rules + +proc `\+` (x, y: int): int = result = x + y +proc `\*` (x, y: int): int = result = x * y + +echo 5 \+ 1 \* 9 == 6*9 + +proc foo[S, T](x: S, y: T): T = x & y + +proc bar[T](x: T): T = x + +echo "def".foo[:string, string]("abc"), " ", 4.bar[:int] + +# bug #9574 +proc isFalse(a: int): bool = false + +assert not isFalse(3) + +# bug #9633 + +type + MyField = object + b: seq[string] + + MyObject = object + f: MyField + +proc getX(x: MyObject): lent MyField {.inline.} = + x.f + +let a = MyObject() +echo a.getX.b.len + + +# bug #10458 +template t(x: untyped): untyped = "x" + +let + aaa = t 2 + 4 + ccc = t (1, 1) + 6 + ddd = t [0, 1, 2] + 5 + +# bug #10896 +const + test = + proc(): int = 1 + +# bug #8759 +block: + template `=>`(a, b): untyped = (a, b) + template `+=`(a, b): untyped = a * b + + doAssert ("abc" => 3 += 5) == ("abc", 15) |