summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/async/tlambda.nim55
-rw-r--r--tests/async/tnimcall_to_closure.nim17
-rw-r--r--tests/ccgbugs/tgeneric_closure.nim28
-rw-r--r--tests/closure/tclosure0.nim87
-rw-r--r--tests/closure/tclosure2.nim2
-rw-r--r--tests/closure/tclosure3.nim5
-rw-r--r--tests/closure/tclosurebug2.nim6
-rw-r--r--tests/closure/tclosureinference3304.nim15
-rw-r--r--tests/closure/tcodegenerr1923.nim9
-rw-r--r--tests/closure/texplicit_dummy_closure.nim22
-rw-r--r--tests/closure/tfutclosure2138.nim10
-rw-r--r--tests/closure/tinvalidclosure.nim4
-rw-r--r--tests/closure/tissue1502def.nim6
-rw-r--r--tests/closure/tissue1642.nim8
-rw-r--r--tests/closure/tissue1846.nim16
-rw-r--r--tests/closure/tissue1911.nim7
-rw-r--r--tests/closure/tissue600.nim4
-rw-r--r--tests/closure/tjester.nim2
-rw-r--r--tests/closure/tmacrobust1512.nim137
-rw-r--r--tests/closure/tnestedclosure.nim4
-rw-r--r--tests/closure/tnoclosure.nim25
-rw-r--r--tests/destructor/tdestructor3.nim3
-rw-r--r--tests/gc/gcbench.nim2
-rw-r--r--tests/generics/tgeneric3.nim34
-rw-r--r--tests/generics/tgenerictmpl.nim25
-rw-r--r--tests/generics/tspecialized_procvar.nim17
-rw-r--r--tests/iter/tclosureiters.nim73
-rw-r--r--tests/iter/timplicit_auto.nim2
-rw-r--r--tests/iter/titer10.nim51
-rw-r--r--tests/iter/titer7.nim14
-rw-r--r--tests/iter/tkeep_state_between_yield.nim36
-rw-r--r--tests/iter/tnested_closure_iter.nim16
-rw-r--r--tests/iter/tpermutations.nim58
-rw-r--r--tests/iter/twrap_walkdir.nim16
-rw-r--r--tests/manyloc/keineschweine/dependencies/genpacket/genpacket_enet.nim6
-rw-r--r--tests/manyloc/keineschweine/lib/client_helpers.nim2
-rw-r--r--tests/manyloc/keineschweine/lib/sg_assets.nim4
-rw-r--r--tests/manyloc/nake/nakefile.nim2
-rw-r--r--tests/metatype/ttypedesc3.nim2
-rw-r--r--tests/method/tmultim8.nim19
-rw-r--r--tests/openarray/tptrarrayderef.nim54
-rw-r--r--tests/parser/tmultiline_comments.nim64
-rw-r--r--tests/stdlib/tpegs.nim2
-rw-r--r--tests/stdlib/ttime.nim98
-rw-r--r--tests/types/tillegaltyperecursion.nim14
-rw-r--r--tests/vm/texcl.nim27
-rw-r--r--tests/vm/ttouintconv.nim77
47 files changed, 1080 insertions, 107 deletions
diff --git a/tests/async/tlambda.nim b/tests/async/tlambda.nim
new file mode 100644
index 000000000..e0ff1f483
--- /dev/null
+++ b/tests/async/tlambda.nim
@@ -0,0 +1,55 @@
+
+# bug 2007
+
+import asyncdispatch, asyncnet, logging, json, uri, strutils, future
+
+type
+  Builder = ref object
+    client: Client
+    build: Build
+
+  ProgressCB* = proc (message: string): Future[void] {.closure, gcsafe.}
+
+  Build* = ref object
+    onProgress*: ProgressCB
+
+  Client = ref ClientObj
+  ClientObj = object
+    onMessage: proc (client: Client, msg: JsonNode): Future[void]
+
+proc newClient*(name: string,
+                onMessage: (Client, JsonNode) -> Future[void]): Client =
+  new result
+  result.onMessage = onMessage
+
+proc newBuild*(onProgress: ProgressCB): Build =
+  new result
+  result.onProgress = onProgress
+
+proc start(build: Build, repo, hash: string) {.async.} =
+  let path = repo.parseUri().path.toLower()
+
+proc onProgress(builder: Builder, message: string) {.async.} =
+  debug($message)
+
+proc onMessage(builder: Builder, message: JsonNode) {.async.} =
+  debug("onMessage")
+
+proc newBuilder(): Builder =
+  var cres: Builder
+  new cres
+
+  cres.client = newClient("builder", (client, msg) => (onMessage(cres, msg)))
+  cres.build = newBuild(
+      proc (msg: string): Future[void] {.closure, gcsafe.} = onProgress(cres, msg))
+  return cres
+
+proc main() =
+  # Set up logging.
+  var console = newConsoleLogger(fmtStr = verboseFmtStr)
+  addHandler(console)
+
+  var builder = newBuilder()
+
+
+main()
diff --git a/tests/async/tnimcall_to_closure.nim b/tests/async/tnimcall_to_closure.nim
new file mode 100644
index 000000000..748b67cb1
--- /dev/null
+++ b/tests/async/tnimcall_to_closure.nim
@@ -0,0 +1,17 @@
+
+import asyncdispatch
+
+proc defaultOnProgressChanged() = discard
+
+proc ask(x: proc()) = x()
+
+proc retrFile*(onProgressChanged: proc() {.nimcall.}): Future[void] =
+  var retFuture = newFuture[void]("retrFile")
+  iterator retrFileIter(): FutureBase {.closure.} =
+    ask(onProgressChanged)
+    complete(retFuture)
+
+  var nameIterVar = retrFileIter
+  return retFuture
+
+discard retrFile(defaultOnProgressChanged)
diff --git a/tests/ccgbugs/tgeneric_closure.nim b/tests/ccgbugs/tgeneric_closure.nim
new file mode 100644
index 000000000..f9d5e7910
--- /dev/null
+++ b/tests/ccgbugs/tgeneric_closure.nim
@@ -0,0 +1,28 @@
+
+
+# bug 2659
+
+type
+  GenProcType[T,U] = proc(x:T, y:var U)
+  IntProcType = proc(x:int, y:var int)
+
+proc mult(x:int, y:var int) =
+  y = 2 * x
+
+when isMainModule:
+
+  var input = 1
+  var output = 0
+
+  var someIntProc:IntProcType = mult
+  var someGenProc:GenProcType[int,int] = mult
+
+  mult(input, output)
+  echo output
+
+  someIntProc(input, output)
+  echo output
+
+  # Uncommenting causes an error in the C compiler.
+  someGenProc(input, output)
+  echo output
diff --git a/tests/closure/tclosure0.nim b/tests/closure/tclosure0.nim
new file mode 100644
index 000000000..9952268d5
--- /dev/null
+++ b/tests/closure/tclosure0.nim
@@ -0,0 +1,87 @@
+discard """
+  output: '''foo88
+23 24foo 88
+18
+18
+99
+99
+99
+99 99
+99 99
+12 99 99
+12 99 99'''
+"""
+
+when true:
+  # test simple closure within dummy 'main':
+  proc dummy =
+    proc main2(param: int) =
+      var fooB = 23
+      proc outer(outerParam: string) =
+        var outerVar = 88
+        echo outerParam, outerVar
+        proc inner() =
+          block Test:
+            echo fooB, " ", param, outerParam, " ", outerVar
+        inner()
+      outer("foo")
+    main2(24)
+
+  dummy()
+
+when true:
+  proc outer2(x:int) : proc(y:int):int =   # curry-ed application
+      return proc(y:int):int = x*y
+
+  var fn = outer2(6)  # the closure
+  echo fn(3)   # it works
+
+  var rawP = fn.rawProc()
+  var rawE = fn.rawEnv()
+
+  # A type to cast the function pointer into a nimcall
+  type
+    TimesClosure = proc(a: int, x: pointer): int {.nimcall.}
+
+  # Call the function with its closure
+  echo cast[TimesClosure](rawP)(3, rawE)
+
+when true:
+  proc outer =
+    var x, y: int = 99
+    proc innerA = echo x
+    proc innerB =
+      echo y
+      innerA()
+
+    innerA()
+    innerB()
+
+  outer()
+
+when true:
+  proc indirectDep =
+    var x, y: int = 99
+    proc innerA = echo x, " ", y
+    proc innerB =
+      innerA()
+
+    innerA()
+    innerB()
+
+  indirectDep()
+
+when true:
+  proc needlessIndirection =
+    var x, y: int = 99
+    proc indirection =
+      var z = 12
+      proc innerA = echo z, " ", x, " ", y
+      proc innerB =
+        innerA()
+
+      innerA()
+      innerB()
+    indirection()
+
+  needlessIndirection()
diff --git a/tests/closure/tclosure2.nim b/tests/closure/tclosure2.nim
index d331388cf..9c5ee1426 100644
--- a/tests/closure/tclosure2.nim
+++ b/tests/closure/tclosure2.nim
@@ -87,7 +87,7 @@ when true:
     proc py() {.closure.} =
       echo "py"
 
-    const
+    let
       mapping = {
         "abc": px,
         "xyz": py
diff --git a/tests/closure/tclosure3.nim b/tests/closure/tclosure3.nim
index 8f6f4a70f..d5ffb5ab2 100644
--- a/tests/closure/tclosure3.nim
+++ b/tests/closure/tclosure3.nim
@@ -8,8 +8,9 @@ proc main =
   for iterations in 0..50_000:
     var s: seq[proc(): string {.closure.}] = @[]
     for i in 0 .. n-1:
-      let ii = i
-      s.add(proc(): string = return $(ii*ii))
+      (proc () =
+        let ii = i
+        s.add(proc(): string = return $(ii*ii)))()
     for i in 0 .. n-1:
       let val = s[i]()
       if val != $(i*i): echo "bug  ", val
diff --git a/tests/closure/tclosurebug2.nim b/tests/closure/tclosurebug2.nim
index 581b735bf..f131406a3 100644
--- a/tests/closure/tclosurebug2.nim
+++ b/tests/closure/tclosurebug2.nim
@@ -19,11 +19,11 @@ proc mustRehash(length, counter: int): bool {.inline.} =
   assert(length > counter)
   result = (length * 2 < counter * 3) or (length - counter < 4)
 
-proc nextTry(h, maxHash: THash): THash {.inline.} =
+proc nextTry(h, maxHash: Hash): Hash {.inline.} =
   result = ((5 * h) + 1) and maxHash
 
 template rawGetImpl() {.dirty.} =
-  var h: THash = hash(key) and high(t.data) # start with real hash value
+  var h: Hash = hash(key) and high(t.data) # start with real hash value
   while t.data[h].slot != seEmpty:
     if t.data[h].key == key and t.data[h].slot == seFilled:
       return h
@@ -31,7 +31,7 @@ template rawGetImpl() {.dirty.} =
   result = -1
 
 template rawInsertImpl() {.dirty.} =
-  var h: THash = hash(key) and high(data)
+  var h: Hash = hash(key) and high(data)
   while data[h].slot == seFilled:
     h = nextTry(h, high(data))
   data[h].key = key
diff --git a/tests/closure/tclosureinference3304.nim b/tests/closure/tclosureinference3304.nim
new file mode 100644
index 000000000..db4aa1d04
--- /dev/null
+++ b/tests/closure/tclosureinference3304.nim
@@ -0,0 +1,15 @@
+discard """
+  output: '''@[1, 2, 5]'''
+"""
+
+import future, sequtils
+
+type
+  List[T] = ref object
+    val: T
+  
+proc foo[T](l: List[T]): seq[int] =
+  @[1,2,3,5].filter(x => x != l.val)
+
+when isMainModule:
+  echo(foo(List[int](val: 3)))
diff --git a/tests/closure/tcodegenerr1923.nim b/tests/closure/tcodegenerr1923.nim
new file mode 100644
index 000000000..ee131ae15
--- /dev/null
+++ b/tests/closure/tcodegenerr1923.nim
@@ -0,0 +1,9 @@
+type
+  Foo[M] = proc() : M
+
+proc bar[M](f : Foo[M]) =
+  discard f()
+
+proc baz() : int = 42
+
+bar(baz)
\ No newline at end of file
diff --git a/tests/closure/texplicit_dummy_closure.nim b/tests/closure/texplicit_dummy_closure.nim
new file mode 100644
index 000000000..ec608b31a
--- /dev/null
+++ b/tests/closure/texplicit_dummy_closure.nim
@@ -0,0 +1,22 @@
+
+# This is a regression of the new lambda lifting; detected by Aporia
+import asyncio, sockets
+import os
+
+type
+  Window = object
+    oneInstSock*: PAsyncSocket
+    IODispatcher*: PDispatcher
+
+var
+  win: Window
+
+proc initSocket() =
+  win.oneInstSock = asyncSocket()
+  #win.oneInstSock.handleAccept =
+  proc test(s: PAsyncSocket) =
+    var client: PAsyncSocket
+    proc dummy(c: PAsyncSocket) {.closure.} =
+      discard
+    client.handleRead = dummy
+  test(win.oneInstSock)
diff --git a/tests/closure/tfutclosure2138.nim b/tests/closure/tfutclosure2138.nim
new file mode 100644
index 000000000..e18834074
--- /dev/null
+++ b/tests/closure/tfutclosure2138.nim
@@ -0,0 +1,10 @@
+import future, sequtils
+
+proc any[T](list: varargs[T], pred: (T) -> bool): bool =
+    for item in list:
+        if pred(item):
+            result = true
+            break
+
+proc contains(s: string, words: varargs[string]): bool =
+  any(words, (word) => s.contains(word))
\ No newline at end of file
diff --git a/tests/closure/tinvalidclosure.nim b/tests/closure/tinvalidclosure.nim
index c9136a736..d3f38cde5 100644
--- a/tests/closure/tinvalidclosure.nim
+++ b/tests/closure/tinvalidclosure.nim
@@ -1,9 +1,9 @@
 discard """
   line: 12
-  errormsg: "type mismatch: got (proc (x: int){.closure, gcsafe, locks: 0.})"
+  errormsg: "type mismatch: got (proc (x: int){.gcsafe, locks: 0.})"
 """
 
-proc ugh[T](x: T) {.closure.} =
+proc ugh[T](x: T) {.nimcall.} =
   echo "ugha"
 
 
diff --git a/tests/closure/tissue1502def.nim b/tests/closure/tissue1502def.nim
new file mode 100644
index 000000000..0aa6b16e3
--- /dev/null
+++ b/tests/closure/tissue1502def.nim
@@ -0,0 +1,6 @@
+import sequtils
+let xs: seq[tuple[key: string, val: seq[string]]] = @[("foo", @["bar"])]
+
+let maps = xs.map(
+  proc(x: auto): tuple[typ: string, maps: seq[string]] =
+    (x.key, x.val.map(proc(x: string): string = x)))
\ No newline at end of file
diff --git a/tests/closure/tissue1642.nim b/tests/closure/tissue1642.nim
index e3028c88e..5b921fc05 100644
--- a/tests/closure/tissue1642.nim
+++ b/tests/closure/tissue1642.nim
@@ -1,7 +1,3 @@
-discard """
-  file: "tissue1642.nim"
-  disabled: true
-"""
 block:
-  var i = 0
-  proc p() = inc(i)
+    var i = 0
+    proc p() = inc(i)
\ No newline at end of file
diff --git a/tests/closure/tissue1846.nim b/tests/closure/tissue1846.nim
new file mode 100644
index 000000000..3fbef169d
--- /dev/null
+++ b/tests/closure/tissue1846.nim
@@ -0,0 +1,16 @@
+type
+    TBinOp*[T] = proc (x,y: T): bool
+
+    THeap*[T] = object
+        cmp*:   TBinOp[T]
+
+proc less*[T](x,y: T): bool =
+    x < y
+
+proc initHeap*[T](cmp: TBinOp[T]): THeap[T] =
+    result.cmp = cmp
+
+when isMainModule:
+    var h = initHeap[int](less[int])
+
+    echo h.cmp(2,3)
\ No newline at end of file
diff --git a/tests/closure/tissue1911.nim b/tests/closure/tissue1911.nim
new file mode 100644
index 000000000..311d99134
--- /dev/null
+++ b/tests/closure/tissue1911.nim
@@ -0,0 +1,7 @@
+proc foo(x: int) : auto =
+
+  proc helper() : int = x
+  proc bar() : int = helper()
+  proc baz() : int = helper()
+
+  return (bar, baz)
\ No newline at end of file
diff --git a/tests/closure/tissue600.nim b/tests/closure/tissue600.nim
new file mode 100644
index 000000000..eacc7a123
--- /dev/null
+++ b/tests/closure/tissue600.nim
@@ -0,0 +1,4 @@
+for i in 1..1:
+  var reported = false
+  proc report() =
+    reported = true
\ No newline at end of file
diff --git a/tests/closure/tjester.nim b/tests/closure/tjester.nim
index 3bd10120a..84e0fcb71 100644
--- a/tests/closure/tjester.nim
+++ b/tests/closure/tjester.nim
@@ -7,7 +7,7 @@ type
     data: T
     callback: proc () {.closure.}
 
-proc cbOuter(response: string) {.closure, discardable.} =
+proc cbOuter(response: string) {.discardable.} =
   iterator cbIter(): Future[int] {.closure.} =
     for i in 0..7:
       proc foo(): int =
diff --git a/tests/closure/tmacrobust1512.nim b/tests/closure/tmacrobust1512.nim
new file mode 100644
index 000000000..95681e750
--- /dev/null
+++ b/tests/closure/tmacrobust1512.nim
@@ -0,0 +1,137 @@
+import macros, strutils
+
+# https://github.com/nim-lang/Nim/issues/1512
+
+proc macrobust0 (raw_input: string) =
+  var output = ""
+  proc p1 (a:string) =
+    output.add (a)
+
+  proc p2 (a:string) = p1 (a)
+  proc p3 (a:string) = p2 (a)
+  proc p4 (a:string) = p3 (a)
+  proc p5 (a:string) = p4 (a)
+  proc p6 (a:string) = p5 (a)
+  proc p7 (a:string) = p6 (a)
+  proc p8 (a:string) = p7 (a)
+  proc p9 (a:string) = p8 (a)
+  proc p10 (a:string) = p9 (a)
+  proc p11 (a:string) = p10 (a)
+  proc p12 (a:string) = p11 (a)
+  proc p13 (a:string) = p12 (a)
+  proc p14 (a:string) = p13 (a)
+  proc p15 (a:string) = p14 (a)
+  proc p16 (a:string) = p15 (a)
+  proc p17 (a:string) = p16 (a)
+  proc p18 (a:string) = p17 (a)
+  proc p19 (a:string) = p18 (a)
+  proc p20 (a:string) = p19 (a)
+
+  let input = $raw_input
+
+  for a in input.split ():
+    p20 (a)
+    p19 (a)
+
+
+    p18 (a)
+    p17 (a)
+    p16 (a)
+    p15 (a)
+    p14 (a)
+    p13 (a)
+    p12 (a)
+    p11 (a)
+    p10 (a)
+    p9 (a)
+    p8 (a)
+    p7 (a)
+    p6 (a)
+    p5 (a)
+    p4 (a)
+    p3 (a)
+    p2 (a)
+    p1 (a)
+
+
+  echo output
+
+macro macrobust (raw_input: expr) : stmt =
+
+  var output = ""
+  proc p1 (a:string) =
+    output.add (a)
+
+  proc p2 (a:string) = p1 (a)
+  proc p3 (a:string) = p2 (a)
+  proc p4 (a:string) = p3 (a)
+  proc p5 (a:string) = p4 (a)
+  proc p6 (a:string) = p5 (a)
+  proc p7 (a:string) = p6 (a)
+  proc p8 (a:string) = p7 (a)
+  proc p9 (a:string) = p8 (a)
+  proc p10 (a:string) = p9 (a)
+  proc p11 (a:string) = p10 (a)
+  proc p12 (a:string) = p11 (a)
+  proc p13 (a:string) = p12 (a)
+  proc p14 (a:string) = p13 (a)
+  proc p15 (a:string) = p14 (a)
+  proc p16 (a:string) = p15 (a)
+  proc p17 (a:string) = p16 (a)
+  proc p18 (a:string) = p17 (a)
+  proc p19 (a:string) = p18 (a)
+  proc p20 (a:string) = p19 (a)
+
+  let input = $raw_input
+
+  for a in input.split ():
+    p20 (a)
+    p19 (a)
+
+    p18 (a)
+    p17 (a)
+    p16 (a)
+    p15 (a)
+    p14 (a)
+    p13 (a)
+    p12 (a)
+    p11 (a)
+    p10 (a)
+    p9 (a)
+    p8 (a)
+    p7 (a)
+    p6 (a)
+    p5 (a)
+    p4 (a)
+    p3 (a)
+    p2 (a)
+
+  echo output
+  discard result
+
+macrobust """
+  fdsasadfsdfa sadfsdafsdaf
+  dsfsdafdsfadsfa fsdaasdfasdf
+  fsdafsadfsad asdfasdfasdf
+  fdsasdfasdfa sadfsadfsadf
+  sadfasdfsdaf sadfsdafsdaf dsfasdaf
+  sadfsdafsadf fdsasdafsadf fdsasadfsdaf
+  sdfasadfsdafdfsa sadfsadfsdaf
+  sdafsdaffsda sdfasadfsadf
+  fsdasdafsdfa sdfasdfafsda
+  sdfasdafsadf sdfasdafsdaf sdfasdafsdaf
+"""
+
+
+macrobust0 """
+  fdsasadfsdfa sadfsdafsdaf
+  dsfsdafdsfadsfa fsdaasdfasdf
+  fsdafsadfsad asdfasdfasdf
+  fdsasdfasdfa sadfsadfsadf
+  sadfasdfsdaf sadfsdafsdaf dsfasdaf
+  sadfsdafsadf fdsasdafsadf fdsasadfsdaf
+  sdfasadfsdafdfsa sadfsadfsdaf
+  sdafsdaffsda sdfasadfsadf
+  fsdasdafsdfa sdfasdfafsda
+  sdfasdafsadf sdfasdafsdaf sdfasdafsdaf
+"""
\ No newline at end of file
diff --git a/tests/closure/tnestedclosure.nim b/tests/closure/tnestedclosure.nim
index 67e196f66..0628a6977 100644
--- a/tests/closure/tnestedclosure.nim
+++ b/tests/closure/tnestedclosure.nim
@@ -21,13 +21,13 @@ proc main(param: int) =
 # test simple closure within dummy 'main':
 proc dummy =
   proc main2(param: int) =
-    var foo = 23
+    var fooB = 23
     proc outer(outerParam: string) =
       var outerVar = 88
       echo outerParam, outerVar
       proc inner() =
         block Test:
-          echo foo, " ", param, outerParam, " ", outerVar
+          echo fooB, " ", param, outerParam, " ", outerVar
       inner()
     outer("foo")
   main2(24)
diff --git a/tests/closure/tnoclosure.nim b/tests/closure/tnoclosure.nim
new file mode 100644
index 000000000..25cce0040
--- /dev/null
+++ b/tests/closure/tnoclosure.nim
@@ -0,0 +1,25 @@
+discard """
+  output: '''@[1]
+@[1, 1]
+@[1, 2, 1]
+@[1, 3, 3, 1]
+@[1, 4, 6, 4, 1]
+@[1, 5, 10, 10, 5, 1]
+@[1, 6, 15, 20, 15, 6, 1]
+@[1, 7, 21, 35, 35, 21, 7, 1]
+@[1, 8, 28, 56, 70, 56, 28, 8, 1]
+@[1, 9, 36, 84, 126, 126, 84, 36, 9, 1]'''
+"""
+
+import sequtils
+
+proc pascal(n: int) =
+  var row = @[1]
+  for r in 1..n:
+    echo row
+    row = zip(row & @[0], @[0] & row).mapIt(it[0] + it[1])
+
+pascal(10)
+
+# bug #3499 last snippet fixed
+# bug 705  last snippet fixed
diff --git a/tests/destructor/tdestructor3.nim b/tests/destructor/tdestructor3.nim
index 0968f1fd7..d0c53c7bd 100644
--- a/tests/destructor/tdestructor3.nim
+++ b/tests/destructor/tdestructor3.nim
@@ -19,10 +19,11 @@ proc `=`(lhs: var T, rhs: T) =
 proc `=destroy`(v: var T) =
     echo "destroy"
 
-block:
+proc usedToBeBlock =
     var v1 : T
     var v2 : T = v1
 
+usedToBeBlock()
 
 # bug #1632
 
diff --git a/tests/gc/gcbench.nim b/tests/gc/gcbench.nim
index 72337911d..782daf793 100644
--- a/tests/gc/gcbench.nim
+++ b/tests/gc/gcbench.nim
@@ -143,7 +143,7 @@ proc main() =
   # Create long-lived array, filling half of it
   echo(" Creating a long-lived array of " & $kArraySize & " doubles")
   newSeq(myarray, kArraySize)
-  for i in 0..kArraySize div 2 -1:
+  for i in 0..kArraySize div 2 - 1:
     myarray[i] = 1.0 / toFloat(i)
 
   PrintDiagnostics()
diff --git a/tests/generics/tgeneric3.nim b/tests/generics/tgeneric3.nim
index d4dac9385..0dbd5b03c 100644
--- a/tests/generics/tgeneric3.nim
+++ b/tests/generics/tgeneric3.nim
@@ -69,7 +69,7 @@ proc cmp[T:int8|int16|int32|int64|int] (a,b: T): T {.inline.} =
 template binSearchImpl *(docmp: expr) {.immediate.} =
   var bFound = false
   result = 0
-  var H = haystack.len -1
+  var H = haystack.len - 1
   while result <= H :
     var I {.inject.} = (result + H) shr 1
     var SW = docmp
@@ -90,7 +90,7 @@ proc DeleteItem[T,D] (n: PNode[T,D], x: int): PNode[T,D] {.inline.} =
     return n
   dec(n.count)
   if n.count > 0 :
-    for i in countup(x, n.count -1) : n.slots[i] = n.slots[i + 1]
+    for i in countup(x, n.count - 1) : n.slots[i] = n.slots[i + 1]
     n.slots[n.count] = nil
     case n.count
     of cLen1 : setLen(n.slots, cLen1)
@@ -121,7 +121,7 @@ proc internalDelete[T,D] (ANode: PNode[T,D], key: T, Avalue: var D): PNode[T,D]
       if x == 0 :
         n = n.left
       else :
-        x = (-x) -1
+        x = (-x) - 1
         if x < n.count :
           n = n.slots[x].node
         else :
@@ -132,10 +132,10 @@ proc internalDelete[T,D] (ANode: PNode[T,D], key: T, Avalue: var D): PNode[T,D]
       Avalue = n.slots[x].value
       var n2 = DeleteItem(n, x)
       dec(h)
-      while (n2 != n) and (h >=0) :
+      while (n2 != n) and (h >= 0) :
         n = n2
         var w = addr Path[h]
-        x  = w.Xi -1
+        x  = w.Xi - 1
         if x >= 0 :
           if (n == nil) and isClean(w.Nd, x) :
             n = w.Nd
@@ -160,7 +160,7 @@ proc internalFind[T,D] (n: PNode[T,D], key: T): ref TItem[T,D] {.inline.} =
       if x == 0 :
         wn = wn.left
       else :
-        x = (-x) -1
+        x = (-x) - 1
         if x < wn.count :
           wn = wn.slots[x].node
         else :
@@ -199,7 +199,7 @@ proc traceTree[T,D](root: PNode[T,D]) =
     if n.left != nil:
       traceln(space)
       write stdout, "left: "
-      doTrace(n.left, level +1)
+      doTrace(n.left, level+1)
     for i, el in n.slots :
       if el != nil and not isClean(el):
         traceln(space)
@@ -208,7 +208,7 @@ proc traceTree[T,D](root: PNode[T,D]) =
           write stdout, "error "
         else:
           traceEl(el)
-          if el.node != nil: doTrace(el.node, level +1)
+          if el.node != nil: doTrace(el.node, level+1)
           else : write stdout, " empty "
       elif i < n.count :
         traceln(space)
@@ -217,7 +217,7 @@ proc traceTree[T,D](root: PNode[T,D]) =
         when T is string :
           if el.key != nil: write stdout, el.key
         else : write stdout, el.key
-        if el.node != nil: doTrace(el.node, level +1)
+        if el.node != nil: doTrace(el.node, level+1)
         else : write stdout, " empty "
     writeLine stdout,""
 
@@ -245,25 +245,25 @@ proc SplitPage[T,D](n, left: PNode[T,D], xi: int, Akey:var T, Avalue:var D): PNo
   result.slots.newSeq(cLenCenter)
   result.count = cCenter
   if x == cCenter:
-    for i in 0..cCenter -1: shallowCopy(it1[i], left.slots[i])
-    for i in 0..cCenter -1: shallowCopy(result.slots[i], left.slots[cCenter + i])
+    for i in 0..cCenter-1: shallowCopy(it1[i], left.slots[i])
+    for i in 0..cCenter-1: shallowCopy(result.slots[i], left.slots[cCenter + i])
     result.left = n
   else :
     if x < cCenter :
       for i in 0..x-1: shallowCopy(it1[i], left.slots[i])
       it1[x] = setItem(Akey, Avalue, n)
-      for i in x+1 .. cCenter -1: shallowCopy(it1[i], left.slots[i-1])
-      var w = left.slots[cCenter -1]
+      for i in x+1 .. cCenter-1: shallowCopy(it1[i], left.slots[i-1])
+      var w = left.slots[cCenter-1]
       Akey = w.key
       Avalue = w.value
       result.left = w.node
-      for i in 0..cCenter -1: shallowCopy(result.slots[i], left.slots[cCenter + i])
+      for i in 0..cCenter-1: shallowCopy(result.slots[i], left.slots[cCenter + i])
     else :
-      for i in 0..cCenter -1: shallowCopy(it1[i], left.slots[i])
+      for i in 0..cCenter-1: shallowCopy(it1[i], left.slots[i])
       x = x - (cCenter + 1)
       for i in 0..x-1: shallowCopy(result.slots[i], left.slots[cCenter + i + 1])
       result.slots[x] = setItem(Akey, Avalue, n)
-      for i in x+1 .. cCenter -1: shallowCopy(result.slots[i], left.slots[cCenter + i])
+      for i in x+1 .. cCenter-1: shallowCopy(result.slots[i], left.slots[cCenter + i])
       var w = left.slots[cCenter]
       Akey = w.key
       Avalue = w.value
@@ -290,7 +290,7 @@ proc internalPut[T,D](ANode: ref TNode[T,D], Akey: T, Avalue: D, Oldvalue: var D
       if x == 0 :
         n = n.left
       else :
-        x = (-x) -1
+        x = (-x)-1
         if x < n.count :
           n = n.slots[x].node
         else :
diff --git a/tests/generics/tgenerictmpl.nim b/tests/generics/tgenerictmpl.nim
index a749e6570..c71ce4e2e 100644
--- a/tests/generics/tgenerictmpl.nim
+++ b/tests/generics/tgenerictmpl.nim
@@ -1,12 +1,21 @@
+discard """
+  output: '''0
+123'''
+"""
 
-template tmp[T](x: var seq[T]) =
-  #var yz: T  # XXX doesn't work yet
-  x = @[1, 2, 3]
+# bug #3498
+
+template defaultOf[T](t: T): expr = (var d: T; d)
+
+echo defaultOf(1) #<- excpected 0
 
-macro tmp2[T](x: var seq[T]): stmt =
-  nil
+# assignment using template
+
+template tassign[T](x: var seq[T]) =
+  x = @[1, 2, 3]
 
 var y: seq[int]
-tmp(y)
-tmp(y)
-echo y.repr
+tassign(y) #<- x is expected = @[1, 2, 3]
+tassign(y)
+
+echo y[0], y[1], y[2]
diff --git a/tests/generics/tspecialized_procvar.nim b/tests/generics/tspecialized_procvar.nim
new file mode 100644
index 000000000..4bdc94a66
--- /dev/null
+++ b/tests/generics/tspecialized_procvar.nim
@@ -0,0 +1,17 @@
+discard """
+  output: '''concrete 88'''
+"""
+
+# Another regression triggered by changed closure computations:
+
+proc foo[T](x: proc(): T) =
+  echo "generic ", x()
+
+proc foo(x: proc(): int) =
+  echo "concrete ", x()
+
+# note the following 'proc' is not .closure!
+foo(proc (): auto {.nimcall.} = 88)
+
+# bug #3499 last snippet fixed
+# bug 705  last snippet fixed
diff --git a/tests/iter/tclosureiters.nim b/tests/iter/tclosureiters.nim
new file mode 100644
index 000000000..0eb624a8c
--- /dev/null
+++ b/tests/iter/tclosureiters.nim
@@ -0,0 +1,73 @@
+discard """
+  output: '''0
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+5 5
+7 7
+9 9
+0
+0
+0
+0
+1
+2'''
+"""
+
+when true:
+  proc main() =
+    let
+      lo=0
+      hi=10
+
+    iterator itA(): int =
+      for x in lo..hi:
+        yield x
+
+    for x in itA():
+      echo x
+
+    var y: int
+
+    iterator itB(): int =
+      while y <= hi:
+        yield y
+        inc y
+
+    y = 5
+    for x in itB():
+      echo x, " ", y
+      inc y
+
+  main()
+
+
+iterator infinite(): int {.closure.} =
+  var i = 0
+  while true:
+    yield i
+    inc i
+
+iterator take[T](it: iterator (): T, numToTake: int): T {.closure.} =
+  var i = 0
+  for x in it():
+    if i >= numToTake:
+      break
+    yield x
+    inc i
+
+# gives wrong reasult (3 times 0)
+for x in infinite.take(3):
+  echo x
+
+# does what we want
+let inf = infinite
+for x in inf.take(3):
+  echo x
diff --git a/tests/iter/timplicit_auto.nim b/tests/iter/timplicit_auto.nim
index ccb279fe0..d5cb95eb8 100644
--- a/tests/iter/timplicit_auto.nim
+++ b/tests/iter/timplicit_auto.nim
@@ -9,7 +9,7 @@ proc univ(x, y: int): State = Tree
 
 var w, h = 30
 
-iterator fields(a = (0,0), b = (h-1,w-1)) =
+iterator fields(a = (0,0), b = (h-1,w-1)): auto =
   for y in max(a[0], 0) .. min(b[0], h-1):
     for x in max(a[1], 0) .. min(b[1], w-1):
       yield (y,x)
diff --git a/tests/iter/titer10.nim b/tests/iter/titer10.nim
new file mode 100644
index 000000000..6a6afc780
--- /dev/null
+++ b/tests/iter/titer10.nim
@@ -0,0 +1,51 @@
+discard """
+  output: '''3
+2
+5
+1
+@[@[0, 0], @[0, 1]]
+@[@[0, 0], @[0, 1]]
+@[@[2, 2], @[2, 3]]
+@[@[2, 2], @[2, 3]]'''
+"""
+
+when true:
+  # bug #2604
+
+  import algorithm
+
+  iterator byDistance*[int]( ints: openArray[int], base: int ): int =
+      var sortable = @ints
+
+      sortable.sort do (a, b: int) -> int:
+          result = cmp( abs(base - a), abs(base - b) )
+
+      for val in sortable:
+          yield val
+
+  when isMainModule:
+    proc main =
+      for val in byDistance([2, 3, 5, 1], 3):
+          echo val
+    main()
+
+when true:
+  # bug #1527
+
+  import sequtils
+
+  let thread = @[@[0, 0],
+                 @[0, 1],
+                 @[2, 2],
+                 @[2, 3]]
+
+  iterator threadUniqs(seq1: seq[seq[int]]): seq[seq[int]] =
+    for i in 0 .. <seq1.len:
+      block:
+        let i = i
+        yield seq1.filter do (x: seq[int]) -> bool: x[0] == seq1[i][0]
+  proc main2 =
+    for uniqs in thread.threadUniqs:
+      echo uniqs
+
+  main2()
diff --git a/tests/iter/titer7.nim b/tests/iter/titer7.nim
index d0337b7bd..c2bd9b9cb 100644
--- a/tests/iter/titer7.nim
+++ b/tests/iter/titer7.nim
@@ -14,11 +14,7 @@ discard """
 49
 64
 81
---- squares of evens, only
-4
-16
-36
-64'''
+'''
 """
 
 iterator `/`[T](sequence: seq[T],
@@ -40,10 +36,10 @@ iterator `/>>`[I,O](sequence: seq[I],
         if (filtermap.f(element)):
             yield filtermap.m(element)
 
-proc isEven(x:int): bool {.closure.} = result =
+proc isEven(x:int): bool =
     (x and 1) == 0
 
-proc square(x:int): int {.closure.} = result =
+proc square(x:int): int =
     x * x
 
 let list = @[1,2,3,4,5,6,7,8,9]
@@ -52,6 +48,6 @@ echo ("--- evens")
 for item in list / isEven : echo(item)
 echo ("--- squares")
 for item in list >> square : echo(item)
-echo ("--- squares of evens, only")
+#echo ("--- squares of evens, only")
 # next line doesn't compile. Generic types are not inferred
-for item in list />> (isEven, square) : echo(item)
+#for item in list />> (isEven, square) : echo(item)
diff --git a/tests/iter/tkeep_state_between_yield.nim b/tests/iter/tkeep_state_between_yield.nim
new file mode 100644
index 000000000..f4f0ee363
--- /dev/null
+++ b/tests/iter/tkeep_state_between_yield.nim
@@ -0,0 +1,36 @@
+discard """
+  output: '''@[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 18, 20, 21, 24, 27, 30, 36, 40, 42]
+1002'''
+"""
+
+import strutils
+
+proc slice[T](iter: iterator(): T {.closure.}, sl: auto): seq[T] =
+  var res: seq[int64] = @[]
+  var i = 0
+  for n in iter():
+    if i > sl.b:
+      break
+    if i >= sl.a:
+      res.add(n)
+    inc i
+  res
+
+iterator harshad(): int64 {.closure.} =
+  for n in 1 .. < int64.high:
+    var sum = 0
+    for ch in string($n):
+      sum += parseInt("" & ch)
+    if n mod sum == 0:
+      yield n
+
+echo harshad.slice 0 .. <20
+
+for n in harshad():
+  if n > 1000:
+    echo n
+    break
+
+
+# bug #3499 last snippet fixed
+# bug 705  last snippet fixed
diff --git a/tests/iter/tnested_closure_iter.nim b/tests/iter/tnested_closure_iter.nim
new file mode 100644
index 000000000..ec2253cf1
--- /dev/null
+++ b/tests/iter/tnested_closure_iter.nim
@@ -0,0 +1,16 @@
+discard """
+  output: '''0
+1
+2'''
+"""
+# bug #1725
+iterator factory(): int {.closure.} =
+  iterator bar(): int {.closure.} =
+    yield 0
+    yield 1
+    yield 2
+
+  for x in bar(): yield x
+
+for x in factory():
+  echo x
diff --git a/tests/iter/tpermutations.nim b/tests/iter/tpermutations.nim
new file mode 100644
index 000000000..a3b383323
--- /dev/null
+++ b/tests/iter/tpermutations.nim
@@ -0,0 +1,58 @@
+
+import sequtils, future
+
+iterator permutations*[T](ys: openarray[T]): tuple[perm: seq[T], sign: int] =
+  var
+    d = 1
+    c = newSeq[int](ys.len)
+    xs = newSeq[T](ys.len)
+    sign = 1
+
+  for i, y in ys: xs[i] = y
+  yield (xs, sign)
+
+  block outter:
+    while true:
+      while d > 1:
+        dec d
+        c[d] = 0
+      while c[d] >= d:
+        inc d
+        if d >= ys.len: break outter
+
+      let i = if (d and 1) == 1: c[d] else: 0
+      swap xs[i], xs[d]
+      sign *= -1
+      yield (xs, sign)
+      inc c[d]
+
+proc det(a: seq[seq[float]]): float =
+  let n = toSeq 0..a.high
+  for sigma, sign in n.permutations:
+    result += sign.float * n.map((i: int) => a[i][sigma[i]]).foldl(a * b)
+
+proc perm(a: seq[seq[float]]): float =
+  let n = toSeq 0..a.high
+  for sigma, sign in n.permutations:
+    result += n.map((i: int) => a[i][sigma[i]]).foldl(a * b)
+
+for a in [
+    @[ @[1.0, 2.0]
+     , @[3.0, 4.0]
+    ],
+    @[ @[ 1.0,  2,  3,  4]
+     , @[ 4.0,  5,  6,  7]
+     , @[ 7.0,  8,  9, 10]
+     , @[10.0, 11, 12, 13]
+    ],
+    @[ @[ 0.0,  1,  2,  3,  4]
+     , @[ 5.0,  6,  7,  8,  9]
+     , @[10.0, 11, 12, 13, 14]
+     , @[15.0, 16, 17, 18, 19]
+     , @[20.0, 21, 22, 23, 24]
+    ] ]:
+  echo a
+  echo "perm: ", a.perm, " det: ", a.det
+
+# bug #3499 last snippet fixed
+# bug 705  last snippet fixed
diff --git a/tests/iter/twrap_walkdir.nim b/tests/iter/twrap_walkdir.nim
new file mode 100644
index 000000000..4ac487d8e
--- /dev/null
+++ b/tests/iter/twrap_walkdir.nim
@@ -0,0 +1,16 @@
+
+
+
+import os
+
+# bug #3636
+
+proc fooIt(foo: string): iterator(): (string) =
+  iterator temp(): (string) =
+    for f in walkDirRec(foo): # No problem with walkFiles
+      yield f
+  return temp
+
+let it = fooIt(".")
+for x in it():
+  echo x
diff --git a/tests/manyloc/keineschweine/dependencies/genpacket/genpacket_enet.nim b/tests/manyloc/keineschweine/dependencies/genpacket/genpacket_enet.nim
index 7cfd67c49..142b190ab 100644
--- a/tests/manyloc/keineschweine/dependencies/genpacket/genpacket_enet.nim
+++ b/tests/manyloc/keineschweine/dependencies/genpacket/genpacket_enet.nim
@@ -131,10 +131,10 @@ macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} =
           emptyNode())),
       emptyNode(),
       emptyNode(),
-      newNimNode(nnkStmtList).und(#[6]
+      newNimNode(nnkStmtList).und(# [6]
         newNimNode(nnkAsgn).und(
           ^"result",                  ## result =
-          newNimNode(nnkCall).und(#[6][0][1]
+          newNimNode(nnkCall).und(# [6][0][1]
             ^"format",  ## format
             emptyNode()))))  ## "[TypeName   $1   $2]"
     formatStr = "["& $typeName.ident
@@ -277,7 +277,7 @@ when isMainModule:
   s.flush
 
   defPacket(Y, tuple[z: int8])
-  proc `$`(z: Y): string = result = "Y("& $z.z &")"
+  proc `$`(z: Y): string = result = "Y(" & $z.z & ")"
   defPacket(TestPkt, tuple[x: seq[Y]])
   var test = newTestPkt()
   test.x.add([newY(5), newY(4), newY(3), newY(2), newY(1)])
diff --git a/tests/manyloc/keineschweine/lib/client_helpers.nim b/tests/manyloc/keineschweine/lib/client_helpers.nim
index f2833fe14..5f819a7d1 100644
--- a/tests/manyloc/keineschweine/lib/client_helpers.nim
+++ b/tests/manyloc/keineschweine/lib/client_helpers.nim
@@ -66,7 +66,7 @@ proc handlePackets*(server: PServer; buf: PBuffer) =
 proc updateFileProgress*() =
   let progress = currentFileTransfer.pos / currentFileTransfer.fullLen
   downloadProgress.bg.setSize(vec2f(progress * 100, 20))
-  downloadProgress.setString($currentFileTransfer.pos &'/'& $currentFileTransfer.fullLen)
+  downloadProgress.setString($currentFileTransfer.pos & '/' & $currentFileTransfer.fullLen)
 
 ## HFileTransfer
 proc handleFilePartRecv*(serv: PServer; buffer: PBuffer) {.procvar.} =
diff --git a/tests/manyloc/keineschweine/lib/sg_assets.nim b/tests/manyloc/keineschweine/lib/sg_assets.nim
index 3b9781649..801c3456b 100644
--- a/tests/manyloc/keineschweine/lib/sg_assets.nim
+++ b/tests/manyloc/keineschweine/lib/sg_assets.nim
@@ -573,13 +573,13 @@ proc importItem(data: PJsonNode; errors: var seq[string]): PItemRecord =
     elif data[2]["bullet"].kind == JObject:
       result.bullet = importBullet(data[2]["bullet"], errors)
     else:
-      errors.add "UNKNOWN BULLET TYPE for item "& result.name
+      errors.add "UNKNOWN BULLET TYPE for item " & result.name
   of "ammo":
     result.kind = Ammo
   of "utility":
     nil
   else:
-    errors.add "Invalid item type \""& data[1].str &"\" for item "& result.name
+    errors.add "Invalid item type \""&data[1].str&"\" for item "&result.name
 
 proc importBullet(data: PJsonNode; errors: var seq[string]): PBulletRecord =
   new(result)
diff --git a/tests/manyloc/nake/nakefile.nim b/tests/manyloc/nake/nakefile.nim
index de6a1af40..e91b86986 100644
--- a/tests/manyloc/nake/nakefile.nim
+++ b/tests/manyloc/nake/nakefile.nim
@@ -146,7 +146,7 @@ task "download", "download game assets":
 
 task "zip-lib", "zip up the libs dir":
   var z: TZipArchive
-  if not z.open("libs-"& getDateStr() &".zip", fmReadWrite):
+  if not z.open("libs-" & getDateStr() & ".zip", fmReadWrite):
     quit "Could not open zip"
   for file in walkDirRec("libs", {pcFile, pcDir}):
     echo "adding file ", file
diff --git a/tests/metatype/ttypedesc3.nim b/tests/metatype/ttypedesc3.nim
index 3d40b25b2..9f19bd6e3 100644
--- a/tests/metatype/ttypedesc3.nim
+++ b/tests/metatype/ttypedesc3.nim
@@ -6,7 +6,7 @@ type
 
 proc pr(T: typedesc[Base]) = echo "proc " & T.name
 method me(T: typedesc[Base]) = echo "method " & T.name
-iterator it(T: typedesc[Base]) = yield "yield " & T.name
+iterator it(T: typedesc[Base]): auto = yield "yield " & T.name
 
 Base.pr
 Child.pr
diff --git a/tests/method/tmultim8.nim b/tests/method/tmultim8.nim
new file mode 100644
index 000000000..0d067b668
--- /dev/null
+++ b/tests/method/tmultim8.nim
@@ -0,0 +1,19 @@
+
+# bug #3550
+
+type 
+  BaseClass = ref object of RootObj
+  Class1 = ref object of BaseClass
+  Class2 = ref object of BaseClass
+  
+method test(obj: Class1, obj2: BaseClass) =
+  discard
+
+method test(obj: Class2, obj2: BaseClass) =
+  discard
+  
+var obj1 = Class1()
+var obj2 = Class2()
+
+obj1.test(obj2) 
+obj2.test(obj1)
diff --git a/tests/openarray/tptrarrayderef.nim b/tests/openarray/tptrarrayderef.nim
new file mode 100644
index 000000000..1e73be108
--- /dev/null
+++ b/tests/openarray/tptrarrayderef.nim
@@ -0,0 +1,54 @@
+discard """
+  file: "tptrarrayderef.nim"
+  output: "OK"
+"""
+
+var
+  arr = [1,2,3]
+  arrp = addr(arr)
+  sss = @[4,5,6,7]
+  sssp = addr(sss)
+  ra = new(array[3, int])
+  raa = [11,12,13]
+
+#bug #3586
+proc mutate[T](arr:openarray[T], brr: openArray[T]) =
+  for i in 0..arr.len-1:
+    doAssert(arr[i] == brr[i])
+    
+mutate(arr, arr)
+
+#bug #2240
+proc f(a: openarray[int], b: openArray[int]) =
+  for i in 0..a.len-1:
+   doAssert(a[i] == b[i])
+
+var a = [7,8,9]
+var p = addr a
+f(p[], a)
+f(sssp[], sss)
+
+ra[0] = 11
+ra[1] = 12
+ra[2] = 13
+f(ra[], raa)
+
+#bug #2240b
+proc fillBuffer(buf: var openarray[char]) =
+  for i in 0..buf.len-1:
+    buf[i] = chr(i)
+
+proc fillSeqBuffer(b: ref seq[char]) =
+  fillBuffer(b[])
+
+proc getFilledBuffer(sz: int): ref seq[char] =
+  let s : ref seq[char] = new(seq[char])
+  s[] = newSeq[char](sz)
+  fillBuffer(s[])
+  return s
+  
+let aa = getFilledBuffer(3)
+for i in 0..aa[].len-1:
+  doAssert(aa[i] == chr(i))
+  
+echo "OK"
\ No newline at end of file
diff --git a/tests/parser/tmultiline_comments.nim b/tests/parser/tmultiline_comments.nim
new file mode 100644
index 000000000..7a3bb5304
--- /dev/null
+++ b/tests/parser/tmultiline_comments.nim
@@ -0,0 +1,64 @@
+discard """
+  output: '''3'''
+"""
+
+proc main* =
+  ##[Mutltie akdlsf comment with #[nesting].
+  Yay, that is so cool.
+  ]##
+  echo "foo bar"
+  for s in ["one", "two", #["three",]# "four"]:
+    echo s
+
+var foo #[ Test the new inline comments ]#: int = 3
+##[ A
+novel documentation comment
+#[Nesting works to some extend]
+##[ Nested doc comment! ]##
+]#
+]##
+echo $foo
+
+  #[Comment here.
+  Multiple lines
+  are not a problem.]#
+
+  #[  #[ Multiline comment in already
+     commented out code. ]#
+  proc p[T](x: T) = discard
+  ]#
+
+proc bar =
+  ##[Long documentation comment
+  here.
+  ]##
+
+
+proc write(a: auto, x: varargs[string, `$`]) =
+  stdout.write ($a)
+  for o in x:
+    stdout.write(o)
+
+proc writeln(a: auto, x: varargs[string, `$`]) =
+  write a, x
+  stdout.write "\n"
+
+proc write() = write(stdout)
+proc writeln() =
+  stdout.write "\n"
+
+#[  #[ Multiline comment in already
+   commented out code. ]#
+proc p[T](x: T) = discard
+]#
+
+var hello = #[(x in bar)^^ "Hello" # greetings
+]#"Hello"
+proc maino =
+  write hello, " Test Me "
+  writeln()
+  write 3
+  block:
+    write()
+    write " times more"
+  #[ test ]#  writeln " Again"
diff --git a/tests/stdlib/tpegs.nim b/tests/stdlib/tpegs.nim
index 3fe964d82..ec839e288 100644
--- a/tests/stdlib/tpegs.nim
+++ b/tests/stdlib/tpegs.nim
@@ -764,7 +764,7 @@ proc match*(s: string, pattern: TPeg, matches: var openarray[string],
   ## returned.
   var c: TCaptures
   c.origStart = start
-  result = rawMatch(s, pattern, start, c) == len(s) -start
+  result = rawMatch(s, pattern, start, c) == len(s)-start
   if result:
     for i in 0..c.ml-1:
       matches[i] = substr(s, c.matches[i][0], c.matches[i][1])
diff --git a/tests/stdlib/ttime.nim b/tests/stdlib/ttime.nim
index efc371995..ac37196fb 100644
--- a/tests/stdlib/ttime.nim
+++ b/tests/stdlib/ttime.nim
@@ -6,89 +6,88 @@ discard """
 import
   times, strutils
 
-assert( $getTime() == getLocalTime(getTime()).format("ddd MMM dd HH:mm:ss yyyy"))
 # $ date --date='@2147483647'
 # Tue 19 Jan 03:14:07 GMT 2038
 
 var t = getGMTime(fromSeconds(2147483647))
-assert t.format("ddd dd MMM hh:mm:ss ZZZ yyyy") == "Tue 19 Jan 03:14:07 UTC 2038"
-assert t.format("ddd ddMMMhh:mm:ssZZZyyyy") == "Tue 19Jan03:14:07UTC2038"
+doAssert t.format("ddd dd MMM hh:mm:ss ZZZ yyyy") == "Tue 19 Jan 03:14:07 UTC 2038"
+doAssert t.format("ddd ddMMMhh:mm:ssZZZyyyy") == "Tue 19Jan03:14:07UTC2038"
 
-assert t.format("d dd ddd dddd h hh H HH m mm M MM MMM MMMM s" &
+doAssert t.format("d dd ddd dddd h hh H HH m mm M MM MMM MMMM s" &
   " ss t tt y yy yyy yyyy yyyyy z zz zzz ZZZ") ==
   "19 19 Tue Tuesday 3 03 3 03 14 14 1 01 Jan January 7 07 A AM 8 38 038 2038 02038 0 00 00:00 UTC"
 
-assert t.format("yyyyMMddhhmmss") == "20380119031407"
+doAssert t.format("yyyyMMddhhmmss") == "20380119031407"
 
 var t2 = getGMTime(fromSeconds(160070789)) # Mon 27 Jan 16:06:29 GMT 1975
-assert t2.format("d dd ddd dddd h hh H HH m mm M MM MMM MMMM s" &
+doAssert t2.format("d dd ddd dddd h hh H HH m mm M MM MMM MMMM s" &
   " ss t tt y yy yyy yyyy yyyyy z zz zzz ZZZ") ==
   "27 27 Mon Monday 4 04 16 16 6 06 1 01 Jan January 29 29 P PM 5 75 975 1975 01975 0 00 00:00 UTC"
 
 when not defined(JS):
   when sizeof(Time) == 8:
     var t3 = getGMTime(fromSeconds(889067643645)) # Fri  7 Jun 19:20:45 BST 30143
-    assert t3.format("d dd ddd dddd h hh H HH m mm M MM MMM MMMM s" &
+    doAssert t3.format("d dd ddd dddd h hh H HH m mm M MM MMM MMMM s" &
       " ss t tt y yy yyy yyyy yyyyy z zz zzz ZZZ") ==
       "7 07 Fri Friday 6 06 18 18 20 20 6 06 Jun June 45 45 P PM 3 43 143 0143 30143 0 00 00:00 UTC"
-    assert t3.format(":,[]()-/") == ":,[]()-/"
+    doAssert t3.format(":,[]()-/") == ":,[]()-/"
 
 var t4 = getGMTime(fromSeconds(876124714)) # Mon  6 Oct 08:58:34 BST 1997
-assert t4.format("M MM MMM MMMM") == "10 10 Oct October"
+doAssert t4.format("M MM MMM MMMM") == "10 10 Oct October"
 
 # Interval tests
-assert((t4 - initInterval(years = 2)).format("yyyy") == "1995")
-assert((t4 - initInterval(years = 7, minutes = 34, seconds = 24)).format("yyyy mm ss") == "1990 24 10")
+doAssert((t4 - initInterval(years = 2)).format("yyyy") == "1995")
+doAssert((t4 - initInterval(years = 7, minutes = 34, seconds = 24)).format("yyyy mm ss") == "1990 24 10")
 
 var s = "Tuesday at 09:04am on Dec 15, 2015"
 var f = "dddd at hh:mmtt on MMM d, yyyy"
-assert($s.parse(f) == "Tue Dec 15 09:04:00 2015")
+doAssert($s.parse(f) == "Tue Dec 15 09:04:00 2015")
 # ANSIC       = "Mon Jan _2 15:04:05 2006"
 s = "Thu Jan 12 15:04:05 2006"
 f = "ddd MMM dd HH:mm:ss yyyy"
-assert($s.parse(f) == "Thu Jan 12 15:04:05 2006")
+doAssert($s.parse(f) == "Thu Jan 12 15:04:05 2006")
 # UnixDate    = "Mon Jan _2 15:04:05 MST 2006"
 s = "Thu Jan 12 15:04:05 MST 2006"
 f = "ddd MMM dd HH:mm:ss ZZZ yyyy"
-assert($s.parse(f) == "Thu Jan 12 15:04:05 2006")
+doAssert($s.parse(f) == "Thu Jan 12 15:04:05 2006")
 # RubyDate    = "Mon Jan 02 15:04:05 -0700 2006"
 s = "Thu Jan 12 15:04:05 -07:00 2006"
 f = "ddd MMM dd HH:mm:ss zzz yyyy"
-assert($s.parse(f) == "Thu Jan 12 15:04:05 2006")
+doAssert($s.parse(f) == "Thu Jan 12 15:04:05 2006")
 # RFC822      = "02 Jan 06 15:04 MST"
 s = "12 Jan 16 15:04 MST"
 f = "dd MMM yy HH:mm ZZZ"
-assert($s.parse(f) == "Tue Jan 12 15:04:00 2016")
+doAssert($s.parse(f) == "Tue Jan 12 15:04:00 2016")
 # RFC822Z     = "02 Jan 06 15:04 -0700" # RFC822 with numeric zone
 s = "12 Jan 16 15:04 -07:00"
 f = "dd MMM yy HH:mm zzz"
-assert($s.parse(f) == "Tue Jan 12 15:04:00 2016")
+doAssert($s.parse(f) == "Tue Jan 12 15:04:00 2016")
 # RFC850      = "Monday, 02-Jan-06 15:04:05 MST"
 s = "Monday, 12-Jan-06 15:04:05 MST"
 f = "dddd, dd-MMM-yy HH:mm:ss ZZZ"
-assert($s.parse(f) == "Thu Jan 12 15:04:05 2006")
+doAssert($s.parse(f) == "Thu Jan 12 15:04:05 2006")
 # RFC1123     = "Mon, 02 Jan 2006 15:04:05 MST"
 s = "Thu, 12 Jan 2006 15:04:05 MST"
 f = "ddd, dd MMM yyyy HH:mm:ss ZZZ"
-assert($s.parse(f) == "Thu Jan 12 15:04:05 2006")
+doAssert($s.parse(f) == "Thu Jan 12 15:04:05 2006")
 # RFC1123Z    = "Mon, 02 Jan 2006 15:04:05 -0700" # RFC1123 with numeric zone
 s = "Thu, 12 Jan 2006 15:04:05 -07:00"
 f = "ddd, dd MMM yyyy HH:mm:ss zzz"
-assert($s.parse(f) == "Thu Jan 12 15:04:05 2006")
+doAssert($s.parse(f) == "Thu Jan 12 15:04:05 2006")
 # RFC3339     = "2006-01-02T15:04:05Z07:00"
 s = "2006-01-12T15:04:05Z-07:00"
 f = "yyyy-MM-ddTHH:mm:ssZzzz"
-assert($s.parse(f) == "Thu Jan 12 15:04:05 2006")
+doAssert($s.parse(f) == "Thu Jan 12 15:04:05 2006")
 f = "yyyy-MM-dd'T'HH:mm:ss'Z'zzz"
-assert($s.parse(f) == "Thu Jan 12 15:04:05 2006")
+doAssert($s.parse(f) == "Thu Jan 12 15:04:05 2006")
 # RFC3339Nano = "2006-01-02T15:04:05.999999999Z07:00"
 s = "2006-01-12T15:04:05.999999999Z-07:00"
 f = "yyyy-MM-ddTHH:mm:ss.999999999Zzzz"
-assert($s.parse(f) == "Thu Jan 12 15:04:05 2006")
+doAssert($s.parse(f) == "Thu Jan 12 15:04:05 2006")
 # Kitchen     = "3:04PM"
 s = "3:04PM"
 f = "h:mmtt"
-assert "15:04:00" in $s.parse(f)
+doAssert "15:04:00" in $s.parse(f)
 #when not defined(testing):
 #  echo "Kitchen: " & $s.parse(f)
 #  var ti = timeToTimeInfo(getTime())
@@ -97,29 +96,54 @@ assert "15:04:00" in $s.parse(f)
 #  echo "Todays date after decoding to interval: ", tint
 
 # checking dayOfWeek matches known days
-assert getDayOfWeek(21, 9, 1900) == dFri
-assert getDayOfWeek(1, 1, 1970) == dThu
-assert getDayOfWeek(21, 9, 1970) == dMon
-assert getDayOfWeek(1, 1, 2000) == dSat
-assert getDayOfWeek(1, 1, 2021) == dFri
+doAssert getDayOfWeek(21, 9, 1900) == dFri
+doAssert getDayOfWeek(1, 1, 1970) == dThu
+doAssert getDayOfWeek(21, 9, 1970) == dMon
+doAssert getDayOfWeek(1, 1, 2000) == dSat
+doAssert getDayOfWeek(1, 1, 2021) == dFri
 # Julian tests
-assert getDayOfWeekJulian(21, 9, 1900) == dFri
-assert getDayOfWeekJulian(21, 9, 1970) == dMon
-assert getDayOfWeekJulian(1, 1, 2000) == dSat
-assert getDayOfWeekJulian(1, 1, 2021) == dFri
+doAssert getDayOfWeekJulian(21, 9, 1900) == dFri
+doAssert getDayOfWeekJulian(21, 9, 1970) == dMon
+doAssert getDayOfWeekJulian(1, 1, 2000) == dSat
+doAssert getDayOfWeekJulian(1, 1, 2021) == dFri
 
 # toSeconds tests with GM and Local timezones
 #var t4 = getGMTime(fromSeconds(876124714)) # Mon  6 Oct 08:58:34 BST 1997
 var t4L = getLocalTime(fromSeconds(876124714))
-assert toSeconds(timeInfoToTime(t4L)) == 876124714    # fromSeconds is effectively "localTime"
-assert toSeconds(timeInfoToTime(t4L)) + t4L.timezone.float == toSeconds(timeInfoToTime(t4))
+doAssert toSeconds(timeInfoToTime(t4L)) == 876124714    # fromSeconds is effectively "localTime"
+doAssert toSeconds(timeInfoToTime(t4L)) + t4L.timezone.float == toSeconds(timeInfoToTime(t4))
 
 # adding intervals
 var
   a1L = toSeconds(timeInfoToTime(t4L + initInterval(hours = 1))) + t4L.timezone.float
   a1G = toSeconds(timeInfoToTime(t4)) + 60.0 * 60.0
-assert a1L == a1G
+doAssert a1L == a1G
+
 # subtracting intervals
 a1L = toSeconds(timeInfoToTime(t4L - initInterval(hours = 1))) + t4L.timezone.float
 a1G = toSeconds(timeInfoToTime(t4)) - (60.0 * 60.0)
-assert a1L == a1G
+doAssert a1L == a1G
+
+# add/subtract TimeIntervals and Time/TimeInfo
+doAssert getTime() - 1.seconds == getTime() - 3.seconds + 2.seconds
+doAssert getTime() + 65.seconds == getTime() + 1.minutes + 5.seconds
+doAssert getTime() + 60.minutes == getTime() + 1.hours
+doAssert getTime() + 24.hours == getTime() + 1.days
+doAssert getTime() + 13.months == getTime() + 1.years + 1.months
+var
+  ti1 = getTime() + 1.years
+ti1 -= 1.years
+doAssert ti1 == getTime()
+ti1 += 1.days
+doAssert ti1 == getTime() + 1.days
+
+# overflow of TimeIntervals on initalisation
+doAssert initInterval(milliseconds = 25000) == initInterval(seconds = 25)
+doAssert initInterval(seconds = 65) == initInterval(seconds = 5, minutes = 1)
+doAssert initInterval(hours = 25) == initInterval(hours = 1, days = 1)
+doAssert initInterval(months = 13) == initInterval(months = 1, years = 1)
+
+# Bug with adding a day to a Time
+let day = 24.hours
+let tomorrow = getTime() + day
+doAssert tomorrow - getTime() == 60*60*24
\ No newline at end of file
diff --git a/tests/types/tillegaltyperecursion.nim b/tests/types/tillegaltyperecursion.nim
index bace2dfc8..52fbd622f 100644
--- a/tests/types/tillegaltyperecursion.nim
+++ b/tests/types/tillegaltyperecursion.nim
@@ -10,14 +10,14 @@ import strutils
 import os
 
 type
-    TMessageReceivedEventArgs = object of TEventArgs
+    TMessageReceivedEventArgs = object of EventArgs
         Nick*: string
         Message*: string
     TIRC = object
-        EventEmitter: TEventEmitter
-        MessageReceivedHandler*: TEventHandler
-        Socket: TSocket
-        Thread: TThread[TIRC]
+        EventEmitter: EventEmitter
+        MessageReceivedHandler*: EventHandler
+        Socket: Socket
+        Thread: Thread[TIRC]
 
 proc initIRC*(): TIRC =
     result.Socket = socket()
@@ -49,8 +49,8 @@ proc handleData(irc: TIRC) {.thread.} =
             return
 
 proc Connect*(irc: var TIRC, nick: string, host: string, port: int = 6667) =
-    connect(irc.Socket ,host ,TPort(port),TDomain.AF_INET)
-    send(irc.Socket,"USER " & nick & " " & nick & " " & nick & " " & nick &"\r\L")
+    connect(irc.Socket, host, TPort(port), TDomain.AF_INET)
+    send(irc.Socket,"USER " & nick & " " & nick & " " & nick & " " & nick & "\r\L")
     send(irc.Socket,"NICK " & nick & "\r\L")
     var thread: TThread[TIRC]
     createThread(thread, handleData, irc)
diff --git a/tests/vm/texcl.nim b/tests/vm/texcl.nim
new file mode 100644
index 000000000..4ccfd6bfa
--- /dev/null
+++ b/tests/vm/texcl.nim
@@ -0,0 +1,27 @@
+discard """
+  output: '''false'''
+"""
+
+import macros
+
+type
+  nlOptions = enum
+    nloNone
+    nloDebug
+
+var nlOpts {.compileTime.} = {nloDebug}
+
+proc initOpts(): set[nlOptions] =
+  result.incl nloDebug
+  result.incl nloNone
+  result.excl nloDebug
+  
+const cOpts = initOpts()
+
+macro nlo(): stmt =
+  nlOpts.incl(nloNone)
+  nlOpts.excl(nloDebug)
+  result = newEmptyNode()
+
+nlo()
+echo nloDebug in cOpts
\ No newline at end of file
diff --git a/tests/vm/ttouintconv.nim b/tests/vm/ttouintconv.nim
new file mode 100644
index 000000000..cd25ffb00
--- /dev/null
+++ b/tests/vm/ttouintconv.nim
@@ -0,0 +1,77 @@
+import macros
+
+discard """
+msg: '''
+8 9 17
+239 255
+61439 65534 65535
+4026531839 4294967294
+17293822569102704639
+18446744073709551614
+18446744073709551615
+127
+32767
+2147483647
+9223372036854775807
+0
+128
+4294967287'''
+"""
+
+#bug #2514
+
+macro foo(): stmt =
+  var x = 8'u8
+  var y = 9'u16
+  var z = 17'u32
+
+  echo x," ", y," ", z
+
+  var a = 0xEF'u8
+  var aa = 0xFF'u8
+  echo a, " ", aa
+
+  var b = 0xEFFF'u16
+  var bb = 0xFFFE'u16
+  var bbb = 0xFFFF'u16
+  echo b, " ", bb, " ", bbb
+
+  var c = 0xEFFFFFFF'u32
+  var cc = 0xFFFFFFFE'u32
+  echo c, " ", cc
+
+  var d = 0xEFFFFFFFFFFFFFFF'u64
+  echo d
+
+  var f = 0xFFFFFFFFFFFFFFFE'u64
+  echo f
+
+  var g = 0xFFFFFFFFFFFFFFFF'u64
+  echo g
+
+  var xx = 0x7F'u8 and 0xFF
+  echo xx
+
+  var yy = 0x7FFF'u16
+  echo yy
+
+  var zz = 0x7FFFFFFF'u32
+  echo zz
+  
+macro foo2(): stmt =
+  var xx = 0x7FFFFFFFFFFFFFFF
+  echo xx
+  
+  var yy = 0
+  echo yy
+  
+  var zz = 0x80'u8
+  echo zz
+  
+  var ww = -9
+  var vv = ww.uint
+  var kk = vv.uint32
+  echo kk
+  
+foo()
+foo2()