mirror of
https://github.com/nim-lang/Nim.git
synced 2026-07-20 16:01:29 +00:00
activated tests for tr macros
This commit is contained in:
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
|
||||
'''
|
||||
"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user