diff options
Diffstat (limited to 'tests/trmacros/tpartial.nim')
-rw-r--r-- | tests/trmacros/tpartial.nim | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/trmacros/tpartial.nim b/tests/trmacros/tpartial.nim new file mode 100644 index 000000000..fdaa3414a --- /dev/null +++ b/tests/trmacros/tpartial.nim @@ -0,0 +1,11 @@ +discard """ + output: '''-2''' +""" + +proc p(x, y: int; cond: bool): int = + result = if cond: x + y else: x - y + +template optP{p(x, y, true)}(x, y: expr): expr = x - y +template optP{p(x, y, false)}(x, y: expr): expr = x + y + +echo p(2, 4, true) |