diff options
author | Araq <rumpf_a@web.de> | 2012-09-06 00:23:55 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2012-09-06 00:23:55 +0200 |
commit | 355ae07b8f3362af4e90770477d344dcd2fef594 (patch) | |
tree | 05fa0093a4b83fc9cfe89d4ec9c64654efd8ce74 /tests/patterns | |
parent | 30c00aba07cd8b86dc935209bcad74558bae26ad (diff) | |
download | Nim-355ae07b8f3362af4e90770477d344dcd2fef594.tar.gz |
activated tests for tr macros
Diffstat (limited to 'tests/patterns')
-rw-r--r-- | tests/patterns/tcse.nim | 13 | ||||
-rw-r--r-- | tests/patterns/tnoalias.nim | 16 | ||||
-rw-r--r-- | tests/patterns/tstmtlist.nim | 3 |
3 files changed, 31 insertions, 1 deletions
diff --git a/tests/patterns/tcse.nim b/tests/patterns/tcse.nim new file mode 100644 index 000000000..ff04f7d83 --- /dev/null +++ b/tests/patterns/tcse.nim @@ -0,0 +1,13 @@ +discard """ + output: "4" +""" + +template cse{f(a, a, x)}(a: expr{(nkDotExpr|call|nkBracketExpr)&noSideEffect}, + f: expr, x: varargs[expr]): expr = + let aa = a + f(aa, aa, x)+4 + +var + a: array[0..10, int] + i = 3 +echo a[i] + a[i] diff --git a/tests/patterns/tnoalias.nim b/tests/patterns/tnoalias.nim new file mode 100644 index 000000000..1d5671362 --- /dev/null +++ b/tests/patterns/tnoalias.nim @@ -0,0 +1,16 @@ +discard """ + output: "23" +""" + +template optslice{a = b + c}(a: expr{noalias}, b, c: expr): stmt = + a = b + inc a, c + +var + x = 12 + y = 10 + z = 13 + +x = y+z + +echo x diff --git a/tests/patterns/tstmtlist.nim b/tests/patterns/tstmtlist.nim index 138384227..20cb5d688 100644 --- a/tests/patterns/tstmtlist.nim +++ b/tests/patterns/tstmtlist.nim @@ -1,6 +1,7 @@ discard """ output: '''0 -|12|34 +|12| +34 ''' """ |