activated tests for tr macros
This commit is contained in:
parent
30c00aba07
commit
355ae07b8f
7 changed files with 62 additions and 24 deletions
13
tests/patterns/tcse.nim
Normal file
13
tests/patterns/tcse.nim
Normal file
|
|
@ -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]
|
||||
16
tests/patterns/tnoalias.nim
Normal file
16
tests/patterns/tnoalias.nim
Normal file
|
|
@ -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
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
discard """
|
||||
output: '''0
|
||||
|12|34
|
||||
|12|
|
||||
34
|
||||
'''
|
||||
"""
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue