summary refs log tree commit diff stats
path: root/tests/patterns
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2012-09-10 19:34:16 +0200
committerAraq <rumpf_a@web.de>2012-09-10 19:34:16 +0200
commit92b449562e4815b69b07e74a4f37ff38e27c6a3d (patch)
tree1d8791285b2fd9a7e5c416bdf8d5f0e798f90510 /tests/patterns
parent6d94e4590244fe6174181ca4d0928a06d5c6a257 (diff)
downloadNim-92b449562e4815b69b07e74a4f37ff38e27c6a3d.tar.gz
tr macros now documented
Diffstat (limited to 'tests/patterns')
-rw-r--r--tests/patterns/tmatrix.nim7
-rw-r--r--tests/patterns/tor.nim11
-rw-r--r--tests/patterns/tstar.nim2
3 files changed, 16 insertions, 4 deletions
diff --git a/tests/patterns/tmatrix.nim b/tests/patterns/tmatrix.nim
index 1d411ad25..c825a7792 100644
--- a/tests/patterns/tmatrix.nim
+++ b/tests/patterns/tmatrix.nim
@@ -12,11 +12,12 @@ proc `*`(a, b: TMat): TMat = nil
 proc `+`(a, b: TMat): TMat = nil
 proc `-`(a, b: TMat): TMat = nil
 proc `$`(a: TMat): string = result = $a.dummy
-proc mat32(): TMat =
+proc mat21(): TMat =
   result.dummy = 21
 
-macro optOps{ (`+`|`-`|`*`) *| a }(a: TMat): expr =
-  result = newCall(bindSym"mat32")
+macro optOps{ (`+`|`-`|`*`) ** a }(a: TMat): expr =
+  echo treeRepr(a)
+  result = newCall(bindSym"mat21")
 
 #macro optPlus{ `+` * a }(a: varargs[TMat]): expr =
 #  result = newIntLitNode(21)
diff --git a/tests/patterns/tor.nim b/tests/patterns/tor.nim
index 304e1c692..92ef96925 100644
--- a/tests/patterns/tor.nim
+++ b/tests/patterns/tor.nim
@@ -7,3 +7,14 @@ template testOr{ (arithOps{f})(a, b) }(a, b, f: expr): expr = f(a+1, b)
 
 let xx = 10
 echo 10*xx
+
+template t{x = (~x){y} and (~x){z}}(x, y, z: bool): stmt =
+  x = y
+  if x: x = z
+
+var
+  a = true
+  b = true
+  c = false
+a = b and a
+echo a
diff --git a/tests/patterns/tstar.nim b/tests/patterns/tstar.nim
index ac3373214..8443268f4 100644
--- a/tests/patterns/tstar.nim
+++ b/tests/patterns/tstar.nim
@@ -10,7 +10,7 @@ proc `&&`(s: varargs[string]): string =
   for i in 1..len(s)-1: result.add s[i]
   inc calls
 
-template optConc{ `&&` * a }(a: varargs[string]): expr = &&a
+template optConc{ `&&` * a }(a: string): expr = &&a
 
 let space = " "
 echo "my" && (space & "awe" && "some " ) && "concat"