summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/run/tpegs.nim74
-rw-r--r--tests/run/tuserassert.nim1
-rw-r--r--tests/specials.nim1
-rw-r--r--tests/threads/trecursive_actor.nim19
4 files changed, 57 insertions, 38 deletions
diff --git a/tests/run/tpegs.nim b/tests/run/tpegs.nim
index 64c547b24..8fe302073 100755
--- a/tests/run/tpegs.nim
+++ b/tests/run/tpegs.nim
@@ -1669,25 +1669,25 @@ proc escapePeg*(s: string): string =
   if inQuote: result.add('\'')
 
 when isMainModule:
-  assert escapePeg("abc''def'") == r"'abc'\x27\x27'def'\x27"
-  #assert match("(a b c)", peg"'(' @ ')'")
-  assert match("W_HI_Le", peg"\y 'while'")
-  assert(not match("W_HI_L", peg"\y 'while'"))
-  assert(not match("W_HI_Le", peg"\y v'while'"))
-  assert match("W_HI_Le", peg"y'while'")
+  doAssert escapePeg("abc''def'") == r"'abc'\x27\x27'def'\x27"
+  #doAssert match("(a b c)", peg"'(' @ ')'")
+  doAssert match("W_HI_Le", peg"\y 'while'")
+  doAssert(not match("W_HI_L", peg"\y 'while'"))
+  doAssert(not match("W_HI_Le", peg"\y v'while'"))
+  doAssert match("W_HI_Le", peg"y'while'")
   
-  assert($ +digits == $peg"\d+")
-  assert "0158787".match(peg"\d+")
-  assert "ABC 0232".match(peg"\w+\s+\d+")
-  assert "ABC".match(peg"\d+ / \w+")
+  doAssert($ +digits == $peg"\d+")
+  doAssert "0158787".match(peg"\d+")
+  doAssert "ABC 0232".match(peg"\w+\s+\d+")
+  doAssert "ABC".match(peg"\d+ / \w+")
 
   for word in split("00232this02939is39an22example111", peg"\d+"):
     writeln(stdout, word)
 
-  assert matchLen("key", ident) == 3
+  doAssert matchLen("key", ident) == 3
 
   var pattern = sequence(ident, *whitespace, term('='), *whitespace, ident)
-  assert matchLen("key1=  cal9", pattern) == 11
+  doAssert matchLen("key1=  cal9", pattern) == 11
   
   var ws = newNonTerminal("ws", 1, 1)
   ws.rule = *whitespace
@@ -1698,24 +1698,24 @@ when isMainModule:
   
   var c: TCaptures
   var s = "a+b +  c +d+e+f"
-  assert rawMatch(s, expr.rule, 0, c) == len(s)
+  doAssert rawMatch(s, expr.rule, 0, c) == len(s)
   var a = ""
   for i in 0..c.ml-1:
     a.add(substr(s, c.matches[i][0], c.matches[i][1]))
-  assert a == "abcdef"
+  doAssert a == "abcdef"
   #echo expr.rule
 
   #const filename = "lib/devel/peg/grammar.txt"
   #var grammar = parsePeg(newFileStream(filename, fmRead), filename)
   #echo "a <- [abc]*?".match(grammar)
-  assert find("_____abc_______", term("abc"), 2) == 5
-  assert match("_______ana", peg"A <- 'ana' / . A")
-  assert match("abcs%%%", peg"A <- ..A / .A / '%'")
+  doAssert find("_____abc_______", term("abc"), 2) == 5
+  doAssert match("_______ana", peg"A <- 'ana' / . A")
+  doAssert match("abcs%%%", peg"A <- ..A / .A / '%'")
 
   if "abc" =~ peg"{'a'}'bc' 'xyz' / {\ident}":
-    assert matches[0] == "abc"
+    doAssert matches[0] == "abc"
   else:
-    assert false
+    doAssert false
   
   var g2 = peg"""S <- A B / C D
                  A <- 'a'+
@@ -1723,44 +1723,44 @@ when isMainModule:
                  C <- 'c'+
                  D <- 'd'+
               """
-  assert($g2 == "((A B) / (C D))")
-  assert match("cccccdddddd", g2)
-  assert("var1=key; var2=key2".replacef(peg"{\ident}'='{\ident}", "$1<-$2$2") ==
+  doAssert($g2 == "((A B) / (C D))")
+  doAssert match("cccccdddddd", g2)
+  doAssert("var1=key; var2=key2".replacef(peg"{\ident}'='{\ident}", "$1<-$2$2") ==
          "var1<-keykey; var2<-key2key2")
-  assert "var1=key; var2=key2".endsWith(peg"{\ident}'='{\ident}")
+  doAssert "var1=key; var2=key2".endsWith(peg"{\ident}'='{\ident}")
 
   if "aaaaaa" =~ peg"'aa' !. / ({'a'})+":
-    assert matches[0] == "a"
+    doAssert matches[0] == "a"
   else:
-    assert false
+    doAssert false
     
   var matches: array[0..5, string]
   if match("abcdefg", peg"c {d} ef {g}", matches, 2): 
-    assert matches[0] == "d"
-    assert matches[1] == "g"
+    doAssert matches[0] == "d"
+    doAssert matches[1] == "g"
   else:
-    assert false
+    doAssert false
 
   for x in findAll("abcdef", peg"{.}", 3):
     echo x
     
   if "f(a, b)" =~ peg"{[0-9]+} / ({\ident} '(' {@} ')')":
-    assert matches[0] == "f"
-    assert matches[1] == "a, b"
+    doAssert matches[0] == "f"
+    doAssert matches[1] == "a, b"
   else:
-    assert false
+    doAssert false
   
-  assert match("eine übersicht und außerdem", peg"(\letter \white*)+")
+  doAssert match("eine übersicht und außerdem", peg"(\letter \white*)+")
   # ß is not a lower cased letter?!
-  assert match("eine übersicht und auerdem", peg"(\lower \white*)+")
-  assert match("EINE ÜBERSICHT UND AUSSERDEM", peg"(\upper \white*)+")
-  assert(not match("456678", peg"(\letter)+"))
+  doAssert match("eine übersicht und auerdem", peg"(\lower \white*)+")
+  doAssert match("EINE ÜBERSICHT UND AUSSERDEM", peg"(\upper \white*)+")
+  doAssert(not match("456678", peg"(\letter)+"))
 
-  assert("var1 = key; var2 = key2".replacef(
+  doAssert("var1 = key; var2 = key2".replacef(
     peg"\skip(\s*) {\ident}'='{\ident}", "$1<-$2$2") ==
          "var1<-keykey;var2<-key2key2")
 
-  assert match("prefix/start", peg"^start$", 7)
+  doAssert match("prefix/start", peg"^start$", 7)
   
   # tricky test to check for false aliasing:
   block:
diff --git a/tests/run/tuserassert.nim b/tests/run/tuserassert.nim
index 958da2fe1..cf12c4e8b 100644
--- a/tests/run/tuserassert.nim
+++ b/tests/run/tuserassert.nim
@@ -5,7 +5,6 @@ discard """
 template myAssert(cond: expr) = 
   when rand(3) < 2:
     let c = cond.astToStr
-    {.warning: "code activated: " & c.}
     if not cond:
       echo c, "ugh"
   
diff --git a/tests/specials.nim b/tests/specials.nim
index 1f3013e90..a1aa1bc5a 100644
--- a/tests/specials.nim
+++ b/tests/specials.nim
@@ -118,6 +118,7 @@ proc runThreadTests(r: var TResults, options: string) =
   
   test "tactors"
   test "threadex"
+  test "trecursive_actor"
   #test "threadring"
   #test "tthreadanalysis"
   #test "tthreadsort"
diff --git a/tests/threads/trecursive_actor.nim b/tests/threads/trecursive_actor.nim
new file mode 100644
index 000000000..e2774704c
--- /dev/null
+++ b/tests/threads/trecursive_actor.nim
@@ -0,0 +1,19 @@
+discard """
+  outputsub: "0"
+"""
+
+import actors
+
+var
+  a: TActorPool[int, void]
+createActorPool(a)
+
+proc task(i: int) {.thread.} =
+  echo i
+  if i != 0: a.spawn (i-1, task)
+
+# count from 9 till 0 and check 0 is somewhere in the output
+a.spawn(9, task)
+a.join()
+
+