diff options
Diffstat (limited to 'tests/trmacros/tpatterns.nim')
-rw-r--r-- | tests/trmacros/tpatterns.nim | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/trmacros/tpatterns.nim b/tests/trmacros/tpatterns.nim new file mode 100644 index 000000000..6bc8772e3 --- /dev/null +++ b/tests/trmacros/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] |