summary refs log tree commit diff stats
path: root/tests/patterns/tpartial.nim
blob: fdaa3414a2b9bdcaebf214ef9d38eb46b9015f63 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
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)