summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/actiontable/tactiontable2.nim2
-rw-r--r--tests/ambsym/mambsym1.nim2
-rw-r--r--tests/ambsym/mambsys1.nim2
-rw-r--r--tests/ambsym/mambsys2.nim2
-rw-r--r--tests/array/tarrayplus.nim2
-rw-r--r--tests/async/tasyncawait.nim75
-rw-r--r--tests/bind/tinvalidbindtypedesc.nim (renamed from tests/bind/tbindtypedesc.nim)3
-rw-r--r--tests/casestmt/tcasestm.nim4
-rw-r--r--tests/ccgbugs/tcgbug.nim13
-rw-r--r--tests/collections/tsets.nim (renamed from tests/stdlib/tsets.nim)0
-rw-r--r--tests/compiles/tcompiles.nim2
-rw-r--r--tests/concurrency/tnodeadlocks.nim2
-rw-r--r--tests/destructor/tdestructor.nim54
-rw-r--r--tests/destructor/tdictdestruct.nim2
-rw-r--r--tests/discard/tdiscardable.nim16
-rw-r--r--tests/discard/tneedsdiscard.nim2
-rw-r--r--tests/distinct/tborrowdot.nim13
-rw-r--r--tests/effects/teffects1.nim2
-rw-r--r--tests/effects/teffects6.nim2
-rw-r--r--tests/exception/texceptionbreak.nim45
-rw-r--r--tests/exception/tfinally4.nim40
-rw-r--r--tests/exception/tnestedreturn.nim40
-rw-r--r--tests/exception/tnestedreturn2.nim20
-rw-r--r--tests/exprs/texprstmt.nim2
-rw-r--r--tests/exprs/tifexpr_typeinference.nim20
-rw-r--r--tests/exprs/tstmtexp.nim4
-rw-r--r--tests/exprs/tstmtexprs.nim6
-rw-r--r--tests/generics/tbadgenericlambda.nim7
-rw-r--r--tests/generics/tgeneric3.nim6
-rw-r--r--tests/generics/tgenericlambda.nim23
-rw-r--r--tests/generics/tgenericshardcases.nim18
-rw-r--r--tests/generics/tinferredgenericprocs.nim20
-rw-r--r--tests/generics/tlateboundstatic.nim16
-rw-r--r--tests/generics/tmetafield.nim18
-rw-r--r--tests/generics/tsigtypeop.nim9
-rw-r--r--tests/global/globalaux.nim15
-rw-r--r--tests/global/globalaux2.nim4
-rw-r--r--tests/iter/tanoniter1.nim2
-rw-r--r--tests/iter/tchainediterators.nim38
-rw-r--r--tests/iter/titerable.nim26
-rw-r--r--tests/lookups/tredef.nim14
-rw-r--r--tests/macros/tgensym.nim63
-rw-r--r--tests/macros/tmacro5.nim2
-rw-r--r--tests/macros/tmemit.nim16
-rw-r--r--tests/macros/tvarnimnode.nim19
-rw-r--r--tests/manyloc/argument_parser/argument_parser.nim4
-rw-r--r--tests/manyloc/keineschweine/dependencies/chipmunk/chipmunk.nim7
-rw-r--r--tests/manyloc/keineschweine/dependencies/enet/enet.nim9
-rw-r--r--tests/manyloc/keineschweine/dependencies/sfml/sfml.nim12
-rw-r--r--tests/matrix/issue1013.nim23
-rw-r--r--tests/metatype/swizzle.nim79
-rw-r--r--tests/metatype/tbindtypedesc.nim23
-rw-r--r--tests/metatype/tstaticparams.nim37
-rw-r--r--tests/metatype/tusertypeclasses.nim15
-rw-r--r--tests/metatype/tusertypeclasses2.nim24
-rw-r--r--tests/metatype/typeclassinference.nim10
-rw-r--r--tests/metatype/udtcmanual.nim43
-rw-r--r--tests/method/tmethods1.nim4
-rw-r--r--tests/module/trecinca.nim2
-rw-r--r--tests/module/trecincb.nim2
-rw-r--r--tests/notnil/tnotnil3.nim35
-rw-r--r--tests/objects/tobjpragma.nim49
-rw-r--r--tests/overload/tissue966.nim12
-rw-r--r--tests/overload/toverwr.nim14
-rw-r--r--tests/parser/tstrongspaces.nim52
-rw-r--r--tests/patterns/targlist.nim2
-rw-r--r--tests/range/tsubrange2.nim2
-rw-r--r--tests/range/tsubrange3.nim2
-rw-r--r--tests/sets/tsets.nim18
-rw-r--r--tests/showoff/tdrdobbs_examples.nim2
-rw-r--r--tests/specialops/tdotops.nim66
-rw-r--r--tests/static/tstaticparammacro.nim52
-rw-r--r--tests/stdlib/talgorithm.nim3
-rw-r--r--tests/stdlib/tircbot.nim6
-rw-r--r--tests/stdlib/tmath.nim14
-rw-r--r--tests/stdlib/tmath2.nim2
-rw-r--r--tests/stdlib/tmongo.nim16
-rw-r--r--tests/stdlib/tos.nim2
-rw-r--r--tests/stdlib/tpegs.nim12
-rw-r--r--tests/system/alloc.nim52
-rw-r--r--tests/table/ttableconstr.nim2
-rw-r--r--tests/template/sunset.tmpl (renamed from tests/sunset.tmpl)0
-rw-r--r--tests/template/tissue909.nim16
-rw-r--r--tests/template/tissue993.nim21
-rw-r--r--tests/template/tsymchoicefield.nim12
-rw-r--r--tests/template/ttempl5.nim13
-rw-r--r--tests/testament/categories.nim87
-rw-r--r--tests/testament/htmlgen.nim63
-rw-r--r--tests/testament/specs.nim8
-rw-r--r--tests/testament/tester.nim8
-rw-r--r--tests/threads/nimrod.cfg1
-rw-r--r--tests/threads/tthreadanalysis.nim4
-rw-r--r--tests/typerel/tvoid.nim6
-rw-r--r--tests/typerel/typalias.nim2
-rw-r--r--tests/types/tisopr.nim27
-rw-r--r--tests/vm/tcompiletimetable.nim50
-rw-r--r--tests/vm/tquadplus.nim17
-rw-r--r--tests/vm/trgba.nim36
-rw-r--r--tests/vm/tstaticprintseq.nim78
-rw-r--r--tests/vm/twrongconst.nim7
-rw-r--r--tests/vm/twrongwhen.nim13
101 files changed, 1725 insertions, 146 deletions
diff --git a/tests/actiontable/tactiontable2.nim b/tests/actiontable/tactiontable2.nim
index 00b427603..878356321 100644
--- a/tests/actiontable/tactiontable2.nim
+++ b/tests/actiontable/tactiontable2.nim
@@ -1,6 +1,6 @@
 discard """
   line: 21
-  errormsg: "invalid type: 'TTable'"
+  errormsg: "invalid type: 'TTable[string, proc (string)]'"
 """
 
 import tables
diff --git a/tests/ambsym/mambsym1.nim b/tests/ambsym/mambsym1.nim
index cf8ac5242..d9d57b5e5 100644
--- a/tests/ambsym/mambsym1.nim
+++ b/tests/ambsym/mambsym1.nim
@@ -7,4 +7,4 @@ type
 proc ha() =

   var

     x: TExport # no error

-  nil

+  discard

diff --git a/tests/ambsym/mambsys1.nim b/tests/ambsym/mambsys1.nim
index 5472b5ae4..04f9561d3 100644
--- a/tests/ambsym/mambsys1.nim
+++ b/tests/ambsym/mambsys1.nim
@@ -4,4 +4,4 @@ type
   TExport* = enum x, y, z

 

 proc foo*(x: int) =

-  nil

+  discard

diff --git a/tests/ambsym/mambsys2.nim b/tests/ambsym/mambsys2.nim
index 395425b86..d59706865 100644
--- a/tests/ambsym/mambsys2.nim
+++ b/tests/ambsym/mambsys2.nim
@@ -1,4 +1,4 @@
 type

   TExport* = enum x, y, z # exactly the same type!

 

-proc foo*(x: int) = nil

+proc foo*(x: int) = discard

diff --git a/tests/array/tarrayplus.nim b/tests/array/tarrayplus.nim
index 8c7452e85..9e08bbb0a 100644
--- a/tests/array/tarrayplus.nim
+++ b/tests/array/tarrayplus.nim
@@ -1,5 +1,5 @@
 discard """
-  msg: "type mismatch: got (array[0..2, float], array[0..1, float])"
+  errmsg: "type mismatch: got (array[0..2, float], array[0..1, float])"
 """
 
 proc `+`*[R, T] (v1, v2: array[R, T]): array[R, T] =
diff --git a/tests/async/tasyncawait.nim b/tests/async/tasyncawait.nim
new file mode 100644
index 000000000..bd722842f
--- /dev/null
+++ b/tests/async/tasyncawait.nim
@@ -0,0 +1,75 @@
+discard """
+  file: "tasyncawait.nim"
+  cmd: "nimrod cc --hints:on $# $#"
+  output: "5000"
+"""
+import asyncdispatch, rawsockets, net, strutils, os
+
+var msgCount = 0
+
+const
+  swarmSize = 50
+  messagesToSend = 100
+
+var clientCount = 0
+
+proc sendMessages(client: TAsyncFD) {.async.} =
+  for i in 0 .. <messagesToSend:
+    await send(client, "Message " & $i & "\c\L")
+
+proc launchSwarm(port: TPort) {.async.} =
+  for i in 0 .. <swarmSize:
+    var sock = newAsyncRawSocket()
+
+    await connect(sock, "localhost", port)
+    when true:
+      await sendMessages(sock)
+      close(sock)
+    else:
+      # Issue #932: https://github.com/Araq/Nimrod/issues/932
+      var msgFut = sendMessages(sock)
+      msgFut.callback =
+        proc () =
+          close(sock)
+
+proc readMessages(client: TAsyncFD) {.async.} =
+  while true:
+    var line = await recvLine(client)
+    if line == "":
+      close(client)
+      clientCount.inc
+      break
+    else:
+      if line.startswith("Message "):
+        msgCount.inc
+      else:
+        doAssert false
+
+proc createServer(port: TPort) {.async.} =
+  var server = newAsyncRawSocket()
+  block:
+    var name: TSockaddr_in
+    when defined(windows):
+      name.sin_family = toInt(AF_INET).int16
+    else:
+      name.sin_family = toInt(AF_INET)
+    name.sin_port = htons(int16(port))
+    name.sin_addr.s_addr = htonl(INADDR_ANY)
+    if bindAddr(server.TSocketHandle, cast[ptr TSockAddr](addr(name)),
+                sizeof(name).TSocklen) < 0'i32:
+      osError(osLastError())
+  
+  discard server.TSocketHandle.listen()
+  while true:
+    var client = await accept(server)
+    readMessages(client)
+    # TODO: Test: readMessages(disp, await disp.accept(server))
+
+createServer(TPort(10335))
+launchSwarm(TPort(10335))
+while true:
+  poll()
+  if clientCount == swarmSize: break
+
+assert msgCount == swarmSize * messagesToSend
+echo msgCount
diff --git a/tests/bind/tbindtypedesc.nim b/tests/bind/tinvalidbindtypedesc.nim
index d6fbae537..5b2f51110 100644
--- a/tests/bind/tbindtypedesc.nim
+++ b/tests/bind/tinvalidbindtypedesc.nim
@@ -1,6 +1,5 @@
 discard """
-  line: 11
-  file: "tbindtypedesc.nim"
+  line: 10
   errormsg: "type mismatch: got (typedesc[float], string)"
 """
 
diff --git a/tests/casestmt/tcasestm.nim b/tests/casestmt/tcasestm.nim
index 003ec6e50..b033b98ec 100644
--- a/tests/casestmt/tcasestm.nim
+++ b/tests/casestmt/tcasestm.nim
@@ -19,8 +19,8 @@ of eB, eC: write(stdout, "b or c")
 case x
 of "Andreas", "Rumpf": write(stdout, "Hallo Meister!")
 of "aa", "bb": write(stdout, "Du bist nicht mein Meister")
-of "cc", "hash", "when": nil
-of "will", "it", "finally", "be", "generated": nil
+of "cc", "hash", "when": discard
+of "will", "it", "finally", "be", "generated": discard
 
 var z = case i
   of 1..5, 8, 9: "aa"
diff --git a/tests/ccgbugs/tcgbug.nim b/tests/ccgbugs/tcgbug.nim
index 417b909ae..535424a27 100644
--- a/tests/ccgbugs/tcgbug.nim
+++ b/tests/ccgbugs/tcgbug.nim
@@ -19,5 +19,18 @@ var
 new(a)
 q(a)
 
+# bug #914
+var x = newWideCString("Hello")
+
 echo "success"
 
+
+# bug #833
+
+type
+  PFuture*[T] = ref object
+    value*: T
+    finished*: bool
+    cb: proc (future: PFuture[T]) {.closure.}
+
+var k = PFuture[void]()
diff --git a/tests/stdlib/tsets.nim b/tests/collections/tsets.nim
index 656c5b3f2..656c5b3f2 100644
--- a/tests/stdlib/tsets.nim
+++ b/tests/collections/tsets.nim
diff --git a/tests/compiles/tcompiles.nim b/tests/compiles/tcompiles.nim
index d0fccdaff..b3d9c17ce 100644
--- a/tests/compiles/tcompiles.nim
+++ b/tests/compiles/tcompiles.nim
@@ -24,3 +24,5 @@ ok supports(`+`, 34)
 
 no compiles(4+5.0 * "hallo")
 
+no compiles(undeclaredIdentifier)
+no compiles(undeclaredIdentifier)
diff --git a/tests/concurrency/tnodeadlocks.nim b/tests/concurrency/tnodeadlocks.nim
index 18fdca3e9..3f27e24f6 100644
--- a/tests/concurrency/tnodeadlocks.nim
+++ b/tests/concurrency/tnodeadlocks.nim
@@ -12,7 +12,7 @@ var
   thr: array [0..5, TThread[tuple[a, b: int]]]
   L, M, N: TLock
 
-proc doNothing() = nil
+proc doNothing() = discard
 
 proc threadFunc(interval: tuple[a, b: int]) {.thread.} = 
   doNothing()
diff --git a/tests/destructor/tdestructor.nim b/tests/destructor/tdestructor.nim
index bb1410d92..e5236aaab 100644
--- a/tests/destructor/tdestructor.nim
+++ b/tests/destructor/tdestructor.nim
@@ -12,6 +12,13 @@ myobj destroyed
 ----
 mygeneric3 constructed
 mygeneric1 destroyed
+----
+mygeneric1 destroyed
+----
+myobj destroyed
+----
+----
+myobj destroyed
 '''
 """
 
@@ -31,6 +38,22 @@ type
     x: A
     y: B
     z: C
+  
+  TObjKind = enum A, B, C, D
+
+  TCaseObj = object
+    case kind: TObjKind
+    of A:
+      x: TMyGeneric1[int]
+    of B, C:
+      y: TMyObj
+    else:
+      case innerKind: TObjKind
+      of A, B, C:
+        p: TMyGeneric3[int, float, string]
+      of D:
+        q: TMyGeneric3[TMyObj, int, int]
+      r: string
 
 proc destruct(o: var TMyObj) {.destructor.} =
   if o.p != nil: dealloc o.p
@@ -57,13 +80,13 @@ proc mygeneric1() =
   echo "mygeneric1 constructed"
 
 proc mygeneric2[T](val: T) =
-  var
-    a = open()
-    b = TMyGeneric2[int, T](x: 10, y: val)
-    c = TMyGeneric3[int, int, string](x: 10, y: 20, z: "test")
-
+  var a = open()
+  
+  var b = TMyGeneric2[int, T](x: 10, y: val)
   echo "mygeneric2 constructed"
 
+  var c = TMyGeneric3[int, int, string](x: 10, y: 20, z: "test")
+  
 proc mygeneric3 =
   var x = TMyGeneric3[int, string, TMyGeneric1[int]](
     x: 10, y: "test", z: TMyGeneric1[int](x: 10))
@@ -82,3 +105,24 @@ mygeneric2[int](10)
 echo "----"
 mygeneric3()
 
+proc caseobj =
+  block:
+    echo "----"
+    var o1 = TCaseObj(kind: A, x: TMyGeneric1[int](x: 10))
+  
+  block:
+    echo "----"
+    var o2 = TCaseObj(kind: B, y: open())
+  
+  block:
+    echo "----"
+    var o3 = TCaseObj(kind: D, innerKind: B, r: "test",
+                      p: TMyGeneric3[int, float, string](x: 10, y: 1.0, z: "test"))
+
+  block:
+    echo "----"
+    var o4 = TCaseObj(kind: D, innerKind: D, r: "test",
+                      q: TMyGeneric3[TMyObj, int, int](x: open(), y: 1, z: 0))
+
+caseobj()
+
diff --git a/tests/destructor/tdictdestruct.nim b/tests/destructor/tdictdestruct.nim
index ec1084105..b7043f7b7 100644
--- a/tests/destructor/tdictdestruct.nim
+++ b/tests/destructor/tdictdestruct.nim
@@ -6,7 +6,7 @@ type
   PDict[TK, TV] = ref TDict[TK, TV]
 
 proc fakeNew[T](x: var ref T, destroy: proc (a: ref T) {.nimcall.}) =
-  nil
+  discard
 
 proc destroyDict[TK, TV](a: PDict[TK, TV]) =
     return
diff --git a/tests/discard/tdiscardable.nim b/tests/discard/tdiscardable.nim
index c0551ba2f..a806ccdce 100644
--- a/tests/discard/tdiscardable.nim
+++ b/tests/discard/tdiscardable.nim
@@ -11,3 +11,19 @@ proc q[T](x, y: T): T {.discardable.} =
 p(8, 2)
 q[float](0.8, 0.2)
 
+# bug #942
+
+template maybeMod(x: Tinteger, module:Natural):expr =
+  if module > 0: x mod module
+  else: x
+
+proc foo(b: int):int =
+  var x = 1
+  result = x.maybeMod(b) # Works fine
+
+proc bar(b: int):int =
+  result = 1
+  result = result.maybeMod(b) # Error: value returned by statement has to be discarded
+
+echo foo(0)
+echo bar(0)
diff --git a/tests/discard/tneedsdiscard.nim b/tests/discard/tneedsdiscard.nim
index 24f5b2eee..2a7856b4a 100644
--- a/tests/discard/tneedsdiscard.nim
+++ b/tests/discard/tneedsdiscard.nim
@@ -1,6 +1,6 @@
 discard """
   line: 10
-  errormsg: "value returned by statement has to be discarded"
+  errormsg: "value of type 'bool' has to be discarded"
 """
 
 proc p =
diff --git a/tests/distinct/tborrowdot.nim b/tests/distinct/tborrowdot.nim
new file mode 100644
index 000000000..820ee3b71
--- /dev/null
+++ b/tests/distinct/tborrowdot.nim
@@ -0,0 +1,13 @@
+
+type
+  Foo = object
+    a, b: int
+    s: string
+
+  Bar {.borrow: `.`.} = distinct Foo
+
+var bb: ref Bar
+new bb
+bb.a = 90
+bb.s = "abc"
+
diff --git a/tests/effects/teffects1.nim b/tests/effects/teffects1.nim
index b72e8b00c..0014cff46 100644
--- a/tests/effects/teffects1.nim
+++ b/tests/effects/teffects1.nim
@@ -1,5 +1,5 @@
 discard """
-  line: 1855
+  line: 1913
   file: "system.nim"
   errormsg: "can raise an unlisted exception: ref EIO"
 """
diff --git a/tests/effects/teffects6.nim b/tests/effects/teffects6.nim
index 54200f2c3..47c85c160 100644
--- a/tests/effects/teffects6.nim
+++ b/tests/effects/teffects6.nim
@@ -4,7 +4,7 @@ type
   PMenuItem = ref object
 
 proc createMenuItem*(menu: PMenu, label: string, 
-                     action: proc (i: PMenuItem, p: pointer) {.cdecl.}) = nil
+                    action: proc (i: PMenuItem, p: pointer) {.cdecl.}) = discard
 
 var s: PMenu
 createMenuItem(s, "Go to definition...",
diff --git a/tests/exception/texceptionbreak.nim b/tests/exception/texceptionbreak.nim
new file mode 100644
index 000000000..76e986787
--- /dev/null
+++ b/tests/exception/texceptionbreak.nim
@@ -0,0 +1,45 @@
+discard """
+  file: "tnestedbreak.nim"
+  output: "1\n2\n3\n4"
+"""
+
+# First variety
+try:
+  raise newException(EOS, "Problem")
+except EOS:
+  for y in [1, 2, 3]:
+    discard
+  try:
+    discard
+  except EOS:
+    discard
+echo "1"
+
+# Second Variety
+try:
+  raise newException(EOS, "Problem")
+except EOS:
+  for y in [1, 2, 3]:
+    discard
+  for y in [1, 2, 3]:
+    discard
+
+echo "2"
+
+# Third Variety
+try:
+  raise newException(EOS, "Problem")
+except EOS:
+  block:
+    break
+
+echo "3"
+
+# Fourth Variety
+block:
+  try:
+    raise newException(EOS, "Problem")
+  except EOS:
+    break
+
+echo "4"
\ No newline at end of file
diff --git a/tests/exception/tfinally4.nim b/tests/exception/tfinally4.nim
new file mode 100644
index 000000000..05c57c4f5
--- /dev/null
+++ b/tests/exception/tfinally4.nim
@@ -0,0 +1,40 @@
+discard """
+  file: "tfinally4.nim"
+  output: "B1\nA1\n1\nB1\nB2\ncatch\nA1\n1\nB1\nA1\nA2\n2\nB1\nB2\ncatch\nA1\nA2\n0\nB1\nA1\n1\nB1\nB2\nA1\n1\nB1\nA1\nA2\n2\nB1\nB2\nA1\nA2\n3"
+"""
+
+# More thorough test of return-in-finaly
+
+var raiseEx = true
+var returnA = true
+var returnB = false
+ 
+proc main: int = 
+  try: #A
+    try: #B
+      if raiseEx:
+        raise newException(EOS, "")
+      return 3
+    finally: #B
+      echo "B1"
+      if returnB:
+        return 2
+      echo "B2"
+  except EOS: #A
+    echo "catch"
+  finally: #A
+    echo "A1"
+    if returnA:
+      return 1
+    echo "A2"
+
+for x in [true, false]:
+  for y in [true, false]:
+    for z in [true, false]:
+      # echo "raiseEx: " & $x
+      # echo "returnA: " & $y
+      # echo "returnB: " & $z
+      raiseEx = x
+      returnA = y
+      returnB = z
+      echo main()
diff --git a/tests/exception/tnestedreturn.nim b/tests/exception/tnestedreturn.nim
new file mode 100644
index 000000000..b9f7843f6
--- /dev/null
+++ b/tests/exception/tnestedreturn.nim
@@ -0,0 +1,40 @@
+discard """
+  file: "tnestedreturn.nim"
+  output: "A\nB\nC\n"
+"""
+
+# Various tests of return nested in double try/except statements
+
+proc test1() =
+
+  finally: echo "A"
+
+  try:
+    raise newException(EOS, "Problem")
+  except EOS:
+    return
+
+test1()
+
+
+proc test2() =
+
+  finally: echo "B"
+
+  try:
+    return
+  except EOS:
+    discard
+
+test2()
+
+proc test3() =
+  try:
+    try:
+      raise newException(EOS, "Problem")
+    except EOS:
+      return
+  finally:
+    echo "C"
+
+test3()
diff --git a/tests/exception/tnestedreturn2.nim b/tests/exception/tnestedreturn2.nim
new file mode 100644
index 000000000..14a2dab92
--- /dev/null
+++ b/tests/exception/tnestedreturn2.nim
@@ -0,0 +1,20 @@
+discard """
+  file: "tnestedreturn.nim"
+  outputsub: "Error: unhandled exception: Problem [EOS]"
+  exitcode: "1"
+"""
+
+proc test4() =
+  try:
+    try:
+      raise newException(EOS, "Problem")
+    except EOS:
+      return
+  finally:
+    discard
+
+# Should cause unhandled exception error,
+# but could cause segmentation fault if 
+# exceptions are not handled properly.
+test4()
+raise newException(EOS, "Problem")
diff --git a/tests/exprs/texprstmt.nim b/tests/exprs/texprstmt.nim
index b32394d8d..355da2407 100644
--- a/tests/exprs/texprstmt.nim
+++ b/tests/exprs/texprstmt.nim
@@ -1,6 +1,6 @@
 discard """
   line: 10
-  errormsg: "value returned by statement has to be discarded"
+  errormsg: "value of type 'string' has to be discarded"
 """
 
 # bug #578
diff --git a/tests/exprs/tifexpr_typeinference.nim b/tests/exprs/tifexpr_typeinference.nim
new file mode 100644
index 000000000..3ae95c571
--- /dev/null
+++ b/tests/exprs/tifexpr_typeinference.nim
@@ -0,0 +1,20 @@
+#bug #712
+
+import tables
+
+proc test(): TTable[string, string] =
+  discard
+
+proc test2(): TTable[string, string] =
+  discard
+
+var x = 5
+let blah =
+  case x
+  of 5:
+    test2()
+  of 2:
+    test()
+  else: test()
+
+echo blah.len
diff --git a/tests/exprs/tstmtexp.nim b/tests/exprs/tstmtexp.nim
index 7cbf2eb3d..fe60dd3ba 100644
--- a/tests/exprs/tstmtexp.nim
+++ b/tests/exprs/tstmtexp.nim
@@ -1,9 +1,9 @@
 discard """
   file: "tstmtexp.nim"
   line: 8
-  errormsg: "value returned by statement has to be discarded"
+  errormsg: "value of type 'int literal(5)' has to be discarded"
 """
 # Test 3
 
-1+4 #ERROR_MSG value returned by statement has to be discarded
+1+4
 
diff --git a/tests/exprs/tstmtexprs.nim b/tests/exprs/tstmtexprs.nim
index 816e58cb1..ed0066287 100644
--- a/tests/exprs/tstmtexprs.nim
+++ b/tests/exprs/tstmtexprs.nim
@@ -86,3 +86,9 @@ proc parseResponse(): PJsonNode =
     if (var n=result["key2"]; n != nil):
       excMsg &= n.str
     raise newException(ESynch, excMsg)
+
+
+
+#bug #992
+var se = @[1,2]
+let b = (se[1] = 1; 1)
diff --git a/tests/generics/tbadgenericlambda.nim b/tests/generics/tbadgenericlambda.nim
new file mode 100644
index 000000000..38e7f6cd7
--- /dev/null
+++ b/tests/generics/tbadgenericlambda.nim
@@ -0,0 +1,7 @@
+discard """
+  errmsg: "nested proc can have generic parameters only when"
+  line: 6
+"""
+
+let x = proc (x, y): auto = x + y
+
diff --git a/tests/generics/tgeneric3.nim b/tests/generics/tgeneric3.nim
index 3c543ecfa..963d0ccfb 100644
--- a/tests/generics/tgeneric3.nim
+++ b/tests/generics/tgeneric3.nim
@@ -32,7 +32,7 @@ const
 proc len[T,D] (n:PNode[T,D]): Int {.inline.} =
   return n.Count
 
-proc clean[T: TOrdinal|TNumber](o: var T) {.inline.} = nil
+proc clean[T: TOrdinal|TNumber](o: var T) {.inline.} = discard
 
 proc clean[T: string|seq](o: var T) {.inline.} =
   o = nil
@@ -98,7 +98,7 @@ proc DeleteItem[T,D] (n: PNode[T,D], x: Int): PNode[T,D] {.inline.} =
     of cLen3 : setLen(n.slots, cLen3)
     of cLenCenter : setLen(n.slots, cLenCenter)
     of cLen4 : setLen(n.slots, cLen4)
-    else: nil
+    else: discard
     Result = n
 
   else :
@@ -232,7 +232,7 @@ proc InsertItem[T,D](APath: RPath[T,D], ANode:PNode[T,D], AKey: T, AValue: D) =
   of cLen3: setLen(APath.Nd.slots, cLenCenter)
   of cLenCenter: setLen(APath.Nd.slots, cLen4)
   of cLen4: setLen(APath.Nd.slots, cLenMax)
-  else: nil
+  else: discard
   for i in countdown(APath.Nd.Count.int - 1, x + 1): shallowCopy(APath.Nd.slots[i], APath.Nd.slots[i - 1])
   APath.Nd.slots[x] = setItem(AKey, AValue, ANode)
 
diff --git a/tests/generics/tgenericlambda.nim b/tests/generics/tgenericlambda.nim
new file mode 100644
index 000000000..eb6ada3e5
--- /dev/null
+++ b/tests/generics/tgenericlambda.nim
@@ -0,0 +1,23 @@
+discard """
+  output: "10\n10\n1\n2\n3\n15"
+"""
+
+proc test(x: proc (a, b: int): int) =
+  echo x(5, 5)
+
+test(proc (a, b): auto = a + b)
+
+test do (a, b) -> auto: a + b
+
+proc foreach[T](s: seq[T], body: proc(x: T)) =
+  for e in s:
+    body(e)
+
+foreach(@[1,2,3]) do (x):
+  echo x
+
+proc foo =
+  let x = proc (a, b: int): auto = a + b
+  echo x(5, 10)
+
+foo()
diff --git a/tests/generics/tgenericshardcases.nim b/tests/generics/tgenericshardcases.nim
index 2ef63bc20..e3b805db6 100644
--- a/tests/generics/tgenericshardcases.nim
+++ b/tests/generics/tgenericshardcases.nim
@@ -14,7 +14,8 @@ macro selectType(a, b: typedesc): typedesc =
 type
   Foo[T] = object
     data1: array[T.high, int]
-    data2: array[typeNameLen(T), float] # data3: array[0..T.typeNameLen, selectType(float, int)]
+    data2: array[typeNameLen(T), float]
+    data3: array[0..T.typeNameLen, selectType(float, int)]
 
   MyEnum = enum A, B, C, D
 
@@ -27,10 +28,15 @@ echo high(f1.data2) # (MyEnum.len = 6) - 1 == 5
 echo high(f2.data1) # 127 - 1 == 126
 echo high(f2.data2) # int8.len - 1 == 3
 
-#static:
-# assert high(f1.data1) == ord(D)
-# assert high(f1.data2) == 6 # length of MyEnum
+static:
+  assert high(f1.data1) == ord(C)
+  assert high(f1.data2) == 5 # length of MyEnum minus one, because we used T.high
 
-# assert high(f2.data1) == 127
-# assert high(f2.data2) == 4 # length of int8
+  assert high(f2.data1) == 126
+  assert high(f2.data2) == 3 
+
+  assert high(f1.data3) == 6 # length of MyEnum
+  assert high(f2.data3) == 4 # length of int8
+
+  assert f2.data3[0] is float
 
diff --git a/tests/generics/tinferredgenericprocs.nim b/tests/generics/tinferredgenericprocs.nim
new file mode 100644
index 000000000..ac445fd32
--- /dev/null
+++ b/tests/generics/tinferredgenericprocs.nim
@@ -0,0 +1,20 @@
+discard """
+  output: '''123
+1
+2
+3'''
+"""
+
+# https://github.com/Araq/Nimrod/issues/797
+proc foo[T](s:T):string = $s
+
+type IntStringProc = proc(x: int): string 
+
+var f1 = IntStringProc(foo)
+var f2: proc(x: int): string = foo
+var f3: IntStringProc = foo
+
+echo f1(1), f2(2), f3(3)
+
+for x in map([1,2,3], foo): echo x
+
diff --git a/tests/generics/tlateboundstatic.nim b/tests/generics/tlateboundstatic.nim
new file mode 100644
index 000000000..f68f95f8d
--- /dev/null
+++ b/tests/generics/tlateboundstatic.nim
@@ -0,0 +1,16 @@
+discard """
+  msg: "array[0..3, int]"
+"""
+
+type
+  KK[I: static[int]] = object
+   x: array[I, int]
+
+proc foo(a: static[string]): KK[a.len] =
+  result.x[0] = 12
+
+var x = foo "test"
+
+import typetraits
+static: echo x.x.type.name
+
diff --git a/tests/generics/tmetafield.nim b/tests/generics/tmetafield.nim
new file mode 100644
index 000000000..8e7f26549
--- /dev/null
+++ b/tests/generics/tmetafield.nim
@@ -0,0 +1,18 @@
+discard """
+  cmd: "nimrod check $# $#"
+  errmsg: "'proc' is not a concrete type"
+  errmsg: "'Foo' is not a concrete type."
+  errmsg: "invalid type: 'TBaseMed'"
+"""
+
+type
+  Foo[T] = object
+    x: T
+
+  TBaseMed =  object
+    doSmth: proc
+    data: seq[Foo]
+
+var a: TBaseMed
+
+# issue 188
diff --git a/tests/generics/tsigtypeop.nim b/tests/generics/tsigtypeop.nim
new file mode 100644
index 000000000..4c863cba1
--- /dev/null
+++ b/tests/generics/tsigtypeop.nim
@@ -0,0 +1,9 @@
+type
+  Vec3[T] = array[3, T]
+
+proc foo(x: Vec3, y: Vec3.T, z: x.T): x.type.T =
+  return 10
+
+var y: Vec3[int] = [1, 2, 3]
+var z: int = foo(y, 3, 4)
+
diff --git a/tests/global/globalaux.nim b/tests/global/globalaux.nim
new file mode 100644
index 000000000..5f6f72721
--- /dev/null
+++ b/tests/global/globalaux.nim
@@ -0,0 +1,15 @@
+type 
+  TObj*[T] = object
+    val*: T
+
+var
+  totalGlobals* = 0
+
+proc makeObj[T](x: T): TObj[T] =
+  totalGlobals += 1
+  result.val = x
+
+proc globalInstance*[T]: var TObj[T] =
+  var g {.global.} = when T is int: makeObj(10) else: makeObj("hello")
+  result = g
+
diff --git a/tests/global/globalaux2.nim b/tests/global/globalaux2.nim
new file mode 100644
index 000000000..6c77f1f48
--- /dev/null
+++ b/tests/global/globalaux2.nim
@@ -0,0 +1,4 @@
+import globalaux
+
+echo "in globalaux2: ", globalInstance[int]().val
+
diff --git a/tests/iter/tanoniter1.nim b/tests/iter/tanoniter1.nim
index 578749caf..9f0d0a74b 100644
--- a/tests/iter/tanoniter1.nim
+++ b/tests/iter/tanoniter1.nim
@@ -8,7 +8,7 @@ discard """
 """
 
 proc factory(a, b: int): iterator (): int =
-  iterator foo(): int =
+  iterator foo(): int {.closure.} =
     var x = a
     while x <= b:
       yield x
diff --git a/tests/iter/tchainediterators.nim b/tests/iter/tchainediterators.nim
new file mode 100644
index 000000000..18d096761
--- /dev/null
+++ b/tests/iter/tchainediterators.nim
@@ -0,0 +1,38 @@
+discard """
+  output: '''16
+32
+48
+64
+128
+192
+'''
+"""
+
+iterator gaz(it: iterator{.inline.}): type(it) =
+  for x in it:
+    yield x*2
+
+iterator baz(it: iterator{.inline.}) =
+  for x in gaz(it):
+    yield x*2
+
+type T1 = auto
+
+iterator bar(it: iterator: T1{.inline.}): T1 =
+  for x in baz(it):
+    yield x*2
+
+iterator foo[T](x: iterator: T{.inline.}): T =
+  for e in bar(x):
+    yield e*2
+
+var s = @[1, 2, 3]
+
+# pass an interator several levels deep:
+for x in s.items.foo:
+  echo x
+
+# use some complex iterator as an input for another one:
+for x in s.items.baz.foo:
+  echo x
+
diff --git a/tests/iter/titerable.nim b/tests/iter/titerable.nim
new file mode 100644
index 000000000..3ec79f68d
--- /dev/null
+++ b/tests/iter/titerable.nim
@@ -0,0 +1,26 @@
+discard """
+  output: '''2
+4
+6
+4
+8
+12
+'''
+"""
+
+iterator map[T, U](s: iterator:T{.inline.}, f: proc(x: T): U): U =
+  for e in s: yield f(e)
+
+template toSeq(s: expr): expr =
+  var res = newSeq[type(s)](0)
+  for e in s: res.add(e)
+  res
+
+var s1 = @[1, 2, 3]
+for x in map(s1.items, proc (a:int): int = a*2):
+  echo x
+
+var s2 = toSeq(map(s1.items, proc (a:int): int = a*4))
+for x in s2:
+  echo x
+
diff --git a/tests/lookups/tredef.nim b/tests/lookups/tredef.nim
index 02d1f7776..a1647000c 100644
--- a/tests/lookups/tredef.nim
+++ b/tests/lookups/tredef.nim
@@ -1,28 +1,28 @@
-template foo(a: int, b: string) = nil
+template foo(a: int, b: string) = discard
 foo(1, "test")
 
-proc bar(a: int, b: string) = nil
+proc bar(a: int, b: string) = discard
 bar(1, "test")
 
 template foo(a: int, b: string) = bar(a, b)
 foo(1, "test")
 
 block:
-  proc bar(a: int, b: string) = nil
-  template foo(a: int, b: string) = nil
+  proc bar(a: int, b: string) = discard
+  template foo(a: int, b: string) = discard
   foo(1, "test")
   bar(1, "test")
   
 proc baz =
-  proc foo(a: int, b: string) = nil
+  proc foo(a: int, b: string) = discard
   proc foo(b: string) =
-    template bar(a: int, b: string) = nil
+    template bar(a: int, b: string) = discard
     bar(1, "test")
     
   foo("test")
 
   block:
-    proc foo(b: string) = nil
+    proc foo(b: string) = discard
     foo("test")
     foo(1, "test")
 
diff --git a/tests/macros/tgensym.nim b/tests/macros/tgensym.nim
new file mode 100644
index 000000000..3f4140ff4
--- /dev/null
+++ b/tests/macros/tgensym.nim
@@ -0,0 +1,63 @@
+import rawsockets, asyncdispatch, macros
+var p = newDispatcher()
+var sock = newAsyncRawSocket()
+
+proc convertReturns(node, retFutureSym: PNimrodNode): PNimrodNode {.compileTime.} =
+  case node.kind
+  of nnkReturnStmt:
+    result = newCall(newIdentNode("complete"), retFutureSym, node[0])
+  else:
+    result = node
+    for i in 0 .. <node.len:
+      result[i] = convertReturns(node[i], retFutureSym)
+
+macro async2(prc: stmt): stmt {.immediate.} =
+  expectKind(prc, nnkProcDef)
+
+  var outerProcBody = newNimNode(nnkStmtList)
+
+  # -> var retFuture = newFuture[T]()
+  var retFutureSym = newIdentNode("retFuture") #genSym(nskVar, "retFuture")
+  outerProcBody.add(
+    newVarStmt(retFutureSym, 
+      newCall(
+        newNimNode(nnkBracketExpr).add(
+          newIdentNode("newFuture"),
+          prc[3][0][1])))) # Get type from return type of this proc.
+
+  # -> iterator nameIter(): PFutureBase {.closure.} = <proc_body>
+  # Changing this line to: newIdentNode($prc[0].ident & "Iter") # will make it work.
+  var iteratorNameSym = genSym(nskIterator, $prc[0].ident & "Iter")
+  #var iteratorNameSym = newIdentNode($prc[0].ident & "Iter")
+  var procBody = prc[6].convertReturns(retFutureSym)
+
+  var closureIterator = newProc(iteratorNameSym, [newIdentNode("PFutureBase")],
+                                procBody, nnkIteratorDef)
+  closureIterator[4] = newNimNode(nnkPragma).add(newIdentNode("closure"))
+  outerProcBody.add(closureIterator)
+
+  # -> var nameIterVar = nameIter
+  # -> var first = nameIterVar()
+  var varNameIterSym = newIdentNode($prc[0].ident & "IterVar") #genSym(nskVar, $prc[0].ident & "IterVar")
+  var varNameIter = newVarStmt(varNameIterSym, iteratorNameSym)
+  outerProcBody.add varNameIter
+  var varFirstSym = genSym(nskVar, "first")
+  var varFirst = newVarStmt(varFirstSym, newCall(varNameIterSym))
+  outerProcBody.add varFirst
+
+
+  result = prc
+
+  # Remove the 'closure' pragma.
+  for i in 0 .. <result[4].len:
+    if result[4][i].ident == !"async":
+      result[4].del(i)
+
+  result[6] = outerProcBody
+
+proc readStuff(): PFuture[string] {.async2.} =
+  var fut = connect(sock, "irc.freenode.org", TPort(6667))
+  yield fut
+  var fut2 = recv(sock, 50)
+  yield fut2
+  return fut2.read
diff --git a/tests/macros/tmacro5.nim b/tests/macros/tmacro5.nim
index 39324e497..9882ad90d 100644
--- a/tests/macros/tmacro5.nim
+++ b/tests/macros/tmacro5.nim
@@ -51,7 +51,7 @@ macro okayy:stmt =
   for node in decls: result.add node
   for node in impls: result.add node
 
-importimpl(Item, int):
+importImpl(Item, int):
   echo 42
 importImpl(Foo, int16):
   echo 77
diff --git a/tests/macros/tmemit.nim b/tests/macros/tmemit.nim
index 6fb2f3b65..e5aed3172 100644
--- a/tests/macros/tmemit.nim
+++ b/tests/macros/tmemit.nim
@@ -1,7 +1,21 @@
 discard """
-  output: '''HELLO WORLD'''
+  output: '''HELLO WORLD
+c_func'''
 """
 
 import macros, strutils
 
 emit("echo " & '"' & "hello world".toUpper & '"')
+
+# bug #1025
+
+macro foo(icname): stmt =
+  let ic = newStrLitNode($icname)
+  result = quote do:
+    proc x* =
+      proc private {.exportc: `ic`.} = discard
+      echo `ic`
+      private()
+
+foo(c_func)
+x()
diff --git a/tests/macros/tvarnimnode.nim b/tests/macros/tvarnimnode.nim
new file mode 100644
index 000000000..73fcc16ea
--- /dev/null
+++ b/tests/macros/tvarnimnode.nim
@@ -0,0 +1,19 @@
+discard """
+  output: 10
+"""
+
+#bug #926
+
+import macros
+
+proc test(f: var PNimrodNode) {.compileTime.} =
+  f = newNimNode(nnkStmtList)
+  f.add newCall(newIdentNode("echo"), newLit(10))
+
+macro blah(prc: stmt): stmt =
+  result = prc
+
+  test(result)
+
+proc test() {.blah.} =
+  echo 5
diff --git a/tests/manyloc/argument_parser/argument_parser.nim b/tests/manyloc/argument_parser/argument_parser.nim
index 95c71c08c..1edda4aa0 100644
--- a/tests/manyloc/argument_parser/argument_parser.nim
+++ b/tests/manyloc/argument_parser/argument_parser.nim
@@ -178,14 +178,14 @@ template new_parsed_parameter*(tkind: Tparam_kind, expr): Tparsed_parameter =
   ##     #parsed_param3 = new_parsed_parameter(PK_INT, "231")
   var result {.gensym.}: Tparsed_parameter
   result.kind = tkind
-  when tkind == PK_EMPTY: nil
+  when tkind == PK_EMPTY: discard
   elif tkind == PK_INT: result.int_val = expr
   elif tkind == PK_BIGGEST_INT: result.big_int_val = expr
   elif tkind == PK_FLOAT: result.float_val = expr
   elif tkind == PK_BIGGEST_FLOAT: result.big_float_val = expr
   elif tkind == PK_STRING: result.str_val = expr
   elif tkind == PK_BOOL: result.bool_val = expr
-  elif tkind == PK_HELP: nil
+  elif tkind == PK_HELP: discard
   else: {.error: "unknown kind".}
   result
 
diff --git a/tests/manyloc/keineschweine/dependencies/chipmunk/chipmunk.nim b/tests/manyloc/keineschweine/dependencies/chipmunk/chipmunk.nim
index 8226b0b04..d9c933939 100644
--- a/tests/manyloc/keineschweine/dependencies/chipmunk/chipmunk.nim
+++ b/tests/manyloc/keineschweine/dependencies/chipmunk/chipmunk.nim
@@ -18,10 +18,9 @@
 #  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 #  SOFTWARE.
 # 
-when defined(Linux):
-  const Lib = "libchipmunk.so.6.1.1"
-else:
-  {.error: "Platform unsupported".}
+
+const Lib = "libchipmunk.so.6.1.1"
+
 when defined(MoreNimrod):
   {.hint: "MoreNimrod defined; some Chipmunk functions replaced in Nimrod".}
 {.deadCodeElim: on.}
diff --git a/tests/manyloc/keineschweine/dependencies/enet/enet.nim b/tests/manyloc/keineschweine/dependencies/enet/enet.nim
index ad43c69b7..df1b743ee 100644
--- a/tests/manyloc/keineschweine/dependencies/enet/enet.nim
+++ b/tests/manyloc/keineschweine/dependencies/enet/enet.nim
@@ -17,10 +17,9 @@ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 
 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 """
-when defined(Linux):
-  const Lib = "libenet.so.1(|.0.3)"
-else:
-  {.error: "Your platform has not been accounted for."}
+
+const Lib = "libenet.so.1(|.0.3)"
+
 {.deadCodeElim: ON.}
 const 
   ENET_VERSION_MAJOR* = 1
@@ -267,7 +266,7 @@ const
   ENET_PEER_RELIABLE_WINDOW_SIZE         = 0x1000
   ENET_PEER_FREE_RELIABLE_WINDOWS        = 8
 
-when defined(Linux):
+when defined(Linux) or true:
   import posix
   const
     ENET_SOCKET_NULL*: cint = -1
diff --git a/tests/manyloc/keineschweine/dependencies/sfml/sfml.nim b/tests/manyloc/keineschweine/dependencies/sfml/sfml.nim
index 27163e271..0d09d40e3 100644
--- a/tests/manyloc/keineschweine/dependencies/sfml/sfml.nim
+++ b/tests/manyloc/keineschweine/dependencies/sfml/sfml.nim
@@ -6,7 +6,12 @@ when defined(linux):
     LibS = "libcsfml-system.so.2.0"
     LibW = "libcsfml-window.so.2.0"
 else:
-  {.error: "Platform unsupported".}
+  # We only compile for testing here, so it doesn't matter it's not supported
+  const
+    LibG = "libcsfml-graphics.so.2.0"
+    LibS = "libcsfml-system.so.2.0"
+    LibW = "libcsfml-window.so.2.0"
+  #{.error: "Platform unsupported".}
 {.deadCodeElim: on.}
 {.pragma: pf, pure, final.}
 type
@@ -153,8 +158,9 @@ type
     KeyF15,               #/< The F15 key
     KeyPause,             #/< The Pause key
     KeyCount              #/< Keep last -- the total number of keyboard keys
-when defined(linux): #or defined(bsd) ??
-  type TWindowHandle* = clong
+
+type TWindowHandle* = clong
+
 #elif defined(mac):
 #  type TWindowHandle* = pointer ##typedef void* sfWindowHandle; <- whatever the hell that is
 #elif defined(windows):
diff --git a/tests/matrix/issue1013.nim b/tests/matrix/issue1013.nim
new file mode 100644
index 000000000..7d3d52f85
--- /dev/null
+++ b/tests/matrix/issue1013.nim
@@ -0,0 +1,23 @@
+import typetraits
+
+template reject(e: expr) =
+  static: assert(not compiles(e))
+
+type
+  TMatrix[T; M, N: static[int]] = array[M*N, T]
+
+proc `*`[T; R, N, C](a: TMatrix[T, R, N], b: TMatrix[T, N, C]): TMatrix[T, R, C] =
+  discard
+
+var m1: TMatrix[int, 6, 4]
+var m2: TMatrix[int, 4, 3]
+var m3: TMatrix[int, 3, 3]
+
+var m4 = m1*m2
+static: assert m4.M == 6 and m4.N == 3
+
+reject m1 * m3 # not compatible
+
+var m5 = m2 * m3
+static: assert high(m5) == 11 # 4*3 - 1
+
diff --git a/tests/metatype/swizzle.nim b/tests/metatype/swizzle.nim
new file mode 100644
index 000000000..ce18fa234
--- /dev/null
+++ b/tests/metatype/swizzle.nim
@@ -0,0 +1,79 @@
+discard """
+  output: '''3
+[1, 3]
+[2, 1, 2]
+'''
+"""
+
+import macros, strutils
+
+template accept(e: expr) =
+  static: assert(compiles(e))
+
+template reject(e: expr) =
+  static: assert(not compiles(e))
+
+proc swizzleIdx(c: char): int =
+  return case c
+    of 'x': 0
+    of 'y': 1
+    of 'z': 2
+    of 'w': 3    
+    of 'r': 0
+    of 'g': 1
+    of 'b': 2
+    of 'a': 3    
+    else: 0
+
+proc isSwizzle(s: string): bool =
+  template trySet(name, set) =
+    block search:
+      for c in s:
+        if c notin set:
+          break search
+      return true
+
+  trySet coords, {'x', 'y', 'z', 'w'}
+  trySet colors, {'r', 'g', 'b', 'a'}
+  
+  return false
+
+type 
+  StringIsSwizzle = generic value
+    value.isSwizzle
+
+  SwizzleStr = static[string] and StringIsSwizzle
+
+proc foo(x: SwizzleStr) =
+  echo "sw"
+
+accept foo("xx")
+reject foo("xe")
+
+type 
+  Vec[N: static[int]; T] = array[N, T]
+
+
+proc card(x: Vec): int = x.N
+proc `$`(x: Vec): string = x.repr.strip
+
+macro `.`(x: Vec, swizzle: SwizzleStr): expr =
+  var
+    cardinality = swizzle.len
+    values = newNimNode(nnkBracket)
+    v = genSym()
+
+  for c in swizzle:
+    values.add newNimNode(nnkBracketExpr).add(
+      v, c.swizzleIdx.newIntLitNode)
+  
+  return quote do:
+    let `v` = `x`
+    Vec[`cardinality`, `v`.T](`values`)
+
+var z = Vec([1, 2, 3])
+
+echo z.card
+echo z.xz
+echo z.yxy
+
diff --git a/tests/metatype/tbindtypedesc.nim b/tests/metatype/tbindtypedesc.nim
index 5ea8cf063..84527362f 100644
--- a/tests/metatype/tbindtypedesc.nim
+++ b/tests/metatype/tbindtypedesc.nim
@@ -1,10 +1,10 @@
 discard """
-  msg: '''
-int
-float
-TFoo
-TFoo
-'''
+  msg: '''int int
+float float
+int int
+TFoo TFoo
+int float
+TFoo TFoo'''
 """
 
 import typetraits
@@ -24,9 +24,8 @@ template reject(e: expr) =
 
 proc genericParamRepeated[T: typedesc](a: T, b: T) =
   static:
-    echo a.name
-    echo b.name
-
+    echo a.name, " ", b.name
+    
 accept genericParamRepeated(int, int)
 accept genericParamRepeated(float, float)
 
@@ -35,8 +34,7 @@ reject genericParamRepeated(int, float)
 
 proc genericParamOnce[T: typedesc](a, b: T) =
   static:
-    echo a.name
-    echo b.name
+    echo a.name, " ", b.name
 
 accept genericParamOnce(int, int)
 accept genericParamOnce(TFoo, TFoo)
@@ -68,8 +66,7 @@ reject typePairs2(string, int, TBAR, TBAR)
 
 proc dontBind(a: typedesc, b: typedesc) =
   static:
-    echo a.name
-    echo b.name
+    echo a.name, " ", b.name
 
 accept dontBind(int, float)
 accept dontBind(TFoo, TFoo)
diff --git a/tests/metatype/tstaticparams.nim b/tests/metatype/tstaticparams.nim
index b1377443b..6d7c569e0 100644
--- a/tests/metatype/tstaticparams.nim
+++ b/tests/metatype/tstaticparams.nim
@@ -1,6 +1,6 @@
 discard """
   file: "tstaticparams.nim"
-  output: "abracadabra\ntest\n3"
+  output: "abracadabra\ntest\n3\n15\n4\n2"
 """
 
 type 
@@ -11,8 +11,11 @@ type
     data: array[I, T]
 
   TA1[T; I: static[int]] = array[I, T]
-  # TA2[T; I: static[int]] = array[0..I, T]
-  # TA3[T; I: static[int]] = array[I-1, T]
+  TA2[T; I: static[int]] = array[0..I, T]
+  TA3[T; I: static[int]] = array[I-1, T]
+
+  TObj = object
+    x: TA3[int, 3]
 
 proc takeFoo(x: TFoo) =
   echo "abracadabra"
@@ -26,6 +29,30 @@ echo high(y.data)
 
 var
   t1: TA1[float, 1]
-  # t2: TA2[string, 4]
-  # t3: TA3[int, 10]
+  t2: TA2[string, 4]
+  t3: TA3[int, 10]
+  t4: TObj
+
+# example from the manual:
+type
+  Matrix[M,N: static[int]; T] = array[0..(M*N - 1), T]
+    # Note how `Number` is just a type constraint here, while
+    # `static[int]` requires us to supply a compile-time int value
+
+  AffineTransform2D[T] = Matrix[3, 3, T]
+  AffineTransform3D[T] = Matrix[4, 4, T]
+
+var m: AffineTransform3D[float]
+echo high(m)
+
+proc getRows(mtx: Matrix): int =
+  result = mtx.M
+
+echo getRows(m)
+
+# issue 997
+type TTest[T: static[int], U: static[int]] = array[0..T*U, int]
+type TTestSub[N: static[int]] = TTest[1, N]
 
+var z: TTestSub[2]
+echo z.high
diff --git a/tests/metatype/tusertypeclasses.nim b/tests/metatype/tusertypeclasses.nim
index 4c2f07b85..a5d575dbf 100644
--- a/tests/metatype/tusertypeclasses.nim
+++ b/tests/metatype/tusertypeclasses.nim
@@ -26,3 +26,18 @@ foo 10
 foo "test"
 foo(@[TObj(x: 10), TObj(x: 20)])
 
+proc intval(x: int): int = 10
+
+# check real and virtual fields
+type
+  TFoo = generic T
+    T.x
+    y(T)
+    intval T.y
+    let z = intval(T.y)
+
+proc y(x: TObj): int = 10
+
+proc testFoo(x: TFoo) = discard
+testFoo(TObj(x: 10))
+
diff --git a/tests/metatype/tusertypeclasses2.nim b/tests/metatype/tusertypeclasses2.nim
new file mode 100644
index 000000000..77c70d7a6
--- /dev/null
+++ b/tests/metatype/tusertypeclasses2.nim
@@ -0,0 +1,24 @@
+type
+  hasFieldX = generic z
+    z.x is int
+
+  obj_x = object
+    x: int
+
+  ref_obj_x = ref object
+    x: int
+  
+  ref_to_obj_x = ref obj_x
+
+  p_o_x = ptr obj_x
+  v_o_x = var obj_x
+
+template check(x) =
+  static: assert(x)
+
+check obj_x is hasFieldX
+check ref_obj_x is hasFieldX
+check ref_to_obj_x is hasFieldX
+check p_o_x is hasFieldX
+check v_o_x is hasFieldX
+
diff --git a/tests/metatype/typeclassinference.nim b/tests/metatype/typeclassinference.nim
new file mode 100644
index 000000000..72b5aca96
--- /dev/null
+++ b/tests/metatype/typeclassinference.nim
@@ -0,0 +1,10 @@
+import typetraits
+
+type
+  Vec[N: static[int]; T] = distinct array[N, T]
+
+var x = Vec([1, 2, 3])
+
+static:
+  assert x.type.name == "Vec[static[int](3), int]"
+
diff --git a/tests/metatype/udtcmanual.nim b/tests/metatype/udtcmanual.nim
new file mode 100644
index 000000000..dd44298dc
--- /dev/null
+++ b/tests/metatype/udtcmanual.nim
@@ -0,0 +1,43 @@
+discard """
+  output: '''1
+2
+3
+4
+5
+6
+a
+b
+t
+e
+s
+t
+'''
+"""
+
+template accept(e: expr) =
+  static: assert compiles(e)
+
+template reject(e: expr) =
+  static: assert(not compiles(e))
+
+type
+  Container[T] = generic C
+    C.len is Ordinal
+    items(c) is iterator
+    for value in C:
+      type(value) is T
+
+proc takesIntContainer(c: Container[int]) =
+  for e in c: echo e
+
+takesIntContainer(@[1, 2, 3])
+reject takesIntContainer(@["x", "y"])
+
+proc takesContainer(c: Container) =
+  for e in c: echo e
+
+takesContainer(@[4, 5, 6])
+takesContainer(@["a", "b"])
+takesContainer "test"
+reject takesContainer(10)
+
diff --git a/tests/method/tmethods1.nim b/tests/method/tmethods1.nim
index f4add6af4..43a260bca 100644
--- a/tests/method/tmethods1.nim
+++ b/tests/method/tmethods1.nim
@@ -14,8 +14,8 @@ type
   TSomethingElse = object 
   PSomethingElse = ref TSomethingElse
 
-method foo(a: PNode, b: PSomethingElse) = nil
-method foo(a: PNodeFoo, b: PSomethingElse) = nil
+method foo(a: PNode, b: PSomethingElse) = discard
+method foo(a: PNodeFoo, b: PSomethingElse) = discard
 
 var o: TObject
 o.somethin()
diff --git a/tests/module/trecinca.nim b/tests/module/trecinca.nim
index 73a0ec937..62d37783c 100644
--- a/tests/module/trecinca.nim
+++ b/tests/module/trecinca.nim
@@ -1,7 +1,7 @@
 discard """
   file: "tests/reject/trecincb.nim"
   line: 9
-  errormsg: "recursive dependency: 'tests/reject/trecincb.nim'"
+  errormsg: "recursive dependency: 'tests/module/trecincb.nim'"
 """
 # Test recursive includes
 
diff --git a/tests/module/trecincb.nim b/tests/module/trecincb.nim
index 9dd7d51de..a2934052f 100644
--- a/tests/module/trecincb.nim
+++ b/tests/module/trecincb.nim
@@ -1,7 +1,7 @@
 discard """
   file: "trecincb.nim"
   line: 9
-  errormsg: "recursive dependency: 'tests/reject/trecincb.nim'"
+  errormsg: "recursive dependency: 'tests/module/trecincb.nim'"
 """
 # Test recursive includes
 
diff --git a/tests/notnil/tnotnil3.nim b/tests/notnil/tnotnil3.nim
new file mode 100644
index 000000000..b7c7a811d
--- /dev/null
+++ b/tests/notnil/tnotnil3.nim
@@ -0,0 +1,35 @@
+discard """
+  errormsg: "cannot prove 'variable' is not nil"
+  line: 31
+"""
+
+# bug #584
+# Testprogram for 'not nil' check
+
+const testWithResult = true
+
+type
+  A = object
+  B = object
+  C = object
+    a: ref A
+    b: ref B
+
+
+proc testNotNil(c: ref C not nil) =
+  discard
+
+
+when testWithResult:
+  proc testNotNilOnResult(): ref C =
+    new(result)
+    #result.testNotNil() # Here 'not nil' can't be proved
+
+
+var variable: ref C
+new(variable)
+variable.testNotNil() # Here 'not nil' is proved
+
+when testWithResult:
+  discard testNotNilOnResult()
+
diff --git a/tests/objects/tobjpragma.nim b/tests/objects/tobjpragma.nim
new file mode 100644
index 000000000..f9fbd5e40
--- /dev/null
+++ b/tests/objects/tobjpragma.nim
@@ -0,0 +1,49 @@
+discard """
+  file: "tobjpragma.nim"
+  output: '''2
+3
+9
+257
+1
+2
+3'''
+"""
+
+# Test 
+
+type
+  Foo {.packed.} = object
+    a: int8
+    b: int8
+
+  Bar {.packed.} = object
+    a: int8
+    b: int16   
+    
+  Daz {.packed.} = object
+    a: int32
+    b: int8 
+    c: int32  
+
+
+var f = Foo(a: 1, b: 1)
+var b: Bar
+var d: Daz
+
+echo sizeof(f)
+echo sizeof(b)
+echo sizeof(d)
+echo (cast[ptr int16](f.addr)[])
+
+type
+  Union {.union.} = object
+    a: int8
+    b: int8
+
+var u: Union
+u.a = 1
+echo u.b
+u.a = 2
+echo u.b
+u.b = 3
+echo u.a
diff --git a/tests/overload/tissue966.nim b/tests/overload/tissue966.nim
new file mode 100644
index 000000000..2911348cf
--- /dev/null
+++ b/tests/overload/tissue966.nim
@@ -0,0 +1,12 @@
+discard """
+  errormsg: "type mismatch: got (PTest)"
+"""
+
+type
+  PTest = ref object
+
+proc test(x: PTest, y: int) = nil
+
+var buf: PTest
+buf.test()
+
diff --git a/tests/overload/toverwr.nim b/tests/overload/toverwr.nim
index ef25e8913..32d50faaa 100644
--- a/tests/overload/toverwr.nim
+++ b/tests/overload/toverwr.nim
@@ -1,13 +1,13 @@
-discard """
-  file: "toverwr.nim"
-  output: "hello"
-"""
+discard """

+  file: "toverwr.nim"

+  output: "hello"

+"""

 # Test the overloading resolution in connection with a qualifier

 

 proc write(t: TFile, s: string) =

-  nil # a nop

+  discard # a nop

 

 system.write(stdout, "hello")

 #OUT hello

-
-
+

+

diff --git a/tests/parser/tstrongspaces.nim b/tests/parser/tstrongspaces.nim
new file mode 100644
index 000000000..91506daf0
--- /dev/null
+++ b/tests/parser/tstrongspaces.nim
@@ -0,0 +1,52 @@
+#! strongSpaces
+
+discard """
+  output: '''35
+77
+(Field0: 1, Field1: 2, Field2: 2)
+ha
+true
+tester args
+all
+all args
+'''
+"""
+
+echo 2+5 * 5
+
+let foo = 77
+echo $foo
+
+echo (1, 2, 2)
+
+template `&`(a, b: int): expr = a and b
+template `|`(a, b: int): expr = a - b
+template `++`(a, b: int): expr = a + b == 8009
+
+when true:
+  let b = 66
+  let c = 90
+  let bar = 8000
+  if foo+4 * 4 == 8 and b&c | 9  ++
+      bar:
+    echo "ho"
+  else:
+    echo "ha"
+
+  let booA = foo+4 * 4  -  b&c | 9  +
+      bar
+  # is parsed as
+  let booB = ((foo+4)*4) - ((b&c) | 9) + bar
+
+  echo booA == booB
+
+
+template `|`(a, b): expr = (if a.len > 0: a else: b)
+
+const
+  tester = "tester"
+  args = "args"
+
+echo tester & " " & args|"all"
+echo "all"  |  tester & " " & args
+echo "all"|tester & " " & args
diff --git a/tests/patterns/targlist.nim b/tests/patterns/targlist.nim
index a2fa1fa48..e416edf0a 100644
--- a/tests/patterns/targlist.nim
+++ b/tests/patterns/targlist.nim
@@ -2,7 +2,7 @@ discard """
   output: "12false3ha"
 """
 
-proc f(x: varargs[string, `$`]) = nil
+proc f(x: varargs[string, `$`]) = discard
 template optF{f(X)}(x: varargs[expr]) = 
   writeln(stdout, x)
 
diff --git a/tests/range/tsubrange2.nim b/tests/range/tsubrange2.nim
index 51598713b..d14111bb9 100644
--- a/tests/range/tsubrange2.nim
+++ b/tests/range/tsubrange2.nim
@@ -8,7 +8,7 @@ type
   TRange = range[0..40]
   
 proc p(r: TRange) =
-  nil
+  discard
   
 var
   r: TRange
diff --git a/tests/range/tsubrange3.nim b/tests/range/tsubrange3.nim
index b3e02fd29..9afb5018b 100644
--- a/tests/range/tsubrange3.nim
+++ b/tests/range/tsubrange3.nim
@@ -8,7 +8,7 @@ type
   TRange = range[0..40]
   
 proc p(r: TRange) =
-  nil
+  discard
   
 var
   r: TRange
diff --git a/tests/sets/tsets.nim b/tests/sets/tsets.nim
index 7b806f15b..e370209ed 100644
--- a/tests/sets/tsets.nim
+++ b/tests/sets/tsets.nim
@@ -1,7 +1,7 @@
-discard """
-  file: "tsets.nim"
-  output: "Ha ein F ist in s!"
-"""
+discard """

+  file: "tsets.nim"

+  output: "Ha ein F ist in s!"

+"""

 # Test the handling of sets

 

 import

@@ -38,7 +38,7 @@ type
   TTokTypes* = set[TTokTypeRange]

 

 const

-  toktypes: TTokTypes = {TTokTypeRange(tkSymbol)..pred(tkIntLit), 
+  toktypes: TTokTypes = {TTokTypeRange(tkSymbol)..pred(tkIntLit), 

                          tkStrLit..tkTripleStrLit}

 

 var

@@ -51,14 +51,14 @@ else: write(stdout, "BUG: F ist nicht in s!\n")
 a = {} #{'a'..'z'}

 for x in low(TAZ) .. high(TAZ):

   incl(a, x)

-  if x in a: nil

+  if x in a: discard

   else: write(stdout, "BUG: something not in a!\n")

 

 for x in low(TTokTypeRange) .. high(TTokTypeRange):

   if x in tokTypes:

-    nil
+    discard

     #writeln(stdout, "the token '$1' is in the set" % repr(x))

 

 #OUT Ha ein F ist in s!

-
-
+

+

diff --git a/tests/showoff/tdrdobbs_examples.nim b/tests/showoff/tdrdobbs_examples.nim
index d1e0585d2..0b3d86a05 100644
--- a/tests/showoff/tdrdobbs_examples.nim
+++ b/tests/showoff/tdrdobbs_examples.nim
@@ -1,7 +1,7 @@
 discard """
   output: '''108
 11 -1 1936
-4.000000000000002-e001
+4.0000000000000002e-001
 true
 truefalse'''
 """
diff --git a/tests/specialops/tdotops.nim b/tests/specialops/tdotops.nim
new file mode 100644
index 000000000..ce5b3942d
--- /dev/null
+++ b/tests/specialops/tdotops.nim
@@ -0,0 +1,66 @@
+discard """
+  output: '''
+10
+assigning z = 20
+reading field y
+20
+call to y
+dot call
+no params call to a
+100
+no params call to b
+100
+one param call to c with 10
+100'''
+"""
+
+type
+  T1 = object
+    x*: int
+
+  TD = distinct T1
+
+  T2 = object
+    x: int
+
+proc `.`*(v: T1, f: string): int =
+  echo "reading field ", f
+  return v.x
+
+proc `.=`(x: var T1, f: string{lit}, v: int) =
+  echo "assigning ", f, " = ", v
+  x.x = v
+
+template `.()`(x: T1, f: string, args: varargs[expr]): string =
+  echo "call to ", f
+  "dot call"
+
+echo ""
+
+var t = T1(x: 10)
+
+echo t.x
+t.z = 20
+echo t.y
+echo t.y()
+
+var d = TD(t)
+assert(not compiles(d.y))
+
+proc `.`(v: T2, f: string): int =
+  echo "no params call to ", f
+  return v.x
+
+proc `.`*(v: T2, f: string, a: int): int =
+  echo "one param call to ", f, " with ", a
+  return v.x
+
+var tt = T2(x: 100)
+
+echo tt.a
+echo tt.b()
+echo tt.c(10)
+
+assert(not compiles(tt.d("x")))
+assert(not compiles(tt.d(1, 2)))
+
diff --git a/tests/static/tstaticparammacro.nim b/tests/static/tstaticparammacro.nim
new file mode 100644
index 000000000..7fb9e2014
--- /dev/null
+++ b/tests/static/tstaticparammacro.nim
@@ -0,0 +1,52 @@
+discard """
+  msg: '''letters
+aa
+bb
+numbers
+11
+22
+AST a 
+[(11, 22), (33, 44)]
+AST b 
+(e: [55, 66], f: [77, 88])
+55
+'''
+"""
+
+import macros
+
+type
+  TConfig = tuple
+    letters: seq[string]
+    numbers:seq[int]
+
+const data: Tconfig = (@["aa", "bb"], @[11, 22])
+
+macro mymacro(data: static[TConfig]): stmt =
+  echo "letters"
+  for s in items(data.letters):
+    echo s
+  echo "numbers"
+  for n in items(data.numbers):
+    echo n
+
+mymacro(data)
+
+type
+  Ta = seq[tuple[c:int, d:int]]
+  Tb = tuple[e:seq[int], f:seq[int]]
+
+const
+  a : Ta = @[(11, 22), (33, 44)]
+  b : Tb = (@[55,66], @[77, 88])
+
+macro mA(data: static[Ta]): stmt =
+  echo "AST a \n", repr(data)
+
+macro mB(data: static[Tb]): stmt =
+  echo "AST b \n", repr(data)
+  echo data.e[0]
+
+mA(a)
+mB(b)
+
diff --git a/tests/stdlib/talgorithm.nim b/tests/stdlib/talgorithm.nim
index 7ab652c82..3ca425fbc 100644
--- a/tests/stdlib/talgorithm.nim
+++ b/tests/stdlib/talgorithm.nim
@@ -6,3 +6,6 @@ doAssert product(@[@[1,2]]) == @[@[1,2]], "a simple case of one element"
 doAssert product(@[@[1,2], @[3,4]]) == @[@[2,4],@[1,4],@[2,3],@[1,3]], "two elements"
 doAssert product(@[@[1,2], @[3,4], @[5,6]]) == @[@[2,4,6],@[1,4,6],@[2,3,6],@[1,3,6], @[2,4,5],@[1,4,5],@[2,3,5],@[1,3,5]], "three elements"
 doAssert product(@[@[1,2], @[]]) == newSeq[seq[int]](), "two elements, but one empty"
+doAssert lowerBound([1,2,4], 3, system.cmp[int]) == 2
+doAssert lowerBound([1,2,2,3], 4, system.cmp[int]) == 4
+doAssert lowerBound([1,2,3,10], 11) == 4
\ No newline at end of file
diff --git a/tests/stdlib/tircbot.nim b/tests/stdlib/tircbot.nim
index 6008838ff..f0417c7ac 100644
--- a/tests/stdlib/tircbot.nim
+++ b/tests/stdlib/tircbot.nim
@@ -200,7 +200,7 @@ proc setSeen(d: TDb, s: TSeen) =
   var hashToSet = @[("type", $s.kind.int), ("channel", s.channel),
                     ("timestamp", $s.timestamp.int)]
   case s.kind
-  of PSeenJoin: nil
+  of PSeenJoin: discard
   of PSeenPart, PSeenMsg, PSeenQuit:
     hashToSet.add(("msg", s.msg))
   of PSeenNick:
@@ -338,7 +338,7 @@ proc hubConnect(state: PState) =
 
 proc handleIrc(irc: PAsyncIRC, event: TIRCEvent, state: PState) =
   case event.typ
-  of EvConnected: nil
+  of EvConnected: discard
   of EvDisconnected:
     while not state.ircClient.isConnected:
       try:
@@ -424,7 +424,7 @@ proc handleIrc(irc: PAsyncIRC, event: TIRCEvent, state: PState) =
       seenNick.newNick = event.params[0]
       state.database.setSeen(seenNick)
     else:
-      nil # TODO: ?
+      discard # TODO: ?
 
 proc open(port: TPort = TPort(5123)): PState =
   var res: PState
diff --git a/tests/stdlib/tmath.nim b/tests/stdlib/tmath.nim
index a86a3b84c..fc9486093 100644
--- a/tests/stdlib/tmath.nim
+++ b/tests/stdlib/tmath.nim
@@ -23,6 +23,13 @@ suite "random int":
       rand = random(100..1000)
       check rand < 1000
       check rand >= 100
+  test "randomize() again gives new numbers":      
+    randomize()
+    var rand1 = random(1000000)
+    randomize()
+    var rand2 = random(1000000)
+    check rand1 != rand2
+    
 
 suite "random float":
   test "there might be some randomness":
@@ -45,3 +52,10 @@ suite "random float":
       rand = random(100.0..1000.0)
       check rand < 1000.0
       check rand >= 100.0
+  test "randomize() again gives new numbers":      
+    randomize()
+    var rand1:float = random(1000000.0)
+    randomize()
+    var rand2:float = random(1000000.0)
+    check rand1 != rand2
+
diff --git a/tests/stdlib/tmath2.nim b/tests/stdlib/tmath2.nim
index 6a1dae54d..935b08634 100644
--- a/tests/stdlib/tmath2.nim
+++ b/tests/stdlib/tmath2.nim
@@ -1,7 +1,7 @@
 # tests for the interpreter

 

 proc loops(a: var int) =

-  nil

+  discard

   #var

   #  b: int

   #b = glob

diff --git a/tests/stdlib/tmongo.nim b/tests/stdlib/tmongo.nim
deleted file mode 100644
index 1c4c0f4e6..000000000
--- a/tests/stdlib/tmongo.nim
+++ /dev/null
@@ -1,16 +0,0 @@
-
-import mongo, db_mongo, oids, json
-
-var conn = db_mongo.open()
-
-var data = %{"a": %13, "b": %"my string value", 
-             "inner": %{"i": %71} }
-
-var id = insertID(conn, "test.test", data)
-
-for v in find(conn, "test.test", "this.a == 13"):
-  print v
-
-delete(conn, "test.test", id)
-
-close(conn)
diff --git a/tests/stdlib/tos.nim b/tests/stdlib/tos.nim
index fa9993cc9..ebe577b00 100644
--- a/tests/stdlib/tos.nim
+++ b/tests/stdlib/tos.nim
@@ -7,6 +7,6 @@ proc walkDirTree(root: string) =
     case k 
     of pcFile, pcLinkToFile: echo(f)
     of pcDir: walkDirTree(f)
-    of pcLinkToDir: nil
+    of pcLinkToDir: discard
 
 walkDirTree(".")
diff --git a/tests/stdlib/tpegs.nim b/tests/stdlib/tpegs.nim
index bdd8db0f8..6e488bab4 100644
--- a/tests/stdlib/tpegs.nim
+++ b/tests/stdlib/tpegs.nim
@@ -123,7 +123,7 @@ proc add(d: var TPeg, s: TPeg) {.inline.} = add(d.sons, s)
 proc copyPeg(a: TPeg): TPeg = 
   result.kind = a.kind
   case a.kind
-  of pkEmpty..pkWhitespace: nil
+  of pkEmpty..pkWhitespace: discard
   of pkTerminal, pkTerminalIgnoreCase, pkTerminalIgnoreStyle: 
     result.term = a.term
   of pkChar, pkGreedyRepChar: 
@@ -229,7 +229,7 @@ when false:
     case a.kind
     of pkEmpty, pkAny, pkAnyRune, pkGreedyAny, pkNewLine, pkTerminal,
        pkTerminalIgnoreCase, pkTerminalIgnoreStyle, pkChar, pkGreedyRepChar,
-       pkCharChoice, pkGreedyRepSet: nil
+       pkCharChoice, pkGreedyRepSet: discard
     of pkNonTerminal: return true
     else:
       for i in 0..a.sons.len-1:
@@ -318,7 +318,7 @@ proc backrefIgnoreStyle*(index: range[1..MaxSubPatterns]): TPeg {.
 
 proc spaceCost(n: TPeg): int =
   case n.kind
-  of pkEmpty: nil
+  of pkEmpty: discard
   of pkTerminal, pkTerminalIgnoreCase, pkTerminalIgnoreStyle, pkChar,
      pkGreedyRepChar, pkCharChoice, pkGreedyRepSet, 
      pkAny..pkWhitespace, pkGreedyAny:
@@ -1111,7 +1111,7 @@ proc handleHexChar(c: var TPegLexer, xi: var int) =
   of 'A'..'F': 
     xi = (xi shl 4) or (ord(c.buf[c.bufpos]) - ord('A') + 10)
     inc(c.bufpos)
-  else: nil
+  else: discard
 
 proc getEscapedChar(c: var TPegLexer, tok: var TToken) = 
   inc(c.bufpos)
@@ -1341,7 +1341,7 @@ proc getTok(c: var TPegLexer, tok: var TToken) =
       of "i": tok.modifier = modIgnoreCase
       of "y": tok.modifier = modIgnoreStyle
       of "v": tok.modifier = modVerbatim
-      else: nil
+      else: discard
       setLen(tok.literal, 0)
       if c.buf[c.bufpos] == '$':
         getDollar(c, tok)
@@ -1488,7 +1488,7 @@ proc primary(p: var TPegParser): TPeg =
   of tkCurlyAt:
     getTok(p)
     return !*\primary(p).token(p)
-  else: nil
+  else: discard
   case p.tok.kind
   of tkIdentifier:
     if p.identIsVerbatim: 
diff --git a/tests/system/alloc.nim b/tests/system/alloc.nim
new file mode 100644
index 000000000..7abefec2a
--- /dev/null
+++ b/tests/system/alloc.nim
@@ -0,0 +1,52 @@
+var x: ptr int
+
+x = cast[ptr int](alloc(7))
+assert x != nil
+x = cast[ptr int](x.realloc(2))
+assert x != nil
+x.dealloc()
+
+x = createU(int, 3)
+assert x != nil
+x.free()
+
+x = create(int, 4)
+assert cast[ptr array[4, int]](x)[0] == 0
+assert cast[ptr array[4, int]](x)[1] == 0
+assert cast[ptr array[4, int]](x)[2] == 0
+assert cast[ptr array[4, int]](x)[3] == 0
+
+x = x.resize(4)
+assert x != nil
+x.free()
+
+x = cast[ptr int](allocShared(100))
+assert x != nil
+deallocShared(x)
+
+x = createSharedU(int, 3)
+assert x != nil
+x.freeShared()
+
+x = createShared(int, 3)
+assert x != nil
+assert cast[ptr array[3, int]](x)[0] == 0
+assert cast[ptr array[3, int]](x)[1] == 0
+assert cast[ptr array[3, int]](x)[2] == 0
+
+assert x != nil
+x = cast[ptr int](x.resizeShared(2))
+assert x != nil
+x.freeShared()
+
+x = create(int, 10)
+assert x != nil
+x = x.resize(12)
+assert x != nil
+x.dealloc()
+
+x = createShared(int, 1)
+assert x != nil
+x = x.resizeShared(1)
+assert x != nil
+x.freeShared()
diff --git a/tests/table/ttableconstr.nim b/tests/table/ttableconstr.nim
index c627e68e8..1a21a18d1 100644
--- a/tests/table/ttableconstr.nim
+++ b/tests/table/ttableconstr.nim
@@ -1,7 +1,7 @@
 # Test if the new table constructor syntax works:
 
 template ignoreExpr(e: expr): stmt {.immediate.} =
-  nil
+  discard
 
 # test first class '..' syntactical citizen:  
 ignoreExpr x <> 2..4
diff --git a/tests/sunset.tmpl b/tests/template/sunset.tmpl
index 6475bac4e..6475bac4e 100644
--- a/tests/sunset.tmpl
+++ b/tests/template/sunset.tmpl
diff --git a/tests/template/tissue909.nim b/tests/template/tissue909.nim
new file mode 100644
index 000000000..5b57a3558
--- /dev/null
+++ b/tests/template/tissue909.nim
@@ -0,0 +1,16 @@
+import macros
+
+template baz() =
+  proc bar() =
+    var x = 5
+    iterator foo(): int {.closure.} =
+      echo x
+    var y = foo
+    discard y()
+
+macro test(): stmt =
+  result = getAst(baz())
+  echo(treeRepr(result))
+
+test()
+bar()
diff --git a/tests/template/tissue993.nim b/tests/template/tissue993.nim
new file mode 100644
index 000000000..d39f43942
--- /dev/null
+++ b/tests/template/tissue993.nim
@@ -0,0 +1,21 @@
+
+type pnode* = ref object of tobject
+
+template litNode (name, ty): stmt  =
+  type name* = ref object of PNode
+    val*: ty
+litNode PIntNode, int
+
+import json
+
+template withKey*(j: PJsonNode; key: string; varname: expr;
+                  body:stmt): stmt {.immediate.} =
+  if j.hasKey(key):
+    let varname{.inject.}= j[key]
+    block:
+      body
+
+var j = parsejson("{\"zzz\":1}")
+withkey(j, "foo", x):
+  echo(x)
+
diff --git a/tests/template/tsymchoicefield.nim b/tests/template/tsymchoicefield.nim
new file mode 100644
index 000000000..ab05500bf
--- /dev/null
+++ b/tests/template/tsymchoicefield.nim
@@ -0,0 +1,12 @@
+type Foo = object
+  len: int
+
+var f = Foo(len: 40)
+
+template getLen(f: Foo): expr = f.len
+
+echo f.getLen
+# This fails, because `len` gets the nkOpenSymChoice
+# treatment inside the template early pass and then
+# it can't be recognized as a field anymore
+
diff --git a/tests/template/ttempl5.nim b/tests/template/ttempl5.nim
index 85692e97b..1f2378780 100644
--- a/tests/template/ttempl5.nim
+++ b/tests/template/ttempl5.nim
@@ -3,3 +3,16 @@ import mtempl5
 
 echo templ()
 
+#bug #892
+
+proc parse_to_close(value: string, index: int, open='(', close=')'): int =
+    discard
+
+# Call parse_to_close
+template get_next_ident: stmt =
+    discard "{something}".parse_to_close(0, open = '{', close = '}')
+
+get_next_ident()
+
+
+#identifier expected, but found '(open|open|open)'
diff --git a/tests/testament/categories.nim b/tests/testament/categories.nim
index 442dd1212..9bb4838e0 100644
--- a/tests/testament/categories.nim
+++ b/tests/testament/categories.nim
@@ -222,9 +222,88 @@ proc testStdlib(r: var TResults, pattern, options: string, cat: Category) =
     else:
       testNoSpec r, makeTest(test, options, cat, actionCompile)
 
+# ----------------------------- babel ----------------------------------------
+type PackageFilter = enum
+  pfCoreOnly
+  pfExtraOnly
+  pfAll
+
+let 
+  babelExe = findExe("babel")
+  babelDir = getHomeDir() / ".babel"
+  packageDir = babelDir / "pkgs"
+  packageIndex = babelDir / "packages.json"
+
+proc waitForExitEx(p: PProcess): int =
+  var outp: PStream = outputStream(p)
+  var line = newStringOfCap(120).TaintedString
+  while true:
+    if outp.readLine(line):
+      discard
+    else:
+      result = peekExitCode(p)
+      if result != -1: break
+  close(p)
+
+proc getPackageDir(package: string): string =
+  ## TODO - Replace this with dom's version comparison magic.
+  var commandOutput = execCmdEx("babel path $#" % package)
+  if commandOutput.exitCode != quitSuccess:
+    return ""
+  else:
+    result = commandOutput[0].string
+
+iterator listPackages(filter: PackageFilter): tuple[name, url: string] =
+  let packageList = parseFile(packageIndex)
+
+  for package in packageList.items():
+    let
+      name = package["name"].str
+      url = package["url"].str
+      isCorePackage = "nimrod-code" in normalize(url)
+    case filter:
+    of pfCoreOnly:
+      if isCorePackage:
+        yield (name, url)
+    of pfExtraOnly:
+      if not isCorePackage:
+        yield (name, url)
+    of pfAll:
+      yield (name, url)
+
+proc testBabelPackages(r: var TResults, cat: Category, filter: PackageFilter) =
+  if babelExe == "":
+    echo("[Warning] - Cannot run babel tests: Babel binary not found.")
+    return
+
+  if execCmd("$# update" % babelExe) == quitFailure:
+    echo("[Warning] - Cannot run babel tests: Babel update failed.")
+    return
+
+  for name, url in listPackages(filter):
+    var test = makeTest(name, "", cat)
+    echo(url)
+    let
+      installProcess = startProcess(babelExe, "", ["install", "-y", name])
+      installStatus = waitForExitEx(installProcess)
+    installProcess.close
+    if installStatus != quitSuccess:
+      r.addResult(test, "", "", reInstallFailed)
+      continue
+
+    let
+      buildPath = getPackageDir(name)[0.. -3]
+    let
+      buildProcess = startProcess(babelExe, buildPath, ["build"])
+      buildStatus = waitForExitEx(buildProcess)
+    buildProcess.close
+    if buildStatus != quitSuccess:
+      r.addResult(test, "", "", reBuildFailed)
+    r.addResult(test, "", "", reSuccess)
+
 # ----------------------------------------------------------------------------
 
-const AdditionalCategories = ["debugger", "tools", "examples", "stdlib"]
+const AdditionalCategories = ["debugger", "tools", "examples", "stdlib", "babel-core"]
 
 proc `&.?`(a, b: string): string =
   # candidate for the stdlib?
@@ -264,6 +343,12 @@ proc processCategory(r: var TResults, cat: Category, options: string) =
     compileExample(r, "examples/*.nim", options, cat)
     compileExample(r, "examples/gtk/*.nim", options, cat)
     compileExample(r, "examples/talk/*.nim", options, cat)
+  of "babel-core":
+    testBabelPackages(r, cat, pfCoreOnly)
+  of "babel-extra":
+    testBabelPackages(r, cat, pfExtraOnly)
+  of "babel-all":
+    testBabelPackages(r, cat, pfAll)
   else:
     for name in os.walkFiles("tests" & DirSep &.? cat.string / "t*.nim"):
       testSpec r, makeTest(name, options, cat)
diff --git a/tests/testament/htmlgen.nim b/tests/testament/htmlgen.nim
index eb674a171..b91475aee 100644
--- a/tests/testament/htmlgen.nim
+++ b/tests/testament/htmlgen.nim
@@ -9,7 +9,7 @@
 
 ## HTML generator for the tester.
 
-import db_sqlite, cgi, backend, strutils
+import db_sqlite, cgi, backend, strutils, json
 
 const
   TableHeader = """<table border="1">
@@ -114,8 +114,6 @@ proc getCommit(db: TDbConn, c: int): string =
   for thisCommit in db.rows(sql"select id from [Commit] order by id desc"):
     if commit == 0: result = thisCommit[0]
     inc commit
-  if result.isNil:
-    quit "cannot determine commit " & $c
 
 proc generateHtml*(filename: string, commit: int) =
   const selRow = """select name, category, target, action, 
@@ -161,20 +159,67 @@ proc generateHtml*(filename: string, commit: int) =
   close(outfile)
 
 proc generateJson*(filename: string, commit: int) =
-  const selRow = """select count(*),
+  const
+    selRow = """select count(*),
                            sum(result = 'reSuccess'), 
                            sum(result = 'reIgnored')
+                from TestResult
+                where [commit] = ? and machine = ?
+                order by category"""
+    selDiff = """select A.category || '/' || A.target || '/' || A.name,
+                        A.result,
+                        B.result
+                from TestResult A
+                inner join TestResult B
+                on A.name = B.name and A.category = B.category
+                where A.[commit] = ? and B.[commit] = ? and A.machine = ?
+                   and A.result != B.result"""
+    selResults = """select 
+                      category || '/' || target || '/' || name, 
+                      category, target, action, result, expected, given 
                     from TestResult
-                    where [commit] = ? and machine = ?
-                    order by category"""
+                    where [commit] = ?"""
   var db = open(connection="testament.db", user="testament", password="",
                 database="testament")
   let lastCommit = db.getCommit(commit)
+  if lastCommit.isNil:
+    quit "cannot determine commit " & $commit
 
-  var outfile = open(filename, fmWrite)
+  let previousCommit = db.getCommit(commit-1)
 
-  let data = db.getRow(sql(selRow), lastCommit, $backend.getMachine(db))
+  var outfile = open(filename, fmWrite)
 
-  outfile.writeln("""{"total": $#, "passed": $#, "skipped": $#}""" % data)
+  let machine = $backend.getMachine(db)
+  let data = db.getRow(sql(selRow), lastCommit, machine)
+
+  outfile.writeln("""{"total": $#, "passed": $#, "skipped": $#""" % data)
+
+  let results = newJArray()
+  for row in db.rows(sql(selResults), lastCommit):
+    var obj = newJObject()
+    obj["name"] = %row[0]
+    obj["category"] = %row[1]
+    obj["target"] = %row[2]
+    obj["action"] = %row[3]
+    obj["result"] = %row[4]
+    obj["expected"] = %row[5]
+    obj["given"] = %row[6]
+    results.add(obj)
+  outfile.writeln(""", "results": """)
+  outfile.write(results.pretty)
+
+  if not previousCommit.isNil:
+    let diff = newJArray()
+
+    for row in db.rows(sql(selDiff), previousCommit, lastCommit, machine):
+      var obj = newJObject()
+      obj["name"] = %row[0]
+      obj["old"] = %row[1]
+      obj["new"] = %row[2]
+      diff.add obj
+    outfile.writeln(""", "diff": """)
+    outfile.writeln(diff.pretty)
+
+  outfile.writeln "}"
   close(db)
   close(outfile)
diff --git a/tests/testament/specs.nim b/tests/testament/specs.nim
index e97015946..65e17a453 100644
--- a/tests/testament/specs.nim
+++ b/tests/testament/specs.nim
@@ -28,6 +28,8 @@ type
     reCodegenFailure,
     reCodeNotFound,
     reExeNotFound,
+    reInstallFailed     # package installation failed
+    reBuildFailed       # package building failed
     reIgnored,          # test is ignored
     reSuccess           # test was successful
   TTarget* = enum
@@ -112,7 +114,11 @@ proc parseSpec*(filename: string): TSpec =
       result.substr = true
     of "exitcode": 
       discard parseInt(e.value, result.exitCode)
-    of "errormsg", "msg":
+    of "msg":
+      result.msg = e.value
+      if result.action != actionRun:
+        result.action = actionCompile
+    of "errormsg":
       result.msg = e.value
       result.action = actionReject
     of "disabled":
diff --git a/tests/testament/tester.nim b/tests/testament/tester.nim
index fac97cf2a..6655b1b79 100644
--- a/tests/testament/tester.nim
+++ b/tests/testament/tester.nim
@@ -11,7 +11,7 @@
 
 import
   parseutils, strutils, pegs, os, osproc, streams, parsecfg, json,
-  marshal, backend, parseopt, specs, htmlgen, browsers
+  marshal, backend, parseopt, specs, htmlgen, browsers, terminal
 
 const
   resultsFile = "testresults.html"
@@ -109,6 +109,12 @@ proc addResult(r: var TResults, test: TTest,
                           expected = expected,
                           given = given)
   r.data.addf("$#\t$#\t$#\t$#", name, expected, given, $success)
+  if success notin {reSuccess, reIgnored}:
+    styledEcho styleBright, name, fgRed, " [", $success, "]"
+    styledEcho styleDim, "EXPECTED:"
+    echo expected
+    styledEcho styleDim, "GIVEN:"
+    echo given
 
 proc cmpMsgs(r: var TResults, expected, given: TSpec, test: TTest) =
   if strip(expected.msg) notin strip(given.msg):
diff --git a/tests/threads/nimrod.cfg b/tests/threads/nimrod.cfg
new file mode 100644
index 000000000..b81c89721
--- /dev/null
+++ b/tests/threads/nimrod.cfg
@@ -0,0 +1 @@
+threads:on
diff --git a/tests/threads/tthreadanalysis.nim b/tests/threads/tthreadanalysis.nim
index 4edd51025..3a46cd185 100644
--- a/tests/threads/tthreadanalysis.nim
+++ b/tests/threads/tthreadanalysis.nim
@@ -1,5 +1,7 @@
 discard """
   outputsub: "101"
+  msg: "Warning: write to foreign heap"
+  line: 37
   cmd: "nimrod cc --hints:on --threads:on $# $#"
 """
 
@@ -8,7 +10,7 @@ import os
 var
   thr: array [0..5, TThread[tuple[a, b: int]]]
 
-proc doNothing() = nil
+proc doNothing() = discard
 
 type
   PNode = ref TNode
diff --git a/tests/typerel/tvoid.nim b/tests/typerel/tvoid.nim
index bb569e7f8..d31936217 100644
--- a/tests/typerel/tvoid.nim
+++ b/tests/typerel/tvoid.nim
@@ -1,5 +1,9 @@
 discard """
-  output: "he, no return type;abc a string"
+  output: '''12
+empty
+he, no return type;
+abc a string
+ha'''
 """
 
 proc ReturnT[T](x: T): T =
diff --git a/tests/typerel/typalias.nim b/tests/typerel/typalias.nim
index ba9f38ed9..40ff06765 100644
--- a/tests/typerel/typalias.nim
+++ b/tests/typerel/typalias.nim
@@ -9,7 +9,7 @@ proc init: TYourObj =
   result.y = -1
   
 proc f(x: var TYourObj) =
-  nil
+  discard
   
 var m: TMyObj = init()
 f(m)
diff --git a/tests/types/tisopr.nim b/tests/types/tisopr.nim
index 6d3c51749..3c2b9ee5e 100644
--- a/tests/types/tisopr.nim
+++ b/tests/types/tisopr.nim
@@ -1,8 +1,8 @@
 discard """
-  output: "true true false yes"
+  output: '''true true false yes'''
 """
 
-proc IsVoid[T](): string = 
+proc IsVoid[T](): string =
   when T is void:
     result = "yes"
   else:
@@ -11,3 +11,26 @@ proc IsVoid[T](): string =
 const x = int is int
 echo x, " ", float is float, " ", float is string, " ", IsVoid[void]()
 
+template yes(e: expr): stmt =
+  static: assert e
+
+template no(e: expr): stmt =
+  static: assert(not e)
+
+var s = @[1, 2, 3]
+
+yes s.items is iterator
+no  s.items is proc
+
+yes s.items is iterator: int
+no  s.items is iterator: float
+
+yes s.items is iterator: TNumber
+no  s.items is iterator: object
+
+type 
+  Iter[T] = iterator: T
+
+yes s.items is Iter[TNumber]
+no  s.items is Iter[float]
+
diff --git a/tests/vm/tcompiletimetable.nim b/tests/vm/tcompiletimetable.nim
new file mode 100644
index 000000000..f1d3ecd4e
--- /dev/null
+++ b/tests/vm/tcompiletimetable.nim
@@ -0,0 +1,50 @@
+discard """
+  msg: '''2
+3
+4:2
+  '''
+"""
+
+# bug #404
+
+import macros, tables
+
+var ZOOT{.compileTime.} = initTable[int, int](2)
+var iii {.compiletime.} = 1
+
+macro zoo:stmt=
+  zoot[iii] = iii*2
+  inc iii
+  echo iii
+
+zoo
+zoo
+
+
+macro tupleUnpack: stmt =
+  var (y,z) = (4, 2)
+  echo y, ":", z
+
+tupleUnpack
+
+# bug #903
+
+import strtabs
+
+var x {.compileTime.}: PStringTable
+
+macro addStuff(stuff, body: expr): stmt {.immediate.} =
+  result = newNimNode(nnkStmtList)
+
+  if x.isNil:
+    x = newStringTable(modeStyleInsensitive)
+  x[$stuff] = ""
+
+macro dump(): stmt =
+  result = newNimNode(nnkStmtList)
+  for y in x.keys: echo "Got ", y
+
+addStuff("Hey"): echo "Hey"
+addStuff("Hi"): echo "Hi"
+dump()
+
diff --git a/tests/vm/tquadplus.nim b/tests/vm/tquadplus.nim
new file mode 100644
index 000000000..552e8fef7
--- /dev/null
+++ b/tests/vm/tquadplus.nim
@@ -0,0 +1,17 @@
+# bug #1023
+
+discard """
+  output: "1 == 1"
+"""
+
+type Quadruple = tuple[a, b, c, d: int]
+
+proc `+`(s, t: Quadruple): Quadruple =
+  (a: s.a + t.a, b: s.b + t.b, c: s.c + t.c, d: s.d + t.d)
+
+const
+  A = (a: 0, b: -1, c: 0, d: 1)
+  B = (a: 0, b: -2, c: 1, d: 0)
+  C = A + B
+
+echo C.d, " == ", (A+B).d
diff --git a/tests/vm/trgba.nim b/tests/vm/trgba.nim
new file mode 100644
index 000000000..b1d94702f
--- /dev/null
+++ b/tests/vm/trgba.nim
@@ -0,0 +1,36 @@
+discard """
+  output: '''[127, 127, 0, 255]
+[127, 127, 0, 255]
+'''
+"""
+
+#bug #1009
+type
+  TAggRgba8* = array[4, Byte]
+
+template R*(self: TAggRgba8): Byte = self[0]   
+template G*(self: TAggRgba8): Byte = self[1]   
+template B*(self: TAggRgba8): Byte = self[2]   
+template A*(self: TAggRgba8): Byte = self[3]   
+
+template `R=`*(self: TAggRgba8, val: Byte) = 
+  self[0] = val   
+template `G=`*(self: TAggRgba8, val: Byte) =   
+  self[1] = val   
+template `B=`*(self: TAggRgba8, val: Byte) =   
+  self[2] = val   
+template `A=`*(self: TAggRgba8, val: Byte) =   
+  self[3] = val   
+
+proc ABGR* (val: int| int64): TAggRgba8 =
+  var V = val
+  result.R = V and 0xFF
+  V = V shr 8
+  result.G = V and 0xFF
+  V = V shr 8
+  result.B = V and 0xFF
+  result.A = (V shr 8) and 0xFF
+
+const
+  c1 = ABGR(0xFF007F7F) 
+echo ABGR(0xFF007F7F).repr, c1.repr
diff --git a/tests/vm/tstaticprintseq.nim b/tests/vm/tstaticprintseq.nim
new file mode 100644
index 000000000..3dfd0048d
--- /dev/null
+++ b/tests/vm/tstaticprintseq.nim
@@ -0,0 +1,78 @@
+discard """
+  msg: '''1
+2
+3
+1
+2
+3
+1
+2
+3
+1
+2
+3
+aa
+bb
+11
+22
+aa
+bb
+24'''
+"""
+
+const s = @[1,2,3]
+
+macro foo: stmt =
+  for e in s:
+    echo e
+
+foo()
+
+static:
+  for e in s:
+    echo e
+
+macro bar(x: static[seq[int]]): stmt =
+  for e in x:
+    echo e
+
+bar s
+bar(@[1, 2, 3])
+
+type
+  TData = tuple
+    letters: seq[string]
+    numbers: seq[int]
+
+const data: TData = (@["aa", "bb"], @[11, 22])
+
+static:
+  var m1 = data
+  for x in m1.letters: echo x
+
+  var m2: TData = data
+  for x in m2.numbers: echo x
+
+macro ff(d: static[TData]): stmt =
+  for x in d.letters:
+    echo x
+
+ff(data)
+
+# bug #1010
+
+proc `*==`(x: var int, y: int) {.inline, noSideEffect.} =
+  ## Binary `*=` operator for ordinals
+  x = x * y
+
+proc fac: int =
+  var x = 1;
+  for i in 1..4:
+    x *== i;
+  return x
+
+const y = fac()
+
+static:
+  echo y
+
diff --git a/tests/vm/twrongconst.nim b/tests/vm/twrongconst.nim
index e5b8a15bd..5c0c80f9f 100644
--- a/tests/vm/twrongconst.nim
+++ b/tests/vm/twrongconst.nim
@@ -1,10 +1,9 @@
 discard """
-  output: "Error: cannot evaluate at compile time: x"
-  line: 10
+  errormsg: "cannot evaluate at compile time: x"
+  line: 9
 """
 
-var x: array[100, char] 
+var x: array[100, char]
 template Foo : expr = x[42]
 
-
 const myConst = foo
diff --git a/tests/vm/twrongwhen.nim b/tests/vm/twrongwhen.nim
new file mode 100644
index 000000000..d67e42883
--- /dev/null
+++ b/tests/vm/twrongwhen.nim
@@ -0,0 +1,13 @@
+discard """
+  errormsg: "cannot evaluate at compile time: x"
+  line: 7
+"""
+
+proc bla(x:int) =
+  when x == 0:
+    echo "oops"
+  else:
+    echo "good"
+
+bla(2)  # echos "oops"
+