summary refs log tree commit diff stats
path: root/tests/trmacros/tpartial.nim
blob: c636684d7410fb270b1f86bd8ba0a2ab7918980c (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): untyped = x - y
template optP{p(x, y, false)}(x, y): untyped = x + y

echo p(2, 4, true)