diff options
author | Araq <rumpf_a@web.de> | 2014-04-06 22:05:42 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2014-04-06 22:05:42 +0200 |
commit | 7c065bfadf472bd569773c98a50b8986136afb43 (patch) | |
tree | 6054ad79c3e442931d9280e011bad91a64735ced /tests/patterns | |
parent | 5d6053173a0db2b4d0dd1c334c41075fe8d9850e (diff) | |
download | Nim-7c065bfadf472bd569773c98a50b8986136afb43.tar.gz |
fixes #798
Diffstat (limited to 'tests/patterns')
-rw-r--r-- | tests/patterns/targlist.nim | 9 | ||||
-rw-r--r-- | tests/patterns/tcse.nim | 13 | ||||
-rw-r--r-- | tests/patterns/thoist.nim | 13 | ||||
-rw-r--r-- | tests/patterns/tmatrix.nim | 29 | ||||
-rw-r--r-- | tests/patterns/tnoalias.nim | 16 | ||||
-rw-r--r-- | tests/patterns/tnoendlessrec.nim | 10 | ||||
-rw-r--r-- | tests/patterns/tor.nim | 21 | ||||
-rw-r--r-- | tests/patterns/tpartial.nim | 11 | ||||
-rw-r--r-- | tests/patterns/tpatterns.nim | 17 | ||||
-rw-r--r-- | tests/patterns/tstar.nim | 19 | ||||
-rw-r--r-- | tests/patterns/tstmtlist.nim | 19 |
11 files changed, 0 insertions, 177 deletions
diff --git a/tests/patterns/targlist.nim b/tests/patterns/targlist.nim deleted file mode 100644 index e416edf0a..000000000 --- a/tests/patterns/targlist.nim +++ /dev/null @@ -1,9 +0,0 @@ -discard """ - output: "12false3ha" -""" - -proc f(x: varargs[string, `$`]) = discard -template optF{f(X)}(x: varargs[expr]) = - writeln(stdout, x) - -f 1, 2, false, 3, "ha" diff --git a/tests/patterns/tcse.nim b/tests/patterns/tcse.nim deleted file mode 100644 index ff04f7d83..000000000 --- a/tests/patterns/tcse.nim +++ /dev/null @@ -1,13 +0,0 @@ -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/thoist.nim b/tests/patterns/thoist.nim deleted file mode 100644 index 7d14c0abf..000000000 --- a/tests/patterns/thoist.nim +++ /dev/null @@ -1,13 +0,0 @@ -discard """ - output: '''true -true''' -""" - -import pegs - -template optPeg{peg(pattern)}(pattern: string{lit}): TPeg = - var gl {.global, gensym.} = peg(pattern) - gl - -echo match("(a b c)", peg"'(' @ ')'") -echo match("W_HI_Le", peg"\y 'while'") diff --git a/tests/patterns/tmatrix.nim b/tests/patterns/tmatrix.nim deleted file mode 100644 index c825a7792..000000000 --- a/tests/patterns/tmatrix.nim +++ /dev/null @@ -1,29 +0,0 @@ -discard """ - output: "21" -""" - -import macros - -type - TMat = object - dummy: int - -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 mat21(): TMat = - result.dummy = 21 - -macro optOps{ (`+`|`-`|`*`) ** a }(a: TMat): expr = - echo treeRepr(a) - result = newCall(bindSym"mat21") - -#macro optPlus{ `+` * a }(a: varargs[TMat]): expr = -# result = newIntLitNode(21) - -var x, y, z: TMat - -echo x + y * z - x - -#echo x + y + z diff --git a/tests/patterns/tnoalias.nim b/tests/patterns/tnoalias.nim deleted file mode 100644 index 1d5671362..000000000 --- a/tests/patterns/tnoalias.nim +++ /dev/null @@ -1,16 +0,0 @@ -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/tnoendlessrec.nim b/tests/patterns/tnoendlessrec.nim deleted file mode 100644 index 53891bcc0..000000000 --- a/tests/patterns/tnoendlessrec.nim +++ /dev/null @@ -1,10 +0,0 @@ -discard """ - output: "4" -""" - -# test that an endless recursion is avoided: - -template optLen{len(x)}(x: expr): expr = len(x) - -var s = "lala" -echo len(s) diff --git a/tests/patterns/tor.nim b/tests/patterns/tor.nim deleted file mode 100644 index 833418919..000000000 --- a/tests/patterns/tor.nim +++ /dev/null @@ -1,21 +0,0 @@ -discard """ - output: '''3060 -true''' -""" - -template arithOps: expr = (`+` | `-` | `*`) -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/tpartial.nim b/tests/patterns/tpartial.nim deleted file mode 100644 index fdaa3414a..000000000 --- a/tests/patterns/tpartial.nim +++ /dev/null @@ -1,11 +0,0 @@ -discard """ - output: '''-2''' -""" - -proc p(x, y: int; cond: bool): int = - result = if cond: x + y else: x - y - -template optP{p(x, y, true)}(x, y: expr): expr = x - y -template optP{p(x, y, false)}(x, y: expr): expr = x + y - -echo p(2, 4, true) diff --git a/tests/patterns/tpatterns.nim b/tests/patterns/tpatterns.nim deleted file mode 100644 index 6bc8772e3..000000000 --- a/tests/patterns/tpatterns.nim +++ /dev/null @@ -1,17 +0,0 @@ -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] diff --git a/tests/patterns/tstar.nim b/tests/patterns/tstar.nim deleted file mode 100644 index 8443268f4..000000000 --- a/tests/patterns/tstar.nim +++ /dev/null @@ -1,19 +0,0 @@ -discard """ - output: "my awesome concat" -""" - -var - calls = 0 - -proc `&&`(s: varargs[string]): string = - result = s[0] - for i in 1..len(s)-1: result.add s[i] - inc calls - -template optConc{ `&&` * a }(a: string): expr = &&a - -let space = " " -echo "my" && (space & "awe" && "some " ) && "concat" - -# check that it's been optimized properly: -doAssert calls == 1 diff --git a/tests/patterns/tstmtlist.nim b/tests/patterns/tstmtlist.nim deleted file mode 100644 index 20cb5d688..000000000 --- a/tests/patterns/tstmtlist.nim +++ /dev/null @@ -1,19 +0,0 @@ -discard """ - output: '''0 -|12| -34 -''' -""" - -template optWrite{ - write(f, x) - ((write|writeln){w})(f, y) -}(x, y: varargs[expr], f, w: expr) = - w(f, "|", x, y, "|") - -if true: - echo "0" - write stdout, "1" - writeln stdout, "2" - write stdout, "3" - echo "4" |