summary refs log tree commit diff stats
path: root/tests/patterns/tpartial.nim
diff options
context:
space:
mode:
authorZahary Karadjov <zahary@gmail.com>2013-01-27 23:41:45 +0200
committerZahary Karadjov <zahary@gmail.com>2013-01-27 23:41:45 +0200
commit81a3585872b1a327b62ba528addbee913d6bbe5a (patch)
treeaff8358bc86704edbd89fd56ec4f7b0cd3583bca /tests/patterns/tpartial.nim
parent67f37264b3f461fe46f5cfea7c35c0a4f709dcb0 (diff)
parent07585088955c1fe8fb815c40409ed9f5d66fd446 (diff)
downloadNim-81a3585872b1a327b62ba528addbee913d6bbe5a.tar.gz
merged upstream master
Diffstat (limited to 'tests/patterns/tpartial.nim')
-rw-r--r--tests/patterns/tpartial.nim11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/patterns/tpartial.nim b/tests/patterns/tpartial.nim
new file mode 100644
index 000000000..fdaa3414a
--- /dev/null
+++ b/tests/patterns/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)