summary refs log tree commit diff stats
path: root/tests/run
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2012-08-30 22:55:32 +0200
committerAraq <rumpf_a@web.de>2012-08-30 22:55:32 +0200
commit1d14cb1ad8d4d98ea19daa2d5ab6ded59d58553a (patch)
treec32929ff723358f440415d7610fd283f58f17a91 /tests/run
parent1786e3099141f6548e9f6cd4f4998d32f602b71d (diff)
downloadNim-1d14cb1ad8d4d98ea19daa2d5ab6ded59d58553a.tar.gz
next steps towards term rewriting macros; simple examples work
Diffstat (limited to 'tests/run')
-rw-r--r--tests/run/tpatterns.nim17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/run/tpatterns.nim b/tests/run/tpatterns.nim
new file mode 100644
index 000000000..4a83d167c
--- /dev/null
+++ b/tests/run/tpatterns.nim
@@ -0,0 +1,17 @@
+discard """
+  output: '''48
+hel'''
+"""
+
+template optZero{x+x}(x: int): int = x*3
+template andthen{x*3}(x: int): int = x*4
+template optSubstr1{x = substr(x, a, b)}(x: string, a, b: int) = setlen(x, b+1)
+
+var y = 12
+echo y+y
+
+var s: array[0..2, string]
+s[0] = "hello"
+s[0] = substr(s[0], 0, 2)
+
+echo s[0]