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.nim3
-rw-r--r--tests/array/troof1.nim36
-rw-r--r--tests/array/troof2.nim10
-rw-r--r--tests/array/troof3.nim8
-rw-r--r--tests/array/troof4.nim37
-rw-r--r--tests/assert/tfailedassert.nim10
-rw-r--r--tests/assign/moverload_asgn2.nim10
-rw-r--r--tests/assign/toverload_asgn1.nim75
-rw-r--r--tests/assign/toverload_asgn2.nim22
-rw-r--r--tests/async/tasyncexceptions.nim1
-rw-r--r--tests/async/tasynctry.nim53
-rw-r--r--tests/async/tasynctry2.nim16
-rw-r--r--tests/bind/tnicerrorforsymchoice.nim6
-rw-r--r--tests/caas/idetools_api.nim2
-rw-r--r--tests/caas/issue_416_template_shift.txt2
-rw-r--r--tests/caas/its_full_of_procs.nim2
-rw-r--r--tests/casestmt/tcase_emptyset_when.nim24
-rw-r--r--tests/casestmt/tcomputedgoto.nim5
-rw-r--r--tests/ccgbugs/tarray_equality.nim15
-rw-r--r--tests/ccgbugs/tmissingderef.nim30
-rw-r--r--tests/ccgbugs/tpartialcs.nim20
-rw-r--r--tests/ccgbugs/trecursive_closure.nim8
-rw-r--r--tests/ccgbugs/trecursive_table.nim17
-rw-r--r--tests/ccgbugs/tstringslice.nim24
-rw-r--r--tests/ccgbugs/tuple_canon.nim80
-rw-r--r--tests/ccgbugs/twrong_tupleconv.nim20
-rw-r--r--tests/clearmsg/ta.nim2
-rw-r--r--tests/clearmsg/tconsttypemismatch.nim8
-rw-r--r--tests/closure/tfib50.nim22
-rw-r--r--tests/closure/tinvalidclosure.nim2
-rw-r--r--tests/closure/tissue1642.nim7
-rw-r--r--tests/closure/ttimeinfo.nim15
-rw-r--r--tests/collections/tindexby.nim22
-rw-r--r--tests/collections/ttableconstr.nim (renamed from tests/table/ttableconstr.nim)0
-rw-r--r--tests/collections/ttables.nim172
-rw-r--r--tests/collections/ttables2.nim (renamed from tests/table/ttables2.nim)10
-rw-r--r--tests/collections/ttablesref.nim (renamed from tests/table/ptables.nim)13
-rw-r--r--tests/collections/ttablesref2.nim (renamed from tests/table/ptables2.nim)0
-rw-r--r--tests/concepts/mvarconcept.nim13
-rw-r--r--tests/concepts/tmanual.nim (renamed from tests/metatype/udtcmanual.nim)6
-rw-r--r--tests/concepts/tswizzle.nim (renamed from tests/metatype/swizzle.nim)51
-rw-r--r--tests/concepts/tusertypeclasses.nim (renamed from tests/metatype/tusertypeclasses.nim)33
-rw-r--r--tests/concepts/tusertypeclasses2.nim (renamed from tests/metatype/tusertypeclasses2.nim)4
-rw-r--r--tests/concepts/tvarconcept.nim9
-rw-r--r--tests/converter/ttypeconverter1.nim2
-rw-r--r--tests/cpp/tcppraise.nim17
-rw-r--r--tests/cpp/tget_subsystem.nim23
-rw-r--r--tests/cpp/trawsockets.nim5
-rw-r--r--tests/cpp/tstaticvar_via_typedesc.nim20
-rw-r--r--tests/cpp/tthread_createthread.nim14
-rw-r--r--tests/cpp/ttypeinfo.nim5
-rw-r--r--tests/cpp/tvector_iterator.nim19
-rw-r--r--tests/cpp/tvectorseq.nim38
-rw-r--r--tests/deprecated/tdeprecated.nim6
-rw-r--r--tests/destructor/tdestructor.nim16
-rw-r--r--tests/destructor/tdestructor2.nim18
-rw-r--r--tests/dir with space/tspace.nim3
-rw-r--r--tests/dll/client.nim.cfg (renamed from tests/dll/client.nimrod.cfg)0
-rw-r--r--tests/dll/server.nim.cfg (renamed from tests/dll/server.nimrod.cfg)0
-rw-r--r--tests/effects/teffects1.nim1
-rw-r--r--tests/effects/tgcsafe.nim2
-rw-r--r--tests/enum/tenumitems.nim2
-rw-r--r--tests/exception/tdefer1.nim18
-rw-r--r--tests/exception/texceptionbreak.nim20
-rw-r--r--tests/exception/texceptions.nim6
-rw-r--r--tests/exception/texcsub.nim8
-rw-r--r--tests/exception/tfinally4.nim8
-rw-r--r--tests/exception/tnestedreturn.nim4
-rw-r--r--tests/exception/tonraise.nim8
-rw-r--r--tests/exception/treraise.nim4
-rw-r--r--tests/exprs/texprstmt.nim2
-rw-r--r--tests/exprs/thighCString.nim6
-rw-r--r--tests/exprs/tresultwarning.nim6
-rw-r--r--tests/fields/tfields_in_template.nim15
-rw-r--r--tests/fields/tfields_with_break.nim33
-rw-r--r--tests/gc/closureleak.nim4
-rw-r--r--tests/gc/cyclecollector.nim21
-rw-r--r--tests/gc/gcleak4.nim4
-rw-r--r--tests/gc/gctest.nim3
-rw-r--r--tests/gc/growobjcrash.nim29
-rw-r--r--tests/generics/t1050.nim16
-rw-r--r--tests/generics/t1056.nim25
-rw-r--r--tests/generics/t1789.nim44
-rw-r--r--tests/generics/tableref_is_nil.nim9
-rw-r--r--tests/generics/tarray_with_somenumber.nim11
-rw-r--r--tests/generics/tconfusing_arrow.nim15
-rw-r--r--tests/generics/tgeneric3.nim2
-rw-r--r--tests/generics/tgeneric_closure.nim37
-rw-r--r--tests/generics/tgeneric_inheritance.nim19
-rw-r--r--tests/generics/tmetafield.nim2
-rw-r--r--tests/generics/tunique_type.nim67
-rw-r--r--tests/generics/twrong_field_caching.nim68
-rw-r--r--tests/generics/twrong_floatlit_type.nim118
-rw-r--r--tests/generics/twrong_generic_object.nim21
-rw-r--r--tests/global/tglobal.nim2
-rw-r--r--tests/implicit/timplictderef.nim21
-rw-r--r--tests/init/tuninit2.nim54
-rw-r--r--tests/iter/tchainediterators.nim5
-rw-r--r--tests/iter/tconcat.nim24
-rw-r--r--tests/iter/timplicit_auto.nim18
-rw-r--r--tests/iter/tobj_iter.nim20
-rw-r--r--tests/iter/tscheduler.nim76
-rw-r--r--tests/iter/tshallowcopy_closures.nim31
-rw-r--r--tests/js/taddr.nim36
-rw-r--r--tests/js/test2.nim11
-rw-r--r--tests/js/tfloatround.nim7
-rw-r--r--tests/js/tstringitems.nim24
-rw-r--r--tests/js/tunittests.nim7
-rw-r--r--tests/let/tlet2.nim2
-rw-r--r--tests/macros/macro_bug.nim17
-rw-r--r--tests/macros/tbugs.nim6
-rw-r--r--tests/macros/tdumpast.nim8
-rw-r--r--tests/macros/tdumpast2.nim14
-rw-r--r--tests/macros/tgensym.nim12
-rw-r--r--tests/macros/tgentemplates.nim4
-rw-r--r--tests/macros/tlexerex.nim16
-rw-r--r--tests/macros/tmacro1.nim6
-rw-r--r--tests/macros/tmacro3.nim4
-rw-r--r--tests/macros/tmacro4.nim2
-rw-r--r--tests/macros/tmacro5.nim8
-rw-r--r--tests/macros/tmacro_in_template.nim10
-rw-r--r--tests/macros/tmacros1.nim4
-rw-r--r--tests/macros/tmacrotypes.nim14
-rw-r--r--tests/macros/tnimnode_for_runtime.nim (renamed from tests/macros/tnimrodnode_for_runtime.nim)3
-rw-r--r--tests/macros/treturnsempty.nim12
-rw-r--r--tests/macros/tsame_name_497.nim9
-rw-r--r--tests/macros/tstringinterp.nim12
-rw-r--r--tests/macros/ttryparseexpr.nim1
-rw-r--r--tests/macros/tvarnimnode.nim2
-rw-r--r--tests/macros/typesapi.nim17
-rw-r--r--tests/macros/typesapi2.nim49
-rw-r--r--tests/manyloc/argument_parser/argument_parser.nim8
-rw-r--r--tests/manyloc/argument_parser/ex_wget.nim8
-rw-r--r--tests/manyloc/keineschweine/README.md6
-rw-r--r--tests/manyloc/keineschweine/dependencies/chipmunk/chipmunk.nim72
-rw-r--r--tests/manyloc/keineschweine/dependencies/enet/enet.nim2
-rw-r--r--tests/manyloc/keineschweine/dependencies/genpacket/genpacket.nim50
-rw-r--r--tests/manyloc/keineschweine/dependencies/genpacket/genpacket_enet.nim61
-rw-r--r--tests/manyloc/keineschweine/dependencies/genpacket/macro_dsl.nim26
-rw-r--r--tests/manyloc/keineschweine/dependencies/genpacket/streams_enh.nim6
-rw-r--r--tests/manyloc/keineschweine/dependencies/sfml/sfml.nim22
-rw-r--r--tests/manyloc/keineschweine/dependencies/sfml/sfml_audio.nim6
-rw-r--r--tests/manyloc/keineschweine/enet_server/enet_client.nim1
-rw-r--r--tests/manyloc/keineschweine/enet_server/enet_server.nim2
-rw-r--r--tests/manyloc/keineschweine/enet_server/nim.cfg (renamed from tests/manyloc/keineschweine/enet_server/nimrod.cfg)0
-rw-r--r--tests/manyloc/keineschweine/keineschweine.nim26
-rw-r--r--tests/manyloc/keineschweine/lib/game_objects.nim2
-rw-r--r--tests/manyloc/keineschweine/lib/gl.nim64
-rw-r--r--tests/manyloc/keineschweine/lib/map_filter.nim14
-rw-r--r--tests/manyloc/keineschweine/lib/sg_assets.nim8
-rw-r--r--tests/manyloc/keineschweine/lib/sg_packets.nim6
-rw-r--r--tests/manyloc/keineschweine/lib/vehicles.nim8
-rw-r--r--tests/manyloc/keineschweine/lib/zlib_helpers.nim14
-rw-r--r--tests/manyloc/keineschweine/server/nim.cfg (renamed from tests/manyloc/keineschweine/server/nimrod.cfg)0
-rw-r--r--tests/manyloc/keineschweine/server/old_sg_server.nim2
-rw-r--r--tests/manyloc/named_argument_bug/tri_engine/gfx/color.nim3
-rw-r--r--tests/manyloc/named_argument_bug/tri_engine/gfx/gl/gl.nim2
-rw-r--r--tests/manyloc/named_argument_bug/tri_engine/gfx/gl/primitive.nim8
-rw-r--r--tests/manyloc/named_argument_bug/tri_engine/gfx/gl/shader.nim10
-rw-r--r--tests/manyloc/standalone/barebone.nim3
-rw-r--r--tests/metatype/tautoproc.nim8
-rw-r--r--tests/metatype/tcompositetypeclasses.nim2
-rw-r--r--tests/metatype/tmatrix.nim (renamed from tests/matrix/tmatrix.nim)0
-rw-r--r--tests/metatype/tmatrix1.nim (renamed from tests/matrix/tmatrix1.nim)0
-rw-r--r--tests/metatype/tmatrix2.nim (renamed from tests/matrix/tmatrix2.nim)0
-rw-r--r--tests/metatype/tmatrix3.nim19
-rw-r--r--tests/metatype/tsemistatic.nim8
-rw-r--r--tests/metatype/tstatic_overloading.nim10
-rw-r--r--tests/metatype/tstaticparammacro.nim (renamed from tests/static/tstaticparammacro.nim)23
-rw-r--r--tests/metatype/tstaticparams.nim86
-rw-r--r--tests/metatype/tstaticvector.nim17
-rw-r--r--tests/metatype/ttypedesc2.nim37
-rw-r--r--tests/metatype/ttypetraits.nim1
-rw-r--r--tests/metatype/tymatrix.nim (renamed from tests/matrix/issue1013.nim)0
-rw-r--r--tests/metatype/typeclassinference.nim1
-rw-r--r--tests/metatype/typedesc_as_value.nim11
-rw-r--r--tests/method/temptybody.nim11
-rw-r--r--tests/misc/parsecomb.nim105
-rw-r--r--tests/misc/tcharinc.nim10
-rw-r--r--tests/misc/tgtk.nim53
-rw-r--r--tests/misc/tinc.nim2
-rw-r--r--tests/misc/tinout.nim2
-rw-r--r--tests/misc/tissue710.nim2
-rw-r--r--tests/misc/tlibs.nim28
-rw-r--r--tests/misc/tnewlibs.nim21
-rw-r--r--tests/misc/tnoop.nim7
-rw-r--r--tests/misc/tparsecombnum.nim55
-rw-r--r--tests/misc/trangechecks.nim43
-rw-r--r--tests/misc/tslices.nim6
-rw-r--r--tests/misc/tunsigned64mod.nim14
-rw-r--r--tests/misc/tunsignedcomp.nim136
-rw-r--r--tests/misc/tunsignedconv.nim43
-rw-r--r--tests/misc/tunsignedinc.nim14
-rw-r--r--tests/misc/tvarious.nim112
-rw-r--r--tests/module/trecinca.nim12
-rw-r--r--tests/module/trecincb.nim13
-rw-r--r--tests/modules/mnamspc1.nim (renamed from tests/namspc/mnamspc1.nim)0
-rw-r--r--tests/modules/mnamspc2.nim (renamed from tests/namspc/mnamspc2.nim)0
-rw-r--r--tests/modules/mopaque.nim (renamed from tests/module/mopaque.nim)0
-rw-r--r--tests/modules/mrecmod.nim (renamed from tests/module/mrecmod.nim)0
-rw-r--r--tests/modules/mrecmod2.nim (renamed from tests/module/mrecmod2.nim)0
-rw-r--r--tests/modules/tmismatchedvisibility.nim4
-rw-r--r--tests/modules/tnamspc.nim (renamed from tests/namspc/tnamspc.nim)0
-rw-r--r--tests/modules/topaque.nim (renamed from tests/module/topaque.nim)0
-rw-r--r--tests/modules/trecinca.nim12
-rw-r--r--tests/modules/trecincb.nim13
-rw-r--r--tests/modules/trecmod.nim (renamed from tests/module/trecmod.nim)0
-rw-r--r--tests/modules/trecmod2.nim (renamed from tests/module/trecmod2.nim)0
-rw-r--r--tests/notnil/tnotnil4.nim8
-rw-r--r--tests/notnil/tnotnil_in_generic.nim27
-rw-r--r--tests/notnil/tnotnil_in_objconstr.nim14
-rw-r--r--tests/objects/tillegal_recursion.nim7
-rw-r--r--tests/objects/tobjconstr.nim26
-rw-r--r--tests/objects/tobjloop.nim15
-rw-r--r--tests/objects/tobjpragma.nim3
-rw-r--r--tests/objects/trefobjsyntax.nim27
-rw-r--r--tests/objects/trefobjsyntax2.nim19
-rw-r--r--tests/objvariant/tadrdisc.nim13
-rw-r--r--tests/objvariant/treassign.nim27
-rw-r--r--tests/osproc/tstdin.nim9
-rw-r--r--tests/overload/toverprc.nim30
-rw-r--r--tests/overload/tparams_after_varargs.nim17
-rw-r--r--tests/overload/tprefer_specialized_generic.nim22
-rw-r--r--tests/overload/tprefer_tygenericinst.nim42
-rw-r--r--tests/overload/tspec.nim118
-rw-r--r--tests/overload/tstmtoverload.nim38
-rw-r--r--tests/overload/tsymtabchange_during_or.nim24
-rw-r--r--tests/overload/tsystemcmp.nim13
-rw-r--r--tests/parallel/tarray_of_channels.nim26
-rw-r--r--tests/parallel/tconvexhull.nim2
-rw-r--r--tests/parallel/tdont_be_stupid.nim15
-rw-r--r--tests/parallel/tgc_unsafe.nim32
-rw-r--r--tests/parallel/tgc_unsafe2.nim39
-rw-r--r--tests/parallel/tmissing_deepcopy.nim40
-rw-r--r--tests/parallel/tsimple_array_checks.nim41
-rw-r--r--tests/parallel/twrong_refcounts.nim53
-rw-r--r--tests/parser/tcommand_as_expr.nim9
-rw-r--r--tests/parser/tinvcolonlocation1.nim12
-rw-r--r--tests/parser/tinvcolonlocation2.nim15
-rw-r--r--tests/parser/tinvcolonlocation3.nim12
-rw-r--r--tests/parser/tproctype_pragmas.nim19
-rw-r--r--tests/parser/tstrongspaces.nim33
-rw-r--r--tests/parser/ttupleunpack.nim35
-rw-r--r--tests/parser/ttypeof.nim26
-rw-r--r--tests/parser/twhen_in_enum.nim11
-rw-r--r--tests/rodfiles/nim.cfg (renamed from tests/rodfiles/nimrod.cfg)0
-rw-r--r--tests/seq/tsequtils.nim2
-rw-r--r--tests/sets/tsets.nim170
-rw-r--r--tests/showoff/tdrdobbs_examples.nim12
-rw-r--r--tests/stdlib/tcount.nim29
-rw-r--r--tests/stdlib/tdialogs.nim17
-rw-r--r--tests/stdlib/tgetfileinfo.nim17
-rw-r--r--tests/stdlib/tircbot.nim452
-rw-r--r--tests/stdlib/tmarshal.nim12
-rw-r--r--tests/stdlib/tmitems.nim136
-rw-r--r--tests/stdlib/tnet.nim47
-rw-r--r--tests/stdlib/tpegs.nim28
-rw-r--r--tests/stdlib/tpermutations.nim19
-rw-r--r--tests/stdlib/treloop.nim9
-rw-r--r--tests/stdlib/tsinglylinkedring.nim29
-rw-r--r--tests/stdlib/tstrutil.nim57
-rw-r--r--tests/system/tsettostring.nim8
-rw-r--r--tests/table/ttables.nim128
-rw-r--r--tests/template/t2do.nim22
-rw-r--r--tests/template/t_otemplates.nim10
-rw-r--r--tests/template/texponential_eval.nim47
-rw-r--r--tests/template/tparams_gensymed.nim62
-rw-r--r--tests/template/tscope.nim12
-rw-r--r--tests/template/tstmt_semchecked_twice.nim30
-rw-r--r--tests/template/ttempl2.nim8
-rw-r--r--tests/template/twrongmapit.nim2
-rw-r--r--tests/template/utemplates.nim6
-rw-r--r--tests/testament/backend.nim2
-rw-r--r--tests/testament/caasdriver.nim15
-rw-r--r--tests/testament/categories.nim114
-rw-r--r--tests/testament/htmlgen.nim41
-rw-r--r--tests/testament/specs.nim28
-rw-r--r--tests/testament/tester.nim119
-rw-r--r--tests/testament/tester.nim.cfg1
-rw-r--r--tests/threads/ttryrecv.nim35
-rw-r--r--tests/trmacros/tor.nim2
-rw-r--r--tests/tuples/tanontuples.nim7
-rw-r--r--tests/tuples/tdifferent_instantiations.nim9
-rw-r--r--tests/tuples/tgeneric_tuple.nim9
-rw-r--r--tests/tuples/tgeneric_tuple2.nim17
-rw-r--r--tests/tuples/tuint_tuple.nim10
-rw-r--r--tests/tuples/tuple_with_nil.nim766
-rw-r--r--tests/typerel/tregionptrs2.nim23
-rw-r--r--tests/typerel/tsymchoice_for_expr.nim15
-rw-r--r--tests/typerel/typedescs.nim7
-rw-r--r--tests/types/tauto_canbe_void.nim9
-rw-r--r--tests/types/temptyseqs.nim68
-rw-r--r--tests/types/tforwty2.nim2
-rw-r--r--tests/types/tinfiniterecursion.nim8
-rw-r--r--tests/types/tisopr.nim58
-rw-r--r--tests/usingstmt/tusingstatement.nim22
-rw-r--r--tests/vm/tconsteval.nim2
-rw-r--r--tests/vm/tconsttable.nim19
-rw-r--r--tests/vm/tldconst.nim14
-rw-r--r--tests/vm/tstringnil.nim6
300 files changed, 5944 insertions, 1492 deletions
diff --git a/tests/actiontable/tactiontable2.nim b/tests/actiontable/tactiontable2.nim
index 99bb3dca0..fbc65a67d 100644
--- a/tests/actiontable/tactiontable2.nim
+++ b/tests/actiontable/tactiontable2.nim
@@ -1,6 +1,5 @@
 discard """
-  line: 21
-  errormsg: "invalid type: 'Table[string, proc (string){.gcsafe.}]'"
+  output: "action 3 arg"
 """
 
 import tables
diff --git a/tests/array/troof1.nim b/tests/array/troof1.nim
new file mode 100644
index 000000000..96669a121
--- /dev/null
+++ b/tests/array/troof1.nim
@@ -0,0 +1,36 @@
+discard """
+  output: '''@[2, 3, 4]321
+9.0 4.0
+(a: 1.0, b: 2.0, c: 8.0)2.0'''
+"""
+
+proc foo[T](x, y: T): T = x
+
+var a = @[1, 2, 3, 4]
+var b: array[3, array[2, float]] = [[1.0,2], [3.0,4], [8.0,9]]
+echo a[1.. ^1], a[^2], a[^3], a[^4]
+echo b[^1][^1], " ", (b[^2]).foo(b[^1])[^1]
+
+type
+  MyArray = object
+    a, b, c: float
+
+var
+  ma = MyArray(a: 1.0, b: 2.0, c: 3.0)
+
+proc len(x: MyArray): int = 3
+
+proc `[]=`(x: var MyArray; idx: range[0..2]; val: float) =
+  case idx
+  of 0: x.a = val
+  of 1: x.b = val
+  of 2: x.c = val
+
+proc `[]`(x: var MyArray; idx: range[0..2]): float =
+  case idx
+  of 0: result = x.a
+  of 1: result = x.b
+  of 2: result = x.c
+
+ma[^1] = 8.0
+echo ma, ma[^2]
diff --git a/tests/array/troof2.nim b/tests/array/troof2.nim
new file mode 100644
index 000000000..d4c1a4982
--- /dev/null
+++ b/tests/array/troof2.nim
@@ -0,0 +1,10 @@
+discard """
+  errormsg: "invalid context for '^' as 'foo()' has side effects"
+  line: "9"
+"""
+
+proc foo(): seq[int] =
+  echo "ha"
+
+let f = foo()[^1]
+
diff --git a/tests/array/troof3.nim b/tests/array/troof3.nim
new file mode 100644
index 000000000..4b6e22223
--- /dev/null
+++ b/tests/array/troof3.nim
@@ -0,0 +1,8 @@
+discard """
+  errormsg: "invalid context for '^' as len!=high+1 for 'a'"
+  line: "8"
+"""
+
+var a: array[1..3, string]
+
+echo a[^1]
diff --git a/tests/array/troof4.nim b/tests/array/troof4.nim
new file mode 100644
index 000000000..7a262d9de
--- /dev/null
+++ b/tests/array/troof4.nim
@@ -0,0 +1,37 @@
+discard """
+  errormsg: "no surrounding array access context for '^'"
+  line: "37"
+"""
+
+proc foo[T](x, y: T): T = x
+
+var a = @[1, 2, 3, 4]
+var b: array[3, array[2, float]] = [[1.0,2], [3.0,4], [8.0,9]]
+echo a[1.. ^1], a[^2], a[^3], a[^4]
+echo b[^1][^1], " ", (b[^2]).foo(b[^1])[^1]
+
+type
+  MyArray = object
+    a, b, c: float
+
+var
+  ma = MyArray(a: 1.0, b: 2.0, c: 3.0)
+
+proc len(x: MyArray): int = 3
+
+proc `[]=`(x: var MyArray; idx: range[0..2]; val: float) =
+  case idx
+  of 0: x.a = val
+  of 1: x.b = val
+  of 2: x.c = val
+
+proc `[]`(x: var MyArray; idx: range[0..2]): float =
+  case idx
+  of 0: result = x.a
+  of 1: result = x.b
+  of 2: result = x.c
+
+ma[^1] = 8.0
+echo ma, ma[^2]
+
+echo(^1)
diff --git a/tests/assert/tfailedassert.nim b/tests/assert/tfailedassert.nim
index 4994e13c8..1e6764471 100644
--- a/tests/assert/tfailedassert.nim
+++ b/tests/assert/tfailedassert.nim
@@ -1,16 +1,16 @@
 discard """
   output: '''
-WARNING: false first asseertion from bar
+WARNING: false first assertion from bar
 ERROR: false second assertion from bar
 -1
-tfailedassert.nim:27 false assertion from foo
+tests/assert/tfailedassert.nim:27 false assertion from foo
 '''
 """
 
 type
   TLineInfo = tuple[filename: string, line: int]
 
-  TMyError = object of E_Base
+  TMyError = object of Exception
     lineinfo: TLineInfo
 
   EMyError = ref TMyError
@@ -30,8 +30,8 @@ proc bar: int =
   # local overrides that are active only
   # in this proc
   onFailedAssert(msg): echo "WARNING: " & msg
-    
-  assert(false, "first asseertion from bar")
+
+  assert(false, "first assertion from bar")
 
   onFailedAssert(msg):
     echo "ERROR: " & msg
diff --git a/tests/assign/moverload_asgn2.nim b/tests/assign/moverload_asgn2.nim
new file mode 100644
index 000000000..6620adbeb
--- /dev/null
+++ b/tests/assign/moverload_asgn2.nim
@@ -0,0 +1,10 @@
+type
+  Concrete* = object
+    a*, b*: string
+    rc*: int # refcount
+
+proc `=`(d: var Concrete; src: Concrete) =
+  shallowCopy(d.a, src.a)
+  shallowCopy(d.b, src.b)
+  dec d.rc
+  d.rc = src.rc + 1
diff --git a/tests/assign/toverload_asgn1.nim b/tests/assign/toverload_asgn1.nim
new file mode 100644
index 000000000..dbc3a71c4
--- /dev/null
+++ b/tests/assign/toverload_asgn1.nim
@@ -0,0 +1,75 @@
+discard """
+  output: '''Concrete '='
+Concrete '='
+Concrete '='
+Concrete '='
+Concrete '='
+GenericT[T] '=' int
+GenericT[T] '=' float
+GenericT[T] '=' float
+GenericT[T] '=' float
+GenericT[T] '=' string
+GenericT[T] '=' int8
+GenericT[T] '=' bool
+GenericT[T] '=' bool
+GenericT[T] '=' bool
+GenericT[T] '=' bool'''
+"""
+
+import typetraits
+
+type
+  Concrete = object
+    a, b: string
+
+proc `=`(d: var Concrete; src: Concrete) =
+  shallowCopy(d.a, src.a)
+  shallowCopy(d.b, src.b)
+  echo "Concrete '='"
+
+var x, y: array[0..2, Concrete]
+var cA, cB: Concrete
+
+var cATup, cBTup: tuple[x: int, ha: Concrete]
+
+x = y
+cA = cB
+cATup = cBTup
+
+type
+  GenericT[T] = object
+    a, b: T
+
+proc `=`[T](d: var GenericT[T]; src: GenericT[T]) =
+  shallowCopy(d.a, src.a)
+  shallowCopy(d.b, src.b)
+  echo "GenericT[T] '=' ", type(T).name
+
+var ag: GenericT[int]
+var bg: GenericT[int]
+
+ag = bg
+
+var xg, yg: array[0..2, GenericT[float]]
+var cAg, cBg: GenericT[string]
+
+var cATupg, cBTupg: tuple[x: int, ha: GenericT[int8]]
+
+xg = yg
+cAg = cBg
+cATupg = cBTupg
+
+var caSeqg, cbSeqg: seq[GenericT[bool]]
+newSeq(cbSeqg, 4)
+caSeqg = cbSeqg
+
+when false:
+  type
+    Foo = object
+      case b: bool
+      of false: xx: GenericT[int]
+      of true: yy: bool
+
+  var
+    a, b: Foo
+  a = b
diff --git a/tests/assign/toverload_asgn2.nim b/tests/assign/toverload_asgn2.nim
new file mode 100644
index 000000000..243c90494
--- /dev/null
+++ b/tests/assign/toverload_asgn2.nim
@@ -0,0 +1,22 @@
+discard """
+  output: '''i value 88
+2aa'''
+"""
+
+import moverload_asgn2
+
+proc passAround(i: int): Concrete =
+  echo "i value ", i
+  result = Concrete(a: "aa", b: "bb", rc: 0)
+
+proc main =
+  let
+    i = 88
+    v = passAround(i)
+    z = v.a
+  var
+    x: Concrete
+  x = v
+  echo x.rc, z # 2aa
+
+main()
diff --git a/tests/async/tasyncexceptions.nim b/tests/async/tasyncexceptions.nim
index 30ef41756..c4379f7d8 100644
--- a/tests/async/tasyncexceptions.nim
+++ b/tests/async/tasyncexceptions.nim
@@ -19,7 +19,6 @@ proc processClient(fd: int) {.async.} =
   var foo = line[0]
   if foo == 'g':
     raise newException(EBase, "foobar")
-  
 
 proc serve() {.async.} =
 
diff --git a/tests/async/tasynctry.nim b/tests/async/tasynctry.nim
index 66ea40d49..f77198e2e 100644
--- a/tests/async/tasynctry.nim
+++ b/tests/async/tasynctry.nim
@@ -49,3 +49,56 @@ proc catch() {.async.} =
     assert false
 
 asyncCheck catch()
+
+proc test(): Future[bool] {.async.} =
+  result = false
+  try:
+    raise newException(OSError, "Foobar")
+  except:
+    result = true
+    return
+
+proc foo(): Future[bool] {.async.} = discard
+
+proc test2(): Future[bool] {.async.} =
+  result = false
+  try:
+    discard await foo()
+    raise newException(OSError, "Foobar")
+  except:
+    result = true
+    return
+
+proc test3(): Future[int] {.async.} =
+  result = 0
+  try:
+    try:
+      discard await foo()
+      raise newException(OSError, "Hello")
+    except:
+      result = 1
+      raise
+  except:
+    result = 2
+    return
+
+proc test4(): Future[int] {.async.} =
+  try:
+    discard await foo()
+    raise newException(ValueError, "Test4")
+  except OSError:
+    result = 1
+  except:
+    result = 2
+
+var x = test()
+assert x.read
+
+x = test2()
+assert x.read
+
+var y = test3()
+assert y.read == 2
+
+y = test4()
+assert y.read == 2
diff --git a/tests/async/tasynctry2.nim b/tests/async/tasynctry2.nim
new file mode 100644
index 000000000..444a058be
--- /dev/null
+++ b/tests/async/tasynctry2.nim
@@ -0,0 +1,16 @@
+discard """
+  file: "tasynctry2.nim"
+  errormsg: "\'yield\' cannot be used within \'try\' in a non-inlined iterator"
+  line: 15
+"""
+import asyncdispatch
+
+proc foo(): Future[bool] {.async.} = discard
+
+proc test5(): Future[int] {.async.} =
+  try:
+    discard await foo()
+    raise newException(ValueError, "Test5")
+  except:
+    discard await foo()
+    result = 0
diff --git a/tests/bind/tnicerrorforsymchoice.nim b/tests/bind/tnicerrorforsymchoice.nim
index e1ff090dd..5145fdcff 100644
--- a/tests/bind/tnicerrorforsymchoice.nim
+++ b/tests/bind/tnicerrorforsymchoice.nim
@@ -1,17 +1,17 @@
 discard """
   line: 18
-  errormsg: "type mismatch: got (proc (TScgi) | proc (AsyncSocket, StringTableRef, string){.gcsafe.})"
+  errormsg: "type mismatch: got (proc (s: TScgi) | proc (client: AsyncSocket, headers: StringTableRef, input: string){.gcsafe, locks: 0.}"
 """
 
 #bug #442
 import scgi, sockets, asyncio, strtabs
 proc handleSCGIRequest[TScgi: ScgiState | AsyncScgiState](s: TScgi) =
   discard
-proc handleSCGIRequest(client: AsyncSocket, headers: StringTableRef, 
+proc handleSCGIRequest(client: AsyncSocket, headers: StringTableRef,
                        input: string) =
   discard
 
-proc test(handle: proc (client: AsyncSocket, headers: StringTableRef, 
+proc test(handle: proc (client: AsyncSocket, headers: StringTableRef,
                         input: string), b: int) =
   discard
 
diff --git a/tests/caas/idetools_api.nim b/tests/caas/idetools_api.nim
index 8f1061e27..281e562d7 100644
--- a/tests/caas/idetools_api.nim
+++ b/tests/caas/idetools_api.nim
@@ -58,7 +58,7 @@ macro expect*(exceptions: varargs[expr], body: stmt): stmt {.immediate.} =
   ## Expect docstrings
   let exp = callsite()
   template expectBody(errorTypes, lineInfoLit: expr,
-                      body: stmt): PNimrodNode {.dirty.} =
+                      body: stmt): NimNode {.dirty.} =
     try:
       body
       assert false
diff --git a/tests/caas/issue_416_template_shift.txt b/tests/caas/issue_416_template_shift.txt
index b1f47c1ac..e911c1360 100644
--- a/tests/caas/issue_416_template_shift.txt
+++ b/tests/caas/issue_416_template_shift.txt
@@ -6,7 +6,7 @@ def\tskType\tsystem.string\tstring
 > idetools --track:$TESTNIM,12,35 --def $SILENT
 def\tskLet\t$MODULE.failtest.input\tTaintedString
 
-# The following fail because they seem shifted one colum to the right.
+# The following fail because they seem shifted one column to the right.
 > idetools --track:$TESTNIM,12,16 --def $SILENT
 def\tskTemplate\tsequtils.toSeq\tproc \(expr\): expr
 > idetools --track:$TESTNIM,12,22 --def $SILENT
diff --git a/tests/caas/its_full_of_procs.nim b/tests/caas/its_full_of_procs.nim
index 45347490c..8f8b66764 100644
--- a/tests/caas/its_full_of_procs.nim
+++ b/tests/caas/its_full_of_procs.nim
@@ -2,7 +2,7 @@ import unicode, sequtils
 
 # This example shows that idetools returns proc as signature for everything
 # which can be called. While a clever person would use the second column to
-# differentiate betwen procs, methods and others, why does the output contain
+# differentiate between procs, methods and others, why does the output contain
 # incorrect information?
 
 type
diff --git a/tests/casestmt/tcase_emptyset_when.nim b/tests/casestmt/tcase_emptyset_when.nim
new file mode 100644
index 000000000..e9b1ec2df
--- /dev/null
+++ b/tests/casestmt/tcase_emptyset_when.nim
@@ -0,0 +1,24 @@
+discard """
+  file: "tcaseofwhen.nim"
+  outputsub: "compiles for 1\ni am always two\ndefault for 3\nset is 4 not 5\narray is 6 not 7\ndefault for 8"
+  exitcode: "0"
+"""
+
+proc whenCase(a: int) =
+  case a
+  of (when compiles(whenCase(1)): 1 else: {}): echo "compiles for 1"
+  of {}: echo "me not fail"
+  of 2: echo "i am always two"
+  of []: echo "me neither"
+  of {4,5}: echo "set is 4 not 5"
+  of [6,7]: echo "array is 6 not 7"
+  of (when compiles(neverCompilesIBet()): 3 else: {}): echo "compiles for 3"
+  #of {},[]: echo "me neither"
+  else: echo "default for ", a
+
+whenCase(1)
+whenCase(2)
+whenCase(3)
+whenCase(4)
+whenCase(6)
+whenCase(8)
diff --git a/tests/casestmt/tcomputedgoto.nim b/tests/casestmt/tcomputedgoto.nim
index b21fc07a3..f567174af 100644
--- a/tests/casestmt/tcomputedgoto.nim
+++ b/tests/casestmt/tcomputedgoto.nim
@@ -15,7 +15,7 @@ yeah A enumB'''
 
 type
   MyEnum = enum
-    enumA, enumB, enumC, enumD, enumE
+    enumA, enumB, enumC, enumD, enumE, enumLast
 
 proc vm() =
   var instructions: array [0..100, MyEnum]
@@ -42,6 +42,7 @@ proc vm() =
       echo "yeah B ", ra
     of enumE:
       break
+    of enumLast: discard
     inc(pc)
-  
+
 vm()
diff --git a/tests/ccgbugs/tarray_equality.nim b/tests/ccgbugs/tarray_equality.nim
new file mode 100644
index 000000000..66a953439
--- /dev/null
+++ b/tests/ccgbugs/tarray_equality.nim
@@ -0,0 +1,15 @@
+discard """
+  output: '''true
+true'''
+"""
+
+# bug #2489
+
+let a = [1]
+let b = [1]
+echo a == b
+
+# bug #2498
+var x: array[0, int]
+var y: array[0, int]
+echo x == y
diff --git a/tests/ccgbugs/tmissingderef.nim b/tests/ccgbugs/tmissingderef.nim
new file mode 100644
index 000000000..edff1dd4e
--- /dev/null
+++ b/tests/ccgbugs/tmissingderef.nim
@@ -0,0 +1,30 @@
+discard """
+  output: '''255
+1 1
+0.5'''
+"""
+
+# bug #1181
+
+type
+  TFoo = object
+    x: int32
+
+proc mainowar =
+  var foo: TFoo
+  foo.x = 0xff
+  var arr1 = cast[ptr array[4, uint8]](addr foo)[] # Fails.
+  echo arr1[when cpuEndian == littleEndian: 0 else: 3]
+
+  var i = 1i32
+  let x = addr i
+  var arr2 = cast[ptr array[4, uint8]](x)[] # Fails.
+  echo arr2[when cpuEndian == littleEndian: 0 else: 3], " ", i
+
+  # bug #1715
+  var a: array[2, float32] = [0.5'f32, 0.7]
+  let p = addr a
+  var b = p[]
+  echo b[0]
+
+mainowar()
diff --git a/tests/ccgbugs/tpartialcs.nim b/tests/ccgbugs/tpartialcs.nim
new file mode 100644
index 000000000..12ff65c37
--- /dev/null
+++ b/tests/ccgbugs/tpartialcs.nim
@@ -0,0 +1,20 @@
+
+# bug #2551
+
+type Tup = tuple
+  A, a: int
+
+type Obj = object
+  A, a: int
+
+var x: Tup # This works.
+var y: Obj # This doesn't.
+
+# bug #2212
+
+proc f() =
+  let
+    p = 1.0
+    P = 0.25 + 0.5
+
+f()
diff --git a/tests/ccgbugs/trecursive_closure.nim b/tests/ccgbugs/trecursive_closure.nim
new file mode 100644
index 000000000..50c363a4a
--- /dev/null
+++ b/tests/ccgbugs/trecursive_closure.nim
@@ -0,0 +1,8 @@
+# bug #2233
+type MalType = object
+  fun: proc: MalType
+
+proc f(x: proc: MalType) =
+  discard x()
+
+f(nil)
diff --git a/tests/ccgbugs/trecursive_table.nim b/tests/ccgbugs/trecursive_table.nim
new file mode 100644
index 000000000..3406a1c31
--- /dev/null
+++ b/tests/ccgbugs/trecursive_table.nim
@@ -0,0 +1,17 @@
+
+# bug #1700
+import tables
+
+type
+  E* = enum
+    eX
+    eY
+  T* = object
+    case kind: E
+    of eX:
+      xVal: Table[string, T]
+    of eY:
+      nil
+
+proc p*(x: Table[string, T]) =
+  discard
diff --git a/tests/ccgbugs/tstringslice.nim b/tests/ccgbugs/tstringslice.nim
new file mode 100644
index 000000000..00c1adf74
--- /dev/null
+++ b/tests/ccgbugs/tstringslice.nim
@@ -0,0 +1,24 @@
+discard """
+  output: '''1
+1234
+1234
+2
+234
+234
+3
+34
+34
+4
+4
+4'''
+"""
+
+# bug #794
+type TRange = range[0..3]
+
+const str = "123456789"
+
+for i in TRange.low .. TRange.high:
+  echo str[i]                          #This works fine
+  echo str[int(i) .. int(TRange.high)] #So does this
+  echo str[i .. TRange.high]           #The compiler complains about this
diff --git a/tests/ccgbugs/tuple_canon.nim b/tests/ccgbugs/tuple_canon.nim
new file mode 100644
index 000000000..960e2aae9
--- /dev/null
+++ b/tests/ccgbugs/tuple_canon.nim
@@ -0,0 +1,80 @@
+# bug #2250
+
+import
+    math, strutils
+
+type
+    Meters = float
+    Point2[T] = tuple[x, y: T]
+
+    HexState* = enum
+        hsOn, hsOff
+
+    Index = uint16
+
+    HexGrid* = object
+        w, h: int                       ## Width and height of the hex grid.
+        radius: Meters                  ## Radius of circle that circumscribes a hexagon.
+        grid: seq[HexState]             ## Information on what hexes are drawn.
+
+    HexVtxIndex = enum
+        hiA, hiB, hiC, hiD, hiE, hiF
+
+    HexCoord* = Point2[int]
+
+const
+    HexDY = sqrt(1.0 - (0.5 * 0.5))     # dy from center to midpoint of 1-2
+    HexDX = sqrt(1.0 - (HexDY * HexDY)) # dx from center to midpoint of 1-5 (0.5)
+
+
+let
+    hexOffsets : array[HexVtxIndex, Point2[float]] = [
+                  (-1.0, 0.0),
+                  (-HexDX, -HexDY),
+                  (HexDX, -HexDY),
+                  (1.0, 0.0),
+                  (HexDX, HexDY),
+                  (-HexDX, HexDY)]
+
+    evenSharingOffsets : array[HexVtxIndex, tuple[hc: HexCoord; idx: HexVtxIndex]] = [
+            ((0,0), hiA),
+            ((0,0), hiB),
+            ((1,-1), hiA),
+            ((1,0), hiB),
+            ((1,0), hiA),
+            ((0,1), hiB)]
+
+    oddSharingOffsets : array[HexVtxIndex, tuple[hc: HexCoord; idx: HexVtxIndex]] = [
+            ((0,0), hiA),
+            ((0,0), hiB),
+            ((1,0), hiA),
+            ((1,1), hiB),
+            ((1,1), hiA),
+            ((0,1), hiB)]
+
+template odd*(i: int) : expr =
+    (i and 1) != 0
+
+proc vidx(hg: HexGrid; col, row: int; i: HexVtxIndex) : Index =
+    #NOTE: this variation compiles
+    #var offset : type(evenSharingOffsets[i])
+    #
+    #if odd(col):
+    #    offset = oddSharingOffsets[i]
+    #else:
+    #    offset = evenSharingOffsets[i]
+
+    let
+        #NOTE: this line generates the bad code
+        offset = (if odd(col): oddSharingOffsets[i] else: evenSharingOffsets[i])
+        x = col + 1 + offset.hc.x
+        y = row + 1 + offset.hc.y
+
+    result = Index(x*2 + y * (hg.w + 2)*2 + int(offset.idx))
+
+proc go() =
+    var hg : HexGrid
+
+    echo "vidx ", $vidx(hg, 1, 2, hiC)
+
+go()
diff --git a/tests/ccgbugs/twrong_tupleconv.nim b/tests/ccgbugs/twrong_tupleconv.nim
new file mode 100644
index 000000000..68413e96e
--- /dev/null
+++ b/tests/ccgbugs/twrong_tupleconv.nim
@@ -0,0 +1,20 @@
+# bug #1833
+iterator myitems*[T](a: var seq[T]): var T {.inline.} =
+  ## iterates over each item of `a` so that you can modify the yielded value.
+  var i = 0
+  let L = len(a)
+  while i < L:
+    yield a[i]
+    inc(i)
+    assert(len(a) == L, "seq modified while iterating over it")
+
+# Works fine
+var xs = @[1,2,3]
+for x in myitems(xs):
+  inc x
+
+# Tuples don't work
+var ys = @[(1,"a"),(2,"b"),(3,"c")]
+for y in myitems(ys):
+  inc y[0]
+
diff --git a/tests/clearmsg/ta.nim b/tests/clearmsg/ta.nim
index b21522d12..38449c319 100644
--- a/tests/clearmsg/ta.nim
+++ b/tests/clearmsg/ta.nim
@@ -1,5 +1,5 @@
 discard """
-  errormsg: 'type mismatch: got (mc.typ)'
+  errormsg: "type mismatch: got (mc.typ)"
   line: 12
 """
 
diff --git a/tests/clearmsg/tconsttypemismatch.nim b/tests/clearmsg/tconsttypemismatch.nim
new file mode 100644
index 000000000..edf480348
--- /dev/null
+++ b/tests/clearmsg/tconsttypemismatch.nim
@@ -0,0 +1,8 @@
+discard """
+  file: "tconsttypemismatch.nim"
+  line: 7
+  errormsg: "type mismatch"
+"""
+# bug #2252
+const foo: int = 1000 / 30
+
diff --git a/tests/closure/tfib50.nim b/tests/closure/tfib50.nim
new file mode 100644
index 000000000..719aa3ad5
--- /dev/null
+++ b/tests/closure/tfib50.nim
@@ -0,0 +1,22 @@
+discard """
+  output: "20365011074"
+"""
+
+import tables
+
+proc memoize(f: proc (a: int64): int64): proc (a: int64): int64 =
+    var previous = initTable[int64, int64]()
+    return proc(i: int64): int64 =
+        if not previous.hasKey i:
+            previous[i] = f(i)
+        return previous[i]
+
+var fib: proc(a: int64): int64
+
+fib = memoize(proc (i: int64): int64 =
+    if i == 0 or i == 1:
+        return 1
+    return fib(i-1) + fib(i-2)
+)
+
+echo fib(50)
diff --git a/tests/closure/tinvalidclosure.nim b/tests/closure/tinvalidclosure.nim
index 18968a6c6..c9136a736 100644
--- a/tests/closure/tinvalidclosure.nim
+++ b/tests/closure/tinvalidclosure.nim
@@ -1,6 +1,6 @@
 discard """
   line: 12
-  errormsg: "type mismatch: got (proc (int){.closure, gcsafe, locks: 0.})"
+  errormsg: "type mismatch: got (proc (x: int){.closure, gcsafe, locks: 0.})"
 """
 
 proc ugh[T](x: T) {.closure.} =
diff --git a/tests/closure/tissue1642.nim b/tests/closure/tissue1642.nim
new file mode 100644
index 000000000..e3028c88e
--- /dev/null
+++ b/tests/closure/tissue1642.nim
@@ -0,0 +1,7 @@
+discard """
+  file: "tissue1642.nim"
+  disabled: true
+"""
+block:
+  var i = 0
+  proc p() = inc(i)
diff --git a/tests/closure/ttimeinfo.nim b/tests/closure/ttimeinfo.nim
new file mode 100644
index 000000000..3138ae72e
--- /dev/null
+++ b/tests/closure/ttimeinfo.nim
@@ -0,0 +1,15 @@
+# bug #2073
+
+import sequtils
+import times
+
+# 1
+proc f(n: int): TimeInfo =
+  TimeInfo(year: n, month: mJan, monthday: 1)
+
+echo toSeq(2000 || 2015).map(f)
+
+# 2
+echo toSeq(2000 || 2015).map(proc (n: int): TimeInfo =
+  TimeInfo(year: n, month: mJan, monthday: 1)
+)
diff --git a/tests/collections/tindexby.nim b/tests/collections/tindexby.nim
new file mode 100644
index 000000000..f374d5504
--- /dev/null
+++ b/tests/collections/tindexby.nim
@@ -0,0 +1,22 @@
+import tables
+
+doAssert indexBy(newSeq[int](), proc(x: int):int = x) == initTable[int, int](), "empty int table"
+
+var tbl1 = initTable[int, int]()
+tbl1.add(1,1)
+tbl1.add(2,2)
+doAssert indexBy(@[1,2], proc(x: int):int = x) == tbl1, "int table"
+
+type
+  TElem = object
+    foo: int
+    bar: string
+    
+let
+  elem1 = TElem(foo: 1, bar: "bar")
+  elem2 = TElem(foo: 2, bar: "baz")
+  
+var tbl2 = initTable[string, TElem]()
+tbl2.add("bar", elem1)
+tbl2.add("baz", elem2)
+doAssert indexBy(@[elem1,elem2], proc(x: TElem): string = x.bar) == tbl2, "element table"
diff --git a/tests/table/ttableconstr.nim b/tests/collections/ttableconstr.nim
index 1a21a18d1..1a21a18d1 100644
--- a/tests/table/ttableconstr.nim
+++ b/tests/collections/ttableconstr.nim
diff --git a/tests/collections/ttables.nim b/tests/collections/ttables.nim
index f374d5504..3a923610e 100644
--- a/tests/collections/ttables.nim
+++ b/tests/collections/ttables.nim
@@ -1,22 +1,152 @@
-import tables
-
-doAssert indexBy(newSeq[int](), proc(x: int):int = x) == initTable[int, int](), "empty int table"
-
-var tbl1 = initTable[int, int]()
-tbl1.add(1,1)
-tbl1.add(2,2)
-doAssert indexBy(@[1,2], proc(x: int):int = x) == tbl1, "int table"
-
-type
-  TElem = object
-    foo: int
-    bar: string
-    
-let
-  elem1 = TElem(foo: 1, bar: "bar")
-  elem2 = TElem(foo: 2, bar: "baz")
+discard """
+  output: '''true'''
+"""
+
+import hashes, tables
+
+const
+  data = {
+    "34": 123456, "12": 789,
+    "90": 343, "0": 34404,
+    "1": 344004, "2": 344774,
+    "3": 342244, "4": 3412344,
+    "5": 341232144, "6": 34214544,
+    "7": 3434544, "8": 344544,
+    "9": 34435644, "---00": 346677844,
+    "10": 34484, "11": 34474, "19": 34464,
+    "20": 34454, "30": 34141244, "40": 344114,
+    "50": 344490, "60": 344491, "70": 344492,
+    "80": 344497}
+
+  sorteddata = {
+    "---00": 346677844,
+    "0": 34404,
+    "1": 344004,
+    "10": 34484, 
+    "11": 34474,
+    "12": 789,
+    "19": 34464,
+    "2": 344774, "20": 34454, 
+    "3": 342244, "30": 34141244,
+    "34": 123456,
+    "4": 3412344, "40": 344114,
+    "5": 341232144, "50": 344490, 
+    "6": 34214544, "60": 344491,
+    "7": 3434544, "70": 344492,
+    "8": 344544, "80": 344497,
+    "9": 34435644,
+    "90": 343}
+
+block tableTest1:
+  var t = initTable[tuple[x, y: int], string]()
+  t[(0,0)] = "00"
+  t[(1,0)] = "10"
+  t[(0,1)] = "01"
+  t[(1,1)] = "11"
+  for x in 0..1:
+    for y in 0..1:
+      assert t[(x,y)] == $x & $y
+  assert($t == 
+    "{(x: 0, y: 1): 01, (x: 0, y: 0): 00, (x: 1, y: 0): 10, (x: 1, y: 1): 11}")
+
+block tableTest2:
+  var t = initTable[string, float]()
+  t["test"] = 1.2345
+  t["111"] = 1.000043
+  t["123"] = 1.23
+  t.del("111")
   
-var tbl2 = initTable[string, TElem]()
-tbl2.add("bar", elem1)
-tbl2.add("baz", elem2)
-doAssert indexBy(@[elem1,elem2], proc(x: TElem): string = x.bar) == tbl2, "element table"
+  t["012"] = 67.9
+  t["123"] = 1.5 # test overwriting
+  
+  assert t["123"] == 1.5
+  assert t["111"] == 0.0 # deleted
+  assert(not hasKey(t, "111"))
+  
+  for key, val in items(data): t[key] = val.toFloat
+  for key, val in items(data): assert t[key] == val.toFloat
+
+  assert(not t.hasKeyOrPut("456", 4.0))     # test absent key
+  assert t.hasKeyOrPut("012", 3.0)          # test present key
+  var x = t.mgetOrPut("111", 1.5)           # test absent key
+  x = x * 2
+  assert x == 3.0
+  x = t.mgetOrPut("test", 1.5)              # test present key
+  x = x * 2
+  assert x == 2 * 1.2345
+
+block orderedTableTest1:
+  var t = initOrderedTable[string, int](2)
+  for key, val in items(data): t[key] = val
+  for key, val in items(data): assert t[key] == val
+  var i = 0
+  # `pairs` needs to yield in insertion order:
+  for key, val in pairs(t):
+    assert key == data[i][0]
+    assert val == data[i][1]
+    inc(i)
+
+  for key, val in mpairs(t): val = 99
+  for val in mvalues(t): assert val == 99
+
+block countTableTest1:
+  var s = data.toTable
+  var t = initCountTable[string]()
+  for k in s.keys: t.inc(k)
+  for k in t.keys: assert t[k] == 1
+  t.inc("90", 3)
+  t.inc("12", 2)
+  t.inc("34", 1)
+  assert t.largest()[0] == "90"
+
+  t.sort()
+  var i = 0
+  for k, v in t.pairs:
+    case i
+    of 0: assert k == "90" and v == 4
+    of 1: assert k == "12" and v == 3
+    of 2: assert k == "34" and v == 2
+    else: break
+    inc i
+
+block mpairsTableTest1:
+  var t = initTable[string, int]()
+  t["a"] = 1
+  t["b"] = 2
+  t["c"] = 3
+  t["d"] = 4
+  for k, v in t.mpairs:
+    if k == "a" or k == "c":
+      v = 9
+
+  for k, v in t.pairs:
+    if k == "a" or k == "c":
+      assert v == 9
+    else:
+      assert v != 1 and v != 3
+
+block SyntaxTest:
+  var x = toTable[int, string]({:})
+
+proc orderedTableSortTest() =
+  var t = initOrderedTable[string, int](2)
+  for key, val in items(data): t[key] = val
+  for key, val in items(data): assert t[key] == val
+  t.sort(proc (x, y: tuple[key: string, val: int]): int = cmp(x.key, y.key))
+  var i = 0
+  # `pairs` needs to yield in sorted order:
+  for key, val in pairs(t):
+    doAssert key == sorteddata[i][0]
+    doAssert val == sorteddata[i][1]
+    inc(i)
+
+  # check that lookup still works:
+  for key, val in pairs(t):
+    doAssert val == t[key]
+  # check that insert still works:
+  t["newKeyHere"] = 80
+
+
+orderedTableSortTest()
+echo "true"
+
diff --git a/tests/table/ttables2.nim b/tests/collections/ttables2.nim
index 611f3f8ec..6f3fa841a 100644
--- a/tests/table/ttables2.nim
+++ b/tests/collections/ttables2.nim
@@ -16,5 +16,15 @@ proc run1() =         # occupied Memory stays constant, but
   for i in 1 .. 50:   # aborts at run: 44 on win32 with 3.2GB with out of memory
     TestHashIntInt()
 
+# bug #2107
+
+var delTab = initTable[int,int](4)
+
+for i in 1..4:
+  delTab[i] = i
+  delTab.del(i)
+delTab[5] = 5
+
+
 run1()
 echo "true"
diff --git a/tests/table/ptables.nim b/tests/collections/ttablesref.nim
index 79a9aab17..16b0d831e 100644
--- a/tests/table/ptables.nim
+++ b/tests/collections/ttablesref.nim
@@ -2,7 +2,7 @@ discard """
   output: '''true'''
 """
 
-import hashes, tables
+import hashes, tables, sequtils
 
 const
   data = {
@@ -47,7 +47,7 @@ block tableTest1:
     for y in 0..1:
       assert t[(x,y)] == $x & $y
   assert($t == 
-    "{(x: 0, y: 0): 00, (x: 0, y: 1): 01, (x: 1, y: 0): 10, (x: 1, y: 1): 11}")
+    "{(x: 0, y: 1): 01, (x: 0, y: 0): 00, (x: 1, y: 0): 10, (x: 1, y: 1): 11}")
 
 block tableTest2:
   var t = newTable[string, float]()
@@ -84,7 +84,7 @@ block orderedTableTest1:
 block countTableTest1:
   var s = data.toTable
   var t = newCountTable[string]()
-  for k in s.Keys: t.inc(k)
+  for k in s.keys: t.inc(k)
   for k in t.keys: assert t[k] == 1
   t.inc("90", 3)
   t.inc("12", 2)
@@ -103,9 +103,10 @@ block countTableTest1:
 
 block SyntaxTest:
   var x = newTable[int, string]({:})
+  discard x
 
 block nilTest:
-  var i, j: PTable[int, int] = nil
+  var i, j: TableRef[int, int] = nil
   assert i == j
   j = newTable[int, int]()
   assert i != j
@@ -131,6 +132,10 @@ proc orderedTableSortTest() =
   # check that insert still works:
   t["newKeyHere"] = 80
 
+block anonZipTest:
+  let keys = @['a','b','c']
+  let values = @[1, 2, 3]
+  doAssert "{a: 1, b: 2, c: 3}" == $ toTable zip(keys, values)
 
 orderedTableSortTest()
 echo "true"
diff --git a/tests/table/ptables2.nim b/tests/collections/ttablesref2.nim
index 939de2b84..939de2b84 100644
--- a/tests/table/ptables2.nim
+++ b/tests/collections/ttablesref2.nim
diff --git a/tests/concepts/mvarconcept.nim b/tests/concepts/mvarconcept.nim
new file mode 100644
index 000000000..0f9d0beff
--- /dev/null
+++ b/tests/concepts/mvarconcept.nim
@@ -0,0 +1,13 @@
+type RNG* = concept var rng
+  rng.randomUint32() is uint32
+
+type MersenneTwister* = object
+
+proc randomUint32*(self: var MersenneTwister): uint32 = 5
+
+proc randomInt*(rng: var RNG; max: Positive): Natural = 5
+
+var mersenneTwisterInst = MersenneTwister()
+
+proc randomInt*(max: Positive): Natural =
+  mersenneTwisterInst.randomInt(max)
diff --git a/tests/metatype/udtcmanual.nim b/tests/concepts/tmanual.nim
index dd44298dc..7cf08af06 100644
--- a/tests/metatype/udtcmanual.nim
+++ b/tests/concepts/tmanual.nim
@@ -21,10 +21,10 @@ template reject(e: expr) =
   static: assert(not compiles(e))
 
 type
-  Container[T] = generic C
-    C.len is Ordinal
+  Container[T] = concept c
+    c.len is Ordinal
     items(c) is iterator
-    for value in C:
+    for value in c:
       type(value) is T
 
 proc takesIntContainer(c: Container[int]) =
diff --git a/tests/metatype/swizzle.nim b/tests/concepts/tswizzle.nim
index ce18fa234..07205d454 100644
--- a/tests/metatype/swizzle.nim
+++ b/tests/concepts/tswizzle.nim
@@ -3,6 +3,7 @@ discard """
 [1, 3]
 [2, 1, 2]
 '''
+  disabled: "true"
 """
 
 import macros, strutils
@@ -18,14 +19,14 @@ proc swizzleIdx(c: char): int =
     of 'x': 0
     of 'y': 1
     of 'z': 2
-    of 'w': 3    
+    of 'w': 3
     of 'r': 0
     of 'g': 1
     of 'b': 2
-    of 'a': 3    
+    of 'a': 3
     else: 0
 
-proc isSwizzle(s: string): bool =
+proc isSwizzle(s: string): bool {.compileTime.} =
   template trySet(name, set) =
     block search:
       for c in s:
@@ -35,11 +36,11 @@ proc isSwizzle(s: string): bool =
 
   trySet coords, {'x', 'y', 'z', 'w'}
   trySet colors, {'r', 'g', 'b', 'a'}
-  
+
   return false
 
-type 
-  StringIsSwizzle = generic value
+type
+  StringIsSwizzle = concept value
     value.isSwizzle
 
   SwizzleStr = static[string] and StringIsSwizzle
@@ -47,33 +48,33 @@ type
 proc foo(x: SwizzleStr) =
   echo "sw"
 
-accept foo("xx")
+#foo("xx")
 reject foo("xe")
 
-type 
+type
   Vec[N: static[int]; T] = array[N, T]
 
+when false:
+  proc card(x: Vec): int = x.N
+  proc `$`(x: Vec): string = x.repr.strip
 
-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()
 
-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)
 
-  for c in swizzle:
-    values.add newNimNode(nnkBracketExpr).add(
-      v, c.swizzleIdx.newIntLitNode)
-  
-  return quote do:
-    let `v` = `x`
-    Vec[`cardinality`, `v`.T](`values`)
+    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
+#echo z.card
+#echo z.xz
+#echo z.yxy
 
diff --git a/tests/metatype/tusertypeclasses.nim b/tests/concepts/tusertypeclasses.nim
index 6e9e4934b..612556949 100644
--- a/tests/metatype/tusertypeclasses.nim
+++ b/tests/concepts/tusertypeclasses.nim
@@ -1,5 +1,13 @@
 discard """
-  output: "Sortable\nSortable\nContainer"
+  output: '''Sortable
+Sortable
+Container
+true
+true
+false
+false
+false
+'''
 """
 
 import typetraits
@@ -8,10 +16,10 @@ type
   TObj = object
     x: int
 
-  Sortable = generic x, y
+  Sortable = concept x, y
     (x < y) is bool
 
-  ObjectContainer = generic C
+  ObjectContainer = concept C
     C.len is Ordinal
     for v in items(C):
       v.type is tuple|object
@@ -30,7 +38,7 @@ proc intval(x: int): int = 10
 
 # check real and virtual fields
 type
-  TFoo = generic T
+  TFoo = concept T
     T.x
     y(T)
     intval T.y
@@ -41,3 +49,20 @@ proc y(x: TObj): int = 10
 proc testFoo(x: TFoo) = discard
 testFoo(TObj(x: 10))
 
+type
+  Matrix[Rows, Cols: static[int]; T] = concept M
+    M.M == Rows
+    M.N == Cols
+    M.T is T
+
+  MyMatrix[M, N: static[int]; T] = object
+    data: array[M*N, T]
+
+var x: MyMatrix[3, 3, int]
+
+echo x is Matrix
+echo x is Matrix[3, 3, int]
+echo x is Matrix[3, 3, float]
+echo x is Matrix[4, 3, int]
+echo x is Matrix[3, 4, int]
+
diff --git a/tests/metatype/tusertypeclasses2.nim b/tests/concepts/tusertypeclasses2.nim
index 77c70d7a6..ae05540cd 100644
--- a/tests/metatype/tusertypeclasses2.nim
+++ b/tests/concepts/tusertypeclasses2.nim
@@ -1,5 +1,5 @@
 type
-  hasFieldX = generic z
+  hasFieldX = concept z
     z.x is int
 
   obj_x = object
@@ -7,7 +7,7 @@ type
 
   ref_obj_x = ref object
     x: int
-  
+
   ref_to_obj_x = ref obj_x
 
   p_o_x = ptr obj_x
diff --git a/tests/concepts/tvarconcept.nim b/tests/concepts/tvarconcept.nim
new file mode 100644
index 000000000..203ef3cdc
--- /dev/null
+++ b/tests/concepts/tvarconcept.nim
@@ -0,0 +1,9 @@
+discard """
+  output: "5"
+"""
+
+# bug #2346, bug #2404
+
+import mvarconcept
+
+echo randomInt(5)
diff --git a/tests/converter/ttypeconverter1.nim b/tests/converter/ttypeconverter1.nim
index fd3a0318a..510b84700 100644
--- a/tests/converter/ttypeconverter1.nim
+++ b/tests/converter/ttypeconverter1.nim
@@ -1,5 +1,5 @@
 discard """
-  ouput: '''foo
+  output: '''foo
 true'''
 """
 
diff --git a/tests/cpp/tcppraise.nim b/tests/cpp/tcppraise.nim
new file mode 100644
index 000000000..a9ea8e6ce
--- /dev/null
+++ b/tests/cpp/tcppraise.nim
@@ -0,0 +1,17 @@
+discard """
+  cmd: "nim cpp $file"
+  output: '''foo
+bar
+Need odd and >= 3 digits##
+baz'''
+"""
+
+# bug #1888
+echo "foo"
+try:
+  echo "bar"
+  raise newException(ValueError, "Need odd and >= 3 digits")
+#  echo "baz"
+except ValueError:
+  echo getCurrentExceptionMsg(), "##"
+echo "baz"
diff --git a/tests/cpp/tget_subsystem.nim b/tests/cpp/tget_subsystem.nim
new file mode 100644
index 000000000..461914739
--- /dev/null
+++ b/tests/cpp/tget_subsystem.nim
@@ -0,0 +1,23 @@
+discard """
+  cmd: "nim cpp $file"
+"""
+
+{.emit: """
+
+namespace System {
+  struct Input {};
+}
+
+struct SystemManager {
+  template <class T>
+  static T* getSubsystem() { return new T; }
+};
+
+""".}
+
+type Input {.importcpp: "System::Input".} = object
+proc getSubsystem*[T](): ptr T {.
+  importcpp: "SystemManager::getSubsystem<'*0>()", nodecl.}
+
+let input: ptr Input = getSubsystem[Input]()
+
diff --git a/tests/cpp/trawsockets.nim b/tests/cpp/trawsockets.nim
new file mode 100644
index 000000000..bc129de57
--- /dev/null
+++ b/tests/cpp/trawsockets.nim
@@ -0,0 +1,5 @@
+discard """
+  cmd: "nim cpp $file"
+"""
+
+import rawsockets
diff --git a/tests/cpp/tstaticvar_via_typedesc.nim b/tests/cpp/tstaticvar_via_typedesc.nim
new file mode 100644
index 000000000..7a9fa2afc
--- /dev/null
+++ b/tests/cpp/tstaticvar_via_typedesc.nim
@@ -0,0 +1,20 @@
+discard """
+  cmd: "nim cpp $file"
+  output: "42"
+"""
+
+# bug #2324
+
+static: assert defined(cpp), "compile in cpp mode"
+
+{.emit: """
+class Foo {
+public:
+    static int x;
+};
+int Foo::x = 42;
+""".}
+
+type Foo {.importcpp:"Foo".} = object
+proc x* (this: typedesc[Foo]): int {.importcpp:"Foo::x@", nodecl.}
+echo Foo.x
diff --git a/tests/cpp/tthread_createthread.nim b/tests/cpp/tthread_createthread.nim
new file mode 100644
index 000000000..0dc081268
--- /dev/null
+++ b/tests/cpp/tthread_createthread.nim
@@ -0,0 +1,14 @@
+discard """
+  cmd: "nim cpp --hints:on --threads:on $options $file"
+"""
+
+proc threadMain(a: int) {.thread.} =
+    discard
+
+proc main() =
+    var thread: TThread[int]
+
+    thread.createThread(threadMain, 0)
+    thread.joinThreads()
+
+main()
\ No newline at end of file
diff --git a/tests/cpp/ttypeinfo.nim b/tests/cpp/ttypeinfo.nim
new file mode 100644
index 000000000..1529c86e9
--- /dev/null
+++ b/tests/cpp/ttypeinfo.nim
@@ -0,0 +1,5 @@
+discard """
+  cmd: "nim cpp $file"
+"""
+
+import typeinfo
diff --git a/tests/cpp/tvector_iterator.nim b/tests/cpp/tvector_iterator.nim
new file mode 100644
index 000000000..cb5ab33af
--- /dev/null
+++ b/tests/cpp/tvector_iterator.nim
@@ -0,0 +1,19 @@
+discard """
+  cmd: "nim cpp $file"
+"""
+
+{.emit: """
+
+template <class T>
+struct Vector {
+  struct Iterator {};
+};
+
+""".}
+
+type
+  Vector {.importcpp: "Vector".} [T] = object
+  VectorIterator {.importcpp: "Vector<'0>::Iterator".} [T] = object
+
+var x: VectorIterator[void]
+
diff --git a/tests/cpp/tvectorseq.nim b/tests/cpp/tvectorseq.nim
new file mode 100644
index 000000000..6eb5dc9e4
--- /dev/null
+++ b/tests/cpp/tvectorseq.nim
@@ -0,0 +1,38 @@
+discard """
+  output: '''(x: 1.0)
+(x: 0.0)'''
+  cmd: "nim cpp $file"
+  disabled: "true"
+"""
+
+# This cannot work yet because we omit type information for importcpp'ed types.
+# Fixing this is not hard, but also requires fixing Urhonimo.
+
+# bug #2536
+
+{.emit: """/*TYPESECTION*/
+struct Vector3 {
+public:
+  Vector3(): x(5) {}
+  Vector3(float x_): x(x_) {}
+  float x;
+};
+""".}
+
+type Vector3 {.importcpp: "Vector3", nodecl} = object
+  x: cfloat
+
+proc constructVector3(a: cfloat): Vector3 {.importcpp: "Vector3(@)", nodecl}
+
+# hack around another codegen issue: Generics are attached to where they came
+# from:
+proc `$!`(v:  seq[Vector3]): string = "(x: " & $v[0].x & ")"
+
+proc vec3List*(): seq[Vector3] =
+  let s = @[constructVector3(cfloat(1))]
+  echo($!s)
+  result = s
+  echo($!result)
+
+let f = vec3List()
+#echo($!f)
diff --git a/tests/deprecated/tdeprecated.nim b/tests/deprecated/tdeprecated.nim
index f41f0a72f..955a7f6ad 100644
--- a/tests/deprecated/tdeprecated.nim
+++ b/tests/deprecated/tdeprecated.nim
@@ -1,11 +1,9 @@
 discard """
-  line: 9
-  errormsg: "'a' is deprecated [Deprecated]"
+  nimout: "a is deprecated [Deprecated]"
 """
 
 var
   a {.deprecated.}: array[0..11, int]
-  
-a[8] = 1
 
+a[8] = 1
 
diff --git a/tests/destructor/tdestructor.nim b/tests/destructor/tdestructor.nim
index cbaba3154..639dba941 100644
--- a/tests/destructor/tdestructor.nim
+++ b/tests/destructor/tdestructor.nim
@@ -40,7 +40,7 @@ type
     x: A
     y: B
     z: C
-  
+
   TObjKind = enum A, B, C, D
 
   TCaseObj = object
@@ -57,14 +57,14 @@ type
         q: TMyGeneric3[TMyObj, int, int]
       r: string
 
-proc destroy(o: var TMyObj) {.override.} =
+proc `=destroy`(o: var TMyObj) =
   if o.p != nil: dealloc o.p
   echo "myobj destroyed"
 
-proc destroy(o: var TMyGeneric1) {.override.} =
+proc `=destroy`(o: var TMyGeneric1) =
   echo "mygeneric1 destroyed"
 
-proc destroy[A, B](o: var TMyGeneric2[A, B]) {.override.} =
+proc `=destroy`[A, B](o: var TMyGeneric2[A, B]) =
   echo "mygeneric2 destroyed"
 
 proc open: TMyObj =
@@ -83,12 +83,12 @@ proc mygeneric1() =
 
 proc mygeneric2[T](val: T) =
   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))
@@ -111,11 +111,11 @@ 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",
diff --git a/tests/destructor/tdestructor2.nim b/tests/destructor/tdestructor2.nim
index 1bdf4993b..34fa466af 100644
--- a/tests/destructor/tdestructor2.nim
+++ b/tests/destructor/tdestructor2.nim
@@ -1,23 +1,27 @@
 discard """
-  line: 20
-  errormsg: " usage of a type with a destructor in a non destructible context"
+  line: 23
+  nimout: " usage of a type with a destructor in a non destructible context"
 """
 
 {.experimental.}
 
-type  
+type
   TMyObj = object
     x, y: int
     p: pointer
-    
-proc destroy(o: var TMyObj) {.override.} =
+
+proc `=destroy`(o: var TMyObj) =
   if o.p != nil: dealloc o.p
-  
+
 proc open: TMyObj =
   result = TMyObj(x: 1, y: 2, p: alloc(3))
 
 
 proc `$`(x: TMyObj): string = $x.y
 
-echo open()
+proc foo =
+  discard open()
+
+# XXX doesn't trigger this yet:
+#echo open()
 
diff --git a/tests/dir with space/tspace.nim b/tests/dir with space/tspace.nim
new file mode 100644
index 000000000..8db4b52f2
--- /dev/null
+++ b/tests/dir with space/tspace.nim
@@ -0,0 +1,3 @@
+# Test for the compiler to be able to compile a Nim file with spaces in it.
+
+echo("Successful")
\ No newline at end of file
diff --git a/tests/dll/client.nimrod.cfg b/tests/dll/client.nim.cfg
index 0e044a829..0e044a829 100644
--- a/tests/dll/client.nimrod.cfg
+++ b/tests/dll/client.nim.cfg
diff --git a/tests/dll/server.nimrod.cfg b/tests/dll/server.nim.cfg
index 02393ba8b..02393ba8b 100644
--- a/tests/dll/server.nimrod.cfg
+++ b/tests/dll/server.nim.cfg
diff --git a/tests/effects/teffects1.nim b/tests/effects/teffects1.nim
index e32096b57..ea1ea7b21 100644
--- a/tests/effects/teffects1.nim
+++ b/tests/effects/teffects1.nim
@@ -1,5 +1,4 @@
 discard """
-  line: 2170
   file: "system.nim"
   errormsg: "can raise an unlisted exception: ref IOError"
 """
diff --git a/tests/effects/tgcsafe.nim b/tests/effects/tgcsafe.nim
index 0d5109439..d146794b6 100644
--- a/tests/effects/tgcsafe.nim
+++ b/tests/effects/tgcsafe.nim
@@ -1,5 +1,5 @@
 discard """
-  line: 16
+  line: 17
   errormsg: "'mainUnsafe' is not GC-safe"
   cmd: "nim $target --hints:on --threads:on $options $file"
 """
diff --git a/tests/enum/tenumitems.nim b/tests/enum/tenumitems.nim
index b92cff6bf..04737fa9e 100644
--- a/tests/enum/tenumitems.nim
+++ b/tests/enum/tenumitems.nim
@@ -1,6 +1,6 @@
 discard """
   line: 7
-  errormsg: "expression 'items' cannot be called"
+  errormsg: "undeclared identifier: 'items'"
 """
 
 type a = enum b,c,d
diff --git a/tests/exception/tdefer1.nim b/tests/exception/tdefer1.nim
new file mode 100644
index 000000000..61439530a
--- /dev/null
+++ b/tests/exception/tdefer1.nim
@@ -0,0 +1,18 @@
+discard """
+  output: '''hi
+hi'''
+"""
+
+# bug #1742
+
+template test(): expr =
+    let a = 0
+    defer: echo "hi"
+    a
+
+let i = test()
+
+import strutils
+let x = try: parseInt("133a")
+        except: -1
+        finally: echo "hi"
diff --git a/tests/exception/texceptionbreak.nim b/tests/exception/texceptionbreak.nim
index 76e986787..00dd8ed9f 100644
--- a/tests/exception/texceptionbreak.nim
+++ b/tests/exception/texceptionbreak.nim
@@ -5,20 +5,20 @@ discard """
 
 # First variety
 try:
-  raise newException(EOS, "Problem")
-except EOS:
+  raise newException(OSError, "Problem")
+except OSError:
   for y in [1, 2, 3]:
     discard
   try:
     discard
-  except EOS:
+  except OSError:
     discard
 echo "1"
 
 # Second Variety
 try:
-  raise newException(EOS, "Problem")
-except EOS:
+  raise newException(OSError, "Problem")
+except OSError:
   for y in [1, 2, 3]:
     discard
   for y in [1, 2, 3]:
@@ -28,8 +28,8 @@ echo "2"
 
 # Third Variety
 try:
-  raise newException(EOS, "Problem")
-except EOS:
+  raise newException(OSError, "Problem")
+except OSError:
   block:
     break
 
@@ -38,8 +38,8 @@ echo "3"
 # Fourth Variety
 block:
   try:
-    raise newException(EOS, "Problem")
-  except EOS:
+    raise newException(OSError, "Problem")
+  except OSError:
     break
 
-echo "4"
\ No newline at end of file
+echo "4"
diff --git a/tests/exception/texceptions.nim b/tests/exception/texceptions.nim
index 69b2d0f6a..bdf338599 100644
--- a/tests/exception/texceptions.nim
+++ b/tests/exception/texceptions.nim
@@ -35,9 +35,9 @@ echo ""
 proc reraise_in_except =
   try:
     echo "BEFORE"
-    raise newException(EIO, "")
+    raise newException(IOError, "")
 
-  except EIO:
+  except IOError:
     echo "EXCEPT"
     raise
 
@@ -52,7 +52,7 @@ echo ""
 proc return_in_except =
   try:
     echo "BEFORE"
-    raise newException(EIO, "")
+    raise newException(IOError, "")
 
   except:
     echo "EXCEPT"
diff --git a/tests/exception/texcsub.nim b/tests/exception/texcsub.nim
index 3dba357f9..02125d2c0 100644
--- a/tests/exception/texcsub.nim
+++ b/tests/exception/texcsub.nim
@@ -5,12 +5,12 @@ discard """
 # Test inheritance for exception matching:
 
 try:
-  raise newException(EOS, "dummy message")
-except E_Base:
+  raise newException(OSError, "dummy message")
+except Exception:
   echo "caught!"
-except: 
+except:
   echo "wtf!?"
-  
+
 #OUT caught!
 
 
diff --git a/tests/exception/tfinally4.nim b/tests/exception/tfinally4.nim
index 05c57c4f5..3aa707ff6 100644
--- a/tests/exception/tfinally4.nim
+++ b/tests/exception/tfinally4.nim
@@ -8,19 +8,19 @@ discard """
 var raiseEx = true
 var returnA = true
 var returnB = false
- 
-proc main: int = 
+
+proc main: int =
   try: #A
     try: #B
       if raiseEx:
-        raise newException(EOS, "")
+        raise newException(OSError, "")
       return 3
     finally: #B
       echo "B1"
       if returnB:
         return 2
       echo "B2"
-  except EOS: #A
+  except OSError: #A
     echo "catch"
   finally: #A
     echo "A1"
diff --git a/tests/exception/tnestedreturn.nim b/tests/exception/tnestedreturn.nim
index 591638f0e..1480764f1 100644
--- a/tests/exception/tnestedreturn.nim
+++ b/tests/exception/tnestedreturn.nim
@@ -7,7 +7,7 @@ discard """
 
 proc test1() =
 
-  finally: echo "A"
+  defer: echo "A"
 
   try:
     raise newException(OSError, "Problem")
@@ -19,7 +19,7 @@ test1()
 
 proc test2() =
 
-  finally: echo "B"
+  defer: echo "B"
 
   try:
     return
diff --git a/tests/exception/tonraise.nim b/tests/exception/tonraise.nim
index 1a555dd94..a155f0b8e 100644
--- a/tests/exception/tonraise.nim
+++ b/tests/exception/tonraise.nim
@@ -4,8 +4,8 @@ success'''
 """
 
 type
-  ESomething = object of E_Base
-  ESomeOtherErr = object of E_Base
+  ESomething = object of Exception
+  ESomeOtherErr = object of Exception
 
 proc genErrors(s: string) =
   if s == "error!":
@@ -17,14 +17,14 @@ proc foo() =
   var i = 0
   try:
     inc i
-    onRaise(proc (e: ref E_Base): bool =
+    onRaise(proc (e: ref Exception): bool =
       echo "i: ", i)
     genErrors("errssor!")
   except ESomething:
     echo("ESomething happened")
   except:
     echo("Some other error happened")
-    
+
   # test that raise handler is gone:
   try:
     genErrors("error!")
diff --git a/tests/exception/treraise.nim b/tests/exception/treraise.nim
index cbd0b5f8a..b2a11d34f 100644
--- a/tests/exception/treraise.nim
+++ b/tests/exception/treraise.nim
@@ -4,8 +4,8 @@ discard """
   exitcode: "1"
 """
 type
-  ESomething = object of E_Base
-  ESomeOtherErr = object of E_Base
+  ESomething = object of Exception
+  ESomeOtherErr = object of Exception
 
 proc genErrors(s: string) =
   if s == "error!":
diff --git a/tests/exprs/texprstmt.nim b/tests/exprs/texprstmt.nim
index 355da2407..79323d82a 100644
--- a/tests/exprs/texprstmt.nim
+++ b/tests/exprs/texprstmt.nim
@@ -7,6 +7,6 @@ discard """
 
 proc test: string =
   result = "blah"
-  result[1 .. -1]
+  result[1 .. ^1]
 
 echo test()
diff --git a/tests/exprs/thighCString.nim b/tests/exprs/thighCString.nim
new file mode 100644
index 000000000..543966df4
--- /dev/null
+++ b/tests/exprs/thighCString.nim
@@ -0,0 +1,6 @@
+discard """
+  output: "5"
+"""
+let test = cstring("foobar")
+
+echo high(test)
diff --git a/tests/exprs/tresultwarning.nim b/tests/exprs/tresultwarning.nim
new file mode 100644
index 000000000..32934408e
--- /dev/null
+++ b/tests/exprs/tresultwarning.nim
@@ -0,0 +1,6 @@
+discard """
+  nimout: "Special variable 'result' is shadowed. [ResultShadowed]"
+"""
+
+proc test(): string =
+  var result = "foo"
diff --git a/tests/fields/tfields_in_template.nim b/tests/fields/tfields_in_template.nim
new file mode 100644
index 000000000..9352a7a51
--- /dev/null
+++ b/tests/fields/tfields_in_template.nim
@@ -0,0 +1,15 @@
+discard """
+  output: '''n
+n'''
+"""
+
+# bug #1902
+# This works.
+for name, value in (n: "v").fieldPairs:
+  echo name
+
+# This doesn't compile - "expression 'name' has no type (or is ambiguous)".
+template wrapper: stmt =
+  for name, value in (n: "v").fieldPairs:
+    echo name
+wrapper()
diff --git a/tests/fields/tfields_with_break.nim b/tests/fields/tfields_with_break.nim
new file mode 100644
index 000000000..1f2632692
--- /dev/null
+++ b/tests/fields/tfields_with_break.nim
@@ -0,0 +1,33 @@
+discard """
+  output: '''(one: 1, two: 2, three: 3)
+1
+2
+3
+(one: 4, two: 5, three: 6)
+4
+(one: 7, two: 8, three: 9)
+7
+8
+9'''
+"""
+
+# bug #2134
+type
+    TestType = object
+        one: int
+        two: int
+        three: int
+
+var
+    ab = TestType(one:1, two:2, three:3)
+    ac = TestType(one:4, two:5, three:6)
+    ad = TestType(one:7, two:8, three:9)
+    tstSeq = [ab, ac, ad]
+
+for tstElement in mitems(tstSeq):
+    echo tstElement
+    for tstField in fields(tstElement):
+        #for tstField in [1,2,4,6]:
+        echo tstField
+        if tstField == 4:
+            break
diff --git a/tests/gc/closureleak.nim b/tests/gc/closureleak.nim
index 38ee1250a..1c39f43d5 100644
--- a/tests/gc/closureleak.nim
+++ b/tests/gc/closureleak.nim
@@ -7,7 +7,7 @@ from strutils import join
 type
   TFoo * = object
     id: int
-    func: proc(){.closure.}
+    fn: proc(){.closure.}
 var foo_counter = 0
 var alive_foos = newseq[int](0)
 
@@ -26,7 +26,7 @@ for i in 0 .. <10:
 
 for i in 0 .. <10:
   let f = newFoo()
-  f.func = proc = 
+  f.fn = proc = 
     echo f.id
 
 GC_fullcollect()
diff --git a/tests/gc/cyclecollector.nim b/tests/gc/cyclecollector.nim
new file mode 100644
index 000000000..46fed6c45
--- /dev/null
+++ b/tests/gc/cyclecollector.nim
@@ -0,0 +1,21 @@
+
+# Program to detect bug #1796 reliably
+
+type
+  Node = ref object
+    a, b: Node
+    leaf: string
+
+proc createCycle(leaf: string): Node =
+  new result
+  result.a = result
+  shallowCopy result.leaf, leaf
+
+proc main =
+  for i in 0 .. 100_000:
+    var leaf = "this is the leaf. it allocates"
+    let x = createCycle(leaf)
+    let y = createCycle(leaf)
+  echo "done ", getOccupiedMem()
+
+main()
diff --git a/tests/gc/gcleak4.nim b/tests/gc/gcleak4.nim
index 6f2b8a1fe..54e74ac7b 100644
--- a/tests/gc/gcleak4.nim
+++ b/tests/gc/gcleak4.nim
@@ -38,12 +38,14 @@ proc newPlus(a, b: ref TExpr): ref TPlusExpr =
   result.b = b
   result.op2 = $getOccupiedMem()
 
+const Limit = when compileOption("gc", "markAndSweep"): 5*1024*1024 else: 500_000
+
 for i in 0..100_000:
   var s: array[0..11, ref TExpr]
   for j in 0..high(s):
     s[j] = newPlus(newPlus(newLit(j), newLit(2)), newLit(4))
     if eval(s[j]) != j+6:
       quit "error: wrong result"
-  if getOccupiedMem() > 500_000: quit("still a leak!")
+  if getOccupiedMem() > Limit: quit("still a leak!")
 
 echo "no leak: ", getOccupiedMem()
diff --git a/tests/gc/gctest.nim b/tests/gc/gctest.nim
index 27134d7dd..2213a83ac 100644
--- a/tests/gc/gctest.nim
+++ b/tests/gc/gctest.nim
@@ -196,7 +196,8 @@ write(stdout, "starting main...\n")
 main()
 
 GC_fullCollect()
+# the M&S GC fails with this call and it's unclear why. Definitely something
+# we need to fix!
 GC_fullCollect()
 writeln(stdout, GC_getStatistics())
 write(stdout, "finished\n")
-
diff --git a/tests/gc/growobjcrash.nim b/tests/gc/growobjcrash.nim
new file mode 100644
index 000000000..a16468c7e
--- /dev/null
+++ b/tests/gc/growobjcrash.nim
@@ -0,0 +1,29 @@
+discard """
+  output: "works"
+"""
+
+import cgi, strtabs
+
+proc handleRequest(query: string): StringTableRef =
+  iterator foo(): StringTableRef {.closure.} =
+    var params = {:}.newStringTable()
+    for key, val in cgi.decodeData(query):
+      params[key] = val
+    yield params
+
+  let x = foo
+  result = x()
+
+const Limit = when compileOption("gc", "markAndSweep"): 5*1024*1024 else: 700_000
+
+proc main =
+  var counter = 0
+  for i in 0 .. 100_000:
+    for k, v in handleRequest("nick=Elina2&type=activate"):
+      inc counter
+      if counter mod 100 == 0:
+        if getOccupiedMem() > Limit:
+          quit "but now a leak"
+
+main()
+echo "works"
diff --git a/tests/generics/t1050.nim b/tests/generics/t1050.nim
new file mode 100644
index 000000000..a6f9a2482
--- /dev/null
+++ b/tests/generics/t1050.nim
@@ -0,0 +1,16 @@
+discard """
+  msg: "int"
+  output: "4"
+"""
+
+import typetraits
+
+type ArrayType[T] = distinct T
+
+proc arrayItem(a: ArrayType): auto =
+  static: echo(name(type(a).T))
+  result = (type(a).T)(4)
+
+var arr: ArrayType[int]
+echo arrayItem(arr)
+
diff --git a/tests/generics/t1056.nim b/tests/generics/t1056.nim
new file mode 100644
index 000000000..b1fe25894
--- /dev/null
+++ b/tests/generics/t1056.nim
@@ -0,0 +1,25 @@
+discard """
+  output: '''TMatrix[3, 3, system.int]
+3'''
+"""
+
+import typetraits
+
+type
+  TMatrix*[N,M: static[int], T] = object
+    data*: array[0..N*M-1, T]
+
+  TMat2[T] = TMatrix[2,2,T]
+
+proc echoMatrix(a: TMatrix) =
+  echo a.type.name
+  echo TMatrix.N
+
+proc echoMat2(a: TMat2) =
+  echo TMat2.M
+  
+var m = TMatrix[3,3,int](data: [1,2,3,4,5,6,7,8,9])
+
+echoMatrix m
+#echoMat2 m
+
diff --git a/tests/generics/t1789.nim b/tests/generics/t1789.nim
new file mode 100644
index 000000000..188db88f6
--- /dev/null
+++ b/tests/generics/t1789.nim
@@ -0,0 +1,44 @@
+discard """
+  output: "3\n0"
+"""
+
+# https://github.com/Araq/Nim/issues/1789
+
+type
+  Foo[N: static[int]] = object
+
+proc bindStaticN[N](foo: Foo[N]) =
+  var ar0: array[3, int]
+  var ar1: array[N, int]
+  var ar2: array[1..N, int]
+  var ar3: array[0..(N+10), float]
+  echo N
+
+var f: Foo[3]
+f.bindStaticN
+
+# case 2
+
+type
+  ObjectWithStatic[X, Y: static[int], T] = object
+    bar: array[X * Y, T]   # this one works
+
+  AliasWithStatic[X, Y: static[int], T] = array[X * Y, T]
+
+var
+  x: ObjectWithStatic[1, 2, int]
+  y: AliasWithStatic[2, 3, int]
+
+# case 3
+
+type
+  Bar[N: static[int], T] = object
+    bar: array[N, T]
+
+proc `[]`*[N, T](f: Bar[N, T], n: range[0..(N - 1)]): T =
+  assert high(n) == N-1
+  result = f.bar[n]
+  
+var b: Bar[3, int]
+echo b[2]
+
diff --git a/tests/generics/tableref_is_nil.nim b/tests/generics/tableref_is_nil.nim
new file mode 100644
index 000000000..1ad4b3b0c
--- /dev/null
+++ b/tests/generics/tableref_is_nil.nim
@@ -0,0 +1,9 @@
+discard """
+  output: "true"
+"""
+
+# bug #2221
+import tables
+
+var tblo: TableRef[string, int]
+echo tblo == nil
diff --git a/tests/generics/tarray_with_somenumber.nim b/tests/generics/tarray_with_somenumber.nim
new file mode 100644
index 000000000..0bf2537a1
--- /dev/null
+++ b/tests/generics/tarray_with_somenumber.nim
@@ -0,0 +1,11 @@
+discard """
+  output: '''@[0.9, 0.1]'''
+"""
+
+# bug #2304
+
+type TV2*[T:SomeNumber] = array[0..1, T]
+proc newV2T*[T](x, y: T=0): TV2[T] = [x, y]
+
+let x = newV2T[float](0.9, 0.1)
+echo(@x)
diff --git a/tests/generics/tconfusing_arrow.nim b/tests/generics/tconfusing_arrow.nim
new file mode 100644
index 000000000..6a5a9d682
--- /dev/null
+++ b/tests/generics/tconfusing_arrow.nim
@@ -0,0 +1,15 @@
+import algorithm, future
+
+type Deck = object
+  value: int
+
+proc sort(h: var seq[Deck]) =
+  # works:
+  h.sort(proc (x, y: Deck): auto = 
+    cmp(x.value, y.value))
+  # fails:
+  h.sort((x, y: Deck) => cmp(ord(x.value), ord(y.value)))
+
+var player: seq[Deck] = @[]
+
+player.sort()
diff --git a/tests/generics/tgeneric3.nim b/tests/generics/tgeneric3.nim
index 6fb929efb..289bf1fd5 100644
--- a/tests/generics/tgeneric3.nim
+++ b/tests/generics/tgeneric3.nim
@@ -188,7 +188,7 @@ proc traceTree[T,D](root: PNode[T,D]) =
     write stdout, space
 
   proc doTrace(n: PNode[T,D], level: int) =
-    var space = repeatChar(2 * level)
+    var space = spaces(2 * level)
     traceln(space)
     write stdout, "node: "
     if n == nil:
diff --git a/tests/generics/tgeneric_closure.nim b/tests/generics/tgeneric_closure.nim
new file mode 100644
index 000000000..7198dce96
--- /dev/null
+++ b/tests/generics/tgeneric_closure.nim
@@ -0,0 +1,37 @@
+# Test to ensure TEventHandler is '.closure'
+
+# bug #1187
+
+type
+  TEventArgs* = object
+    skip*: bool
+  TEventHandler[T] = proc (e: var TEventArgs, data: T) {.closure.}
+  TEvent*[T] = object
+    #handlers: seq[TEventHandler[T]] # Does not work
+    handlers: seq[proc (e: var TEventArgs, data: T) {.closure.}] # works
+
+  TData = object
+    x: int
+
+  TSomething = object
+    s: TEvent[TData]
+
+proc init*[T](e: var TEvent[T]) =
+  e.handlers.newSeq(0)
+
+#proc add*[T](e: var TEvent[T], h: proc (e: var TEventArgs, data: T) {.closure.}) =
+# this line works
+proc add*[T](e: var TEvent[T], h: TEventHandler[T]) =
+  # this line does not work
+  e.handlers.add(h)
+
+proc main () =
+  var something: TSomething
+  something.s.init()
+  var fromOutside = 4711
+
+  something.s.add() do (e: var TEventArgs, data: TData):
+    var x = data.x
+    x = fromOutside
+
+main()
diff --git a/tests/generics/tgeneric_inheritance.nim b/tests/generics/tgeneric_inheritance.nim
new file mode 100644
index 000000000..432228797
--- /dev/null
+++ b/tests/generics/tgeneric_inheritance.nim
@@ -0,0 +1,19 @@
+discard """
+  output: "0.0"
+"""
+
+# bug #1919
+
+type
+  Base[M] = object of RootObj
+    a : M
+
+  Sub1[M] = object of Base[M]
+    b : int
+
+  Sub2[M] = object of Sub1[M]
+    c : int
+
+var x: Sub2[float]
+
+echo x.a
diff --git a/tests/generics/tmetafield.nim b/tests/generics/tmetafield.nim
index bbfca7e3c..7a2375abe 100644
--- a/tests/generics/tmetafield.nim
+++ b/tests/generics/tmetafield.nim
@@ -2,7 +2,7 @@ discard """
   cmd: "nim check $options $file"
   errormsg: "'proc' is not a concrete type"
   errormsg: "'Foo' is not a concrete type."
-  errormsg: "invalid type: 'TBaseMed'"
+  errormsg: "invalid type: 'proc' in this context: 'TBaseMed'"
 """
 
 type
diff --git a/tests/generics/tunique_type.nim b/tests/generics/tunique_type.nim
new file mode 100644
index 000000000..da2f9e4b2
--- /dev/null
+++ b/tests/generics/tunique_type.nim
@@ -0,0 +1,67 @@
+# Bug #2022
+
+discard """
+  output: '''@[97, 45]
+@[true, false]
+@[false, false]'''
+"""
+
+## The goal of this snippet is to provide and test a construct for general-
+## purpose, random-access mapping. I use an AST-manipulation-based approach
+## because it's more efficient than using procedure pointers and less
+## verbose than defining a new callable type for every invocation of `map`.
+
+import future
+import macros
+import strutils
+
+#===============================================================================
+# Define a system for storing copies of ASTs as static strings.
+# This serves the same purpose as D's `alias` parameters for types, used heavily
+# in its popular `ranges` and `algorithm` modules.
+
+var exprNodes {.compileTime.} = newSeq[NimNode]()
+
+proc refExpr(exprNode: NimNode): string {.compileTime.} =
+  exprNodes.add exprNode.copy
+  "expr" & $(exprNodes.len - 1)
+
+proc derefExpr(exprRef: string): NimNode {.compileTime.} =
+  exprNodes[parseInt(exprRef[4 .. ^1])]
+
+#===============================================================================
+# Define a type that allows a callable expression to be mapped onto elements
+# of an indexable collection.
+
+type Mapped[Input; predicate: static[string]] = object
+  input: Input
+
+macro map(input, predicate: expr): expr =
+  let predicate = callsite()[2]
+  newNimNode(nnkObjConstr).add(
+    newNimNode(nnkBracketExpr).add(
+      ident"Mapped",
+      newNimNode(nnkTypeOfExpr).add(input),
+      newLit(refExpr(predicate))),
+    newNimNode(nnkExprColonExpr).add(
+      ident"input", input))
+
+proc `[]`(m: Mapped, i: int): auto =
+  macro buildResult: expr =
+    newCall(
+      derefExpr(m.predicate),
+      newNimNode(nnkBracketExpr).add(
+        newDotExpr(ident"m", ident"input"),
+        ident"i"))
+  buildResult()
+
+#===============================================================================
+# Test out our generic mapping construct.
+
+let a = "a-string".map(ord)
+let b = @["a", "seq"].map((e: string) => e == "a")
+let c = "another-string".map((e: char) => e == 'o')
+
+echo(@[a[0], a[1]]) # @[97, 45]
+echo(@[b[0], b[1]]) # @[true, false]
+echo(@[c[0], c[1]]) # @[false, false]
diff --git a/tests/generics/twrong_field_caching.nim b/tests/generics/twrong_field_caching.nim
new file mode 100644
index 000000000..595c58eb7
--- /dev/null
+++ b/tests/generics/twrong_field_caching.nim
@@ -0,0 +1,68 @@
+discard """
+  output: '''a23: 2x3
+a32: 3x2
+transpose A
+t32: 3x2
+transpose B
+x23: 2x3 (2x3)
+x32: 3x2 (3x2)'''
+"""
+
+# bug #2125
+# Suppose we have the following type for a rectangular array:
+
+type
+  RectArray*[R, C: static[int], T] = distinct array[R * C, T]
+ 
+var a23: RectArray[2, 3, int]
+var a32: RectArray[3, 2, int]
+ 
+echo "a23: ", a23.R, "x", a23.C
+echo "a32: ", a32.R, "x", a32.C
+
+# Output:
+# a23: 2x3
+# a32: 3x2
+
+# Looking good. Let's add a proc:
+proc transpose*[R, C, T](m: RectArray[R, C, T]): RectArray[C, R, T] =
+  echo "transpose A"
+
+var t32 = a23.transpose
+
+echo "t32: ", t32.R, "x", t32.C
+
+# Output:
+# t32: 3x2
+ 
+ 
+# Everything is still OK. Now let's use the rectangular array inside another
+# generic type:
+type
+  Matrix*[R, C: static[int], T] = object
+    theArray*: RectArray[R, C, T]
+
+#var m23: Matrix[2, 3, int]
+#var m32: Matrix[3, 2, int]
+
+#echo "m23: ", m23.R, "x", m23.C, " (", m23.theArray.R, "x", m23.theArray.C, ")"
+#echo "m32: ", m32.R, "x", m32.C, " (", m32.theArray.R, "x", m32.theArray.C, ")"
+
+# Output:
+# m23: 2x3 (2x3)
+# m32: 3x2 (3x2)
+
+
+# Everything is still as expected. Now let's add the following proc:
+proc transpose*[R, C, T](m: Matrix[R, C, T]): Matrix[C, R, T] =
+  echo "transpose B"
+
+var x23: Matrix[2, 3, int]
+var x32 = x23.transpose
+
+echo "x23: ", x23.R, "x", x23.C, " (", x23.theArray.R, "x", x23.theArray.C, ")"
+echo "x32: ", x32.R, "x", x32.C, " (", x32.theArray.R, "x", x32.theArray.C, ")"
+ 
+# Output:
+# x23: 2x3 (2x3)
+# x32: 3x2 (3x2)  <--- this is incorrect. R and C do not match!
diff --git a/tests/generics/twrong_floatlit_type.nim b/tests/generics/twrong_floatlit_type.nim
new file mode 100644
index 000000000..2db8b4353
--- /dev/null
+++ b/tests/generics/twrong_floatlit_type.nim
@@ -0,0 +1,118 @@
+discard """
+  errormsg: "type mismatch"
+  line: 116
+"""
+
+# bug #2169
+import strutils, math
+
+type
+  Point2D*[S] = object
+    x*, y*: S
+  Matrix2x3*[S] = distinct array[6, S] ## Row major order
+
+  Vector2D*[S] = object
+    x*, y*: S
+
+proc `[]`*[T](m: Matrix2x3[T], i: int): T = array[6, T](m)[i]
+
+template M11*[T](m: Matrix2x3[T]): T = m[0]
+template M12*[T](m: Matrix2x3[T]): T = m[1]
+template M13*[T](m: Matrix2x3[T]): T = m[2]
+template M21*[T](m: Matrix2x3[T]): T = m[3]
+template M22*[T](m: Matrix2x3[T]): T = m[4]
+template M23*[T](m: Matrix2x3[T]): T = m[5]
+
+proc identity*[T](): Matrix2x3[T] =
+    Matrix2x3[T]([T(1.0), 0.0, 0.0,   0.0, 1.0, 0.0])
+
+proc translation*[T](p: Point2D[T]): Matrix2x3[T] =
+    Matrix2x3[T]([T(1.0), T(0.0), p.x, T(0.0), T(1.0), p.y])
+
+proc translation*[T](p: Vector2D[T]): Matrix2x3[T] =
+    Matrix2x3[T]([T(1.0), T(0.0), p.x, T(0.0), T(1.0), p.y])
+
+proc scale*[T](v: Vector2D[T]): Matrix2x3[T] =
+    Matrix2x3[T]([v.x, T(0.0), T(0.0), T(0.0), v.y, T(0.0)])
+
+proc rotation*[T](th: T): Matrix2x3[T] = 
+    let 
+        c = T(cos(th.float))
+        s = T(sin(th.float))
+ 
+    Matrix2x3[T]([c, -s, T(0.0),   s, c, T(0.0)])
+ 
+proc `*`*[T](a, b: Matrix2x3[T]): Matrix2x3[T] = 
+    # Here we pretend that row 3 is [0,0,0,1] without
+    # actually storing it in the matrix.
+    Matrix2x3[T]([a.M11*b.M11 + a.M12*b.M21, 
+                  a.M11*b.M12 + a.M12*b.M22, 
+                  a.M11*b.M13 + a.M12*b.M23 + a.M13, 
+ 
+                  a.M21*b.M11 + a.M22*b.M21,
+                  a.M21*b.M12 + a.M22*b.M22,
+                  a.M21*b.M13 + a.M22*b.M23 + a.M23])
+ 
+proc `*`*[T](a: Matrix2x3[T], p: Point2D[T]): Point2D[T] = 
+    let 
+        x = a.M11*p.x + a.M12*p.y + a.M13
+        y = a.M21*p.x + a.M22*p.y + a.M23
+ 
+    Point2D[T](x: x, y: y)
+ 
+# making these so things like "line" that need a constructor don't stick out.
+# 2x2 determinant:  |a b|
+#                   |c d|  = ad - bc
+ 
+# String rendering
+#
+template ff[S](x: S): string = 
+    formatFloat(float(x), ffDefault, 0)
+ 
+proc `$`*[S](p: Point2D[S]): string = 
+    "P($1, $2)" % [ff(p.x), ff(p.y)]
+ 
+proc `$`*[S](p: Vector2D[S]): string = 
+    "V($1, $2)" % [ff(p.x), ff(p.y)]
+ 
+proc `$`*[S](m: Matrix2x3[S]): string =
+    "M($1 $2 $3/$4 $5 $6)" % [ff(m.M11), ff(m.M12), ff(m.M13), 
+                              ff(m.M21), ff(m.M22), ff(m.M23)]
+
+#
+# Vector operators.
+proc `-`*[S](a: Vector2D[S]): Vector2D[S] =
+  Vector2D[S](x: -a.x, y: -a.y)
+
+proc `+`*[S](a, b: Vector2D[S]): Vector2D[S] =
+  Vector2D[S](x: a.x + b.x, y: a.y + b.y)
+
+proc `-`*[S](a, b: Vector2D[S]): Vector2D[S] =
+  Vector2D[S](x: a.x - b.x, y: a.y - b.y)
+
+proc `*`*[S](v: Vector2D[S], sc: S): Vector2D[S] =
+  Vector2D[S](x: v.x*sc, y: v.y*sc)
+
+proc `*`*[S](sc: S, v: Vector2D[S]): Vector2D[S] =
+  Vector2D[S](x: v.x*sc, y: v.y*sc)
+
+proc `/`*[S](v: Vector2D[S], sc: S): Vector2D[S] =
+  Vector2D[S](x: v.x/sc, y: v.y/sc)
+
+proc `/`*[S](sc: S; v: Vector2D[S]): Vector2D[S] =
+  Vector2D[S](x: sc/v.x, y: sc/v.y)
+
+proc `/`*[S](a, b: Vector2D[S]): Vector2D[S] = 
+  Vector2D[S](x: a.x/b.x, y: a.y/b.y)
+#proc vec[S](x, y: S): Vector2D[S]
+proc vec[S](x, y: S): Vector2D[S] =
+  Vector2D[S](x: x, y: y)
+
+if isMainModule:
+  # Comment out this let, and the program will fail to
+  # compile with a type mismatch, as expected.
+
+  let s3 = scale(vec(4.0, 4.0))
+  let barf = translation(Point2D[float32](x: 1, y: 1)) * rotation(float(0.7))
+
+  echo "Badness ", barf
diff --git a/tests/generics/twrong_generic_object.nim b/tests/generics/twrong_generic_object.nim
new file mode 100644
index 000000000..00d90c55e
--- /dev/null
+++ b/tests/generics/twrong_generic_object.nim
@@ -0,0 +1,21 @@
+discard """
+  errormsg: "cannot instantiate: 'GenericNodeObj'"
+  line: 21
+"""
+# bug #2509
+type
+  GenericNodeObj[T] = ref object
+    obj: T
+
+  Node* = ref object
+    children*: seq[Node]
+    parent*: Node
+
+    nodeObj*: GenericNodeObj # [int]
+
+proc newNode*(nodeObj: GenericNodeObj): Node =
+  result = Node(nodeObj: nodeObj)
+  newSeq(result.children, 10)
+
+var genericObj = GenericNodeObj[int]()
+var myNode = newNode(genericObj)
diff --git a/tests/global/tglobal.nim b/tests/global/tglobal.nim
index 84c4510c1..d44a62afc 100644
--- a/tests/global/tglobal.nim
+++ b/tests/global/tglobal.nim
@@ -1,6 +1,6 @@
 discard """
-  file: "toop1.nim"
   output: "in globalaux2: 10\ntotal globals: 2\nint value: 100\nstring value: second"
+  disabled: "true"
 """
 
 import globalaux, globalaux2
diff --git a/tests/implicit/timplictderef.nim b/tests/implicit/timplictderef.nim
index 99b0b645b..fcb647217 100644
--- a/tests/implicit/timplictderef.nim
+++ b/tests/implicit/timplictderef.nim
@@ -1,9 +1,10 @@
 discard """
-  output: "2"
+  output: '''2
+88'''
 """
 
 type
-  TValue* {.pure, final.} = object of TObject
+  TValue* {.pure, final.} = object of RootObj
     a: int
   PValue = ref TValue
   PPValue = ptr PValue
@@ -16,3 +17,19 @@ var sp: PPValue = addr x
 sp.a = 2
 if sp.a == 2: echo 2  # with sp[].a the error is gone
 
+# Test the new auto-deref a little
+
+{.experimental.}
+
+proc p(x: var int; y: int) = x += y
+
+block:
+  var x: ref int
+  new(x)
+
+  x.p(44)
+
+  var indirect = p
+  x.indirect(44)
+
+  echo x[]
diff --git a/tests/init/tuninit2.nim b/tests/init/tuninit2.nim
new file mode 100644
index 000000000..950895c02
--- /dev/null
+++ b/tests/init/tuninit2.nim
@@ -0,0 +1,54 @@
+# bug #2316
+
+type
+    EventType = enum
+      QuitEvent = 5
+    AppMain* = ref object of RootObj
+        width: int
+        height: int
+        title: string
+        running: bool
+        event_type: EventType
+    App* = ref object of AppMain
+        draw_proc: proc(app: AppMain): void {.closure.}
+        events_proc: proc(app: AppMain): void {.closure.}
+        update_proc: proc(app: AppMain, dt: float): void {.closure.}
+        load_proc: proc(app: AppMain): void {.closure.}
+
+
+proc initApp*(t: string, w, h: int): App =
+    App(width: w, height: h, title: t, event_type: EventType.QuitEvent)
+
+
+method getTitle*(self: AppMain): string = self.title
+method getWidth*(self: AppMain): int = self.width
+method getHeight*(self: AppMain): int = self.height
+
+
+method draw*(self: App, draw: proc(app: AppMain)): void =
+    self.draw_proc = draw
+
+method load*(self: App, load: proc(a: AppMain)): void =
+    self.load_proc = load
+
+method events*(self: App, events: proc(app: AppMain)): void =
+    self.events_proc = events
+
+method update*(self: App, update: proc(app: AppMain, delta: float)): void =
+    self.update_proc = update
+
+method run*(self: App): void = discard
+
+var mygame = initApp("Example", 800, 600)
+
+mygame.load(proc(app: AppMain): void =
+    echo app.getTitle()
+    echo app.getWidth()
+    echo app.getHeight()
+)
+
+mygame.events(proc(app: AppMain): void =
+    discard
+)
+
+mygame.run()
diff --git a/tests/iter/tchainediterators.nim b/tests/iter/tchainediterators.nim
index 8d9f44a54..796672783 100644
--- a/tests/iter/tchainediterators.nim
+++ b/tests/iter/tchainediterators.nim
@@ -6,13 +6,16 @@ discard """
 128
 192
 '''
+  disabled: "true"
 """
 
+# This all relies on non-documented and questionable features.
+
 iterator gaz(it: iterator{.inline.}): type(it) =
   for x in it:
     yield x*2
 
-iterator baz(it: iterator{.inline.}) =
+iterator baz(it: iterator{.inline.}): auto =
   for x in gaz(it):
     yield x*2
 
diff --git a/tests/iter/tconcat.nim b/tests/iter/tconcat.nim
new file mode 100644
index 000000000..477ac5e26
--- /dev/null
+++ b/tests/iter/tconcat.nim
@@ -0,0 +1,24 @@
+discard """
+  output: '''1
+2
+3
+4
+20
+21
+22
+23'''
+"""
+
+proc toIter*[T](s: Slice[T]): iterator: T =
+  iterator it: T {.closure.} =
+    for x in s.a..s.b:
+      yield x
+  return it
+
+iterator concat*[T](its: varargs[T, toIter]): auto =
+  for i in its:
+    for x in i():
+      yield x
+
+for i in concat(1..4, 20..23):
+  echo i
diff --git a/tests/iter/timplicit_auto.nim b/tests/iter/timplicit_auto.nim
new file mode 100644
index 000000000..ccb279fe0
--- /dev/null
+++ b/tests/iter/timplicit_auto.nim
@@ -0,0 +1,18 @@
+# bug #1838
+
+type State = enum Empty, Tree, Fire
+
+const
+  disp: array[State, string] = ["  ", "\e[32m/\\\e[m", "\e[07;31m/\\\e[m"]
+
+proc univ(x, y: int): State = Tree
+
+var w, h = 30
+
+iterator fields(a = (0,0), b = (h-1,w-1)) =
+  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)
+
+for y,x in fields():
+  stdout.write disp[univ(x, y)]
diff --git a/tests/iter/tobj_iter.nim b/tests/iter/tobj_iter.nim
new file mode 100644
index 000000000..eb0e37b23
--- /dev/null
+++ b/tests/iter/tobj_iter.nim
@@ -0,0 +1,20 @@
+discard """
+  output: "7"
+"""
+
+# bug #2023
+
+{.deadCodeElim:on.}
+
+type
+    Obj = object
+        iter: iterator (): int8 {.closure.}
+
+iterator test(): int8 {.closure.} =
+    yield 7
+
+proc init():Obj=
+    result.iter = test
+
+var o = init()
+echo(o.iter())
diff --git a/tests/iter/tscheduler.nim b/tests/iter/tscheduler.nim
new file mode 100644
index 000000000..a267f15c4
--- /dev/null
+++ b/tests/iter/tscheduler.nim
@@ -0,0 +1,76 @@
+discard """
+  output: '''a1 5
+a2 10
+a1 3
+a1 1
+a2 8
+a2 6
+a2 4
+a2 2'''
+"""
+
+import os, strutils, times, algorithm
+
+
+type TaskFn = iterator (): float
+
+type Task = object
+    coro: TaskFn
+    next_run: float
+
+
+type Scheduler = object
+    tasks: seq[Task]
+
+
+proc newScheduler(): Scheduler =
+    var s = Scheduler()
+    s.tasks = @[]
+    return s
+
+
+proc start(this: var Scheduler, task: TaskFn) =
+    var t = Task()
+    t.coro = task
+    t.next_run = 0.0
+    this.tasks.add(t)
+
+
+proc run(this: var Scheduler) =
+    while this.tasks.len > 0:
+        var dead: seq[int] = @[]
+        for i in this.tasks.low..this.tasks.high:
+            var task = this.tasks[i]
+            if finished(task.coro):
+                dead.add(i)
+                continue
+            if task.next_run <= epochTime():
+                task.next_run = task.coro() + epochTime()
+            this.tasks[i] = task
+        for i in dead:
+            this.tasks.delete(i)
+        if this.tasks.len > 0:
+            sort(this.tasks, proc (t1: Task, t2: Task): int = cmp(t1.next_run, t2.next_run))
+            sleep(int((this.tasks[0].next_run - epochTime()) * 1000))
+
+
+iterator a1(): float {.closure.} =
+    var k = 5
+    while k > 0:
+        echo "a1 $1" % [$k]
+        dec k, 2
+        yield 0.5
+
+
+iterator a2(): float {.closure.} =
+    var k = 10
+    while k > 0:
+        echo "a2 $1" % [$k]
+        dec k, 2
+        yield 1.5
+
+
+var sched = newScheduler()
+sched.start(a1)
+sched.start(a2)
+sched.run()
diff --git a/tests/iter/tshallowcopy_closures.nim b/tests/iter/tshallowcopy_closures.nim
new file mode 100644
index 000000000..2f024ee7e
--- /dev/null
+++ b/tests/iter/tshallowcopy_closures.nim
@@ -0,0 +1,31 @@
+discard """
+  ccodecheck: "!@('{' \\s* 'NI HEX3Astate;' \\s* '}')"
+"""
+
+# bug #1803
+type TaskFn = iterator (): float
+
+iterator a1(): float {.closure.} =
+    var k = 10
+    while k > 0:
+        echo "a1 ", k
+        dec k
+        yield 1.0
+
+
+iterator a2(): float {.closure.} =
+    var k = 15
+    while k > 0:
+        echo "a2 ", k
+        dec k
+        yield 2.0
+
+var
+  x = a1
+  y = a2
+  z: TaskFn
+
+discard x()
+z = x #shallowCopy(z, x)
+z = y #shallowCopy(z, y)
+discard x()
diff --git a/tests/js/taddr.nim b/tests/js/taddr.nim
new file mode 100644
index 000000000..6a60aa902
--- /dev/null
+++ b/tests/js/taddr.nim
@@ -0,0 +1,36 @@
+type T = object
+  x: int
+  s: string
+
+var obj: T
+var fieldAddr = addr(obj.x)
+var objAddr = addr(obj)
+
+# Integer tests
+var field = fieldAddr[]
+doAssert field == 0
+
+var objDeref = objAddr[]
+doAssert objDeref.x == 0
+
+# Change value
+obj.x = 42
+
+doAssert field == 0
+doAssert objDeref.x == 0
+
+field = fieldAddr[]
+objDeref = objAddr[]
+
+doAssert field == 42
+doAssert objDeref.x == 42
+
+# String tests
+obj.s = "lorem ipsum dolor sit amet"
+var indexAddr = addr(obj.s[2])
+
+doAssert indexAddr[] == '4'
+
+indexAddr[] = 'd'
+
+doAssert indexAddr[] == 'd'
diff --git a/tests/js/test2.nim b/tests/js/test2.nim
index 5a734358c..1a42fbfda 100644
--- a/tests/js/test2.nim
+++ b/tests/js/test2.nim
@@ -1,6 +1,7 @@
 discard """
   output: '''foo
-js 3.14'''
+js 3.14
+7'''
 """
 
 # This file tests the JavaScript generator
@@ -20,3 +21,11 @@ else:
   proc foo(val: float): string = "js " & $val
 
 echo foo(3.14)
+
+# #2495
+type C = concept x
+
+proc test(x: C, T: typedesc): T =
+  cast[T](x)
+
+echo 7.test(int8)
diff --git a/tests/js/tfloatround.nim b/tests/js/tfloatround.nim
new file mode 100644
index 000000000..7bc5430e6
--- /dev/null
+++ b/tests/js/tfloatround.nim
@@ -0,0 +1,7 @@
+discard """
+  output: '''
+3
+'''
+"""
+
+echo int(22 / 7)
diff --git a/tests/js/tstringitems.nim b/tests/js/tstringitems.nim
new file mode 100644
index 000000000..f4ea02fec
--- /dev/null
+++ b/tests/js/tstringitems.nim
@@ -0,0 +1,24 @@
+discard """
+  output: '''Hello
+Hello'''
+"""
+
+# bug #2581
+
+const someVars = [ "Hello" ]
+var someVars2 = [ "Hello" ]
+
+proc getSomeVar: string =
+    for i in someVars:
+        if i == "Hello":
+            result = i
+            break
+
+proc getSomeVar2: string =
+    for i in someVars2:
+        if i == "Hello":
+            result = i
+            break
+
+echo getSomeVar()
+echo getSomeVar2()
diff --git a/tests/js/tunittests.nim b/tests/js/tunittests.nim
index af38cd9b9..8a264a5e0 100644
--- a/tests/js/tunittests.nim
+++ b/tests/js/tunittests.nim
@@ -1,3 +1,10 @@
+discard """
+  disabled: "true"
+"""
+
+# Unittest uses lambdalifting at compile-time which we disable for the JS
+# codegen! So this cannot and will not work for quite some time.
+
 import unittest
 
 suite "Bacon":
diff --git a/tests/let/tlet2.nim b/tests/let/tlet2.nim
index 8b1ddf940..66dd5a55b 100644
--- a/tests/let/tlet2.nim
+++ b/tests/let/tlet2.nim
@@ -1,6 +1,6 @@
 discard """
   line: "13"
-  errormsg: "for a 'var' type a variable needs to be passed"
+  errormsg: "type mismatch: got (int literal(8), int literal(5), int, int)"
 """
 
 proc divmod(a, b: int, res, remainder: var int) =
diff --git a/tests/macros/macro_bug.nim b/tests/macros/macro_bug.nim
new file mode 100644
index 000000000..0d0fa76ac
--- /dev/null
+++ b/tests/macros/macro_bug.nim
@@ -0,0 +1,17 @@
+import macros
+
+macro macro_bug*(s: stmt): stmt {.immediate.} =
+  s.expectKind({nnkProcDef, nnkMethodDef})
+
+  var params = s.params
+
+  let genericParams = s[2]
+  result = newNimNode(nnkProcDef).add(
+    s.name, s[1], genericParams, params, pragma(s), newEmptyNode())
+
+  var body = body(s)
+
+  # Fails here.
+  var call = newCall("macro_bug", s.params[1][0])
+  body.insert(0, call)
+  result.add(body)
diff --git a/tests/macros/tbugs.nim b/tests/macros/tbugs.nim
index 3db851dd1..1ecb0d4cc 100644
--- a/tests/macros/tbugs.nim
+++ b/tests/macros/tbugs.nim
@@ -46,13 +46,13 @@ echotest()
 
 # bug #1103
 
-type 
+type
     Td = tuple
         a:string
         b:int
 
 proc get_data(d: Td) : string {.compileTime.} =
-    result = d.a # Works if a literal string is used here. 
+    result = d.a # Works if a literal string is used here.
     # Bugs if line A or B is active. Works with C
     result &= "aa"          # A
     #result.add("aa")       # B
@@ -69,7 +69,7 @@ m(s)
 
 # bug #933
 
-proc nilcheck(): PNimrodNode {.compileTime.} =
+proc nilcheck(): NimNode {.compileTime.} =
   echo(result == nil) # true
   echo(result.isNil) # true
   echo(repr(result)) # nil
diff --git a/tests/macros/tdumpast.nim b/tests/macros/tdumpast.nim
index 160e4e194..e3388591a 100644
--- a/tests/macros/tdumpast.nim
+++ b/tests/macros/tdumpast.nim
@@ -1,4 +1,4 @@
-# Dump the contents of a PNimrodNode
+# Dump the contents of a NimNode
 
 import macros
 
@@ -7,7 +7,7 @@ template plus(a, b: expr): expr {.dirty} =
 
 macro call(e: expr): expr =
   result = newCall("foo", newStrLitNode("bar"))
-  
+
 macro dumpAST(n: stmt): stmt {.immediate.} =
   # dump AST as a side-effect and return the inner node
   let n = callsite()
@@ -24,10 +24,10 @@ macro dumpAST(n: stmt): stmt {.immediate.} =
   echo e.lispRepr
 
   result = n[1]
-  
+
 dumpAST:
   proc add(x, y: int): int =
     return x + y
-  
+
   proc sub(x, y: int): int = return x - y
 
diff --git a/tests/macros/tdumpast2.nim b/tests/macros/tdumpast2.nim
index 2a7024a01..6b694fa77 100644
--- a/tests/macros/tdumpast2.nim
+++ b/tests/macros/tdumpast2.nim
@@ -1,13 +1,13 @@
-# Dump the contents of a PNimrodNode
+# Dump the contents of a NimNode
 
 import macros
 
-proc dumpit(n: PNimrodNode): string {.compileTime.} = 
+proc dumpit(n: NimNode): string {.compileTime.} =
   if n == nil: return "nil"
   result = $n.kind
   add(result, "(")
   case n.kind
-  of nnkEmpty: discard # same as nil node in this representation 
+  of nnkEmpty: discard # same as nil node in this representation
   of nnkNilLit:                  add(result, "nil")
   of nnkCharLit..nnkInt64Lit:    add(result, $n.intVal)
   of nnkFloatLit..nnkFloat64Lit: add(result, $n.floatVal)
@@ -20,17 +20,17 @@ proc dumpit(n: PNimrodNode): string {.compileTime.} =
       add(result, ", ")
       add(result, dumpit(n[j]))
   add(result, ")")
-  
-macro dumpAST(n: stmt): stmt {.immediate.} = 
+
+macro dumpAST(n: stmt): stmt {.immediate.} =
   # dump AST as a side-effect and return the inner node
   let n = callsite()
   echo dumpit(n)
   result = n[1]
-  
+
 dumpAST:
   proc add(x, y: int): int =
     return x + y
-  
+
   proc sub(x, y: int): int = return x - y
 
 
diff --git a/tests/macros/tgensym.nim b/tests/macros/tgensym.nim
index 3f4140ff4..b3aef0a2c 100644
--- a/tests/macros/tgensym.nim
+++ b/tests/macros/tgensym.nim
@@ -2,7 +2,7 @@ import rawsockets, asyncdispatch, macros
 var p = newDispatcher()
 var sock = newAsyncRawSocket()
 
-proc convertReturns(node, retFutureSym: PNimrodNode): PNimrodNode {.compileTime.} =
+proc convertReturns(node, retFutureSym: NimNode): NimNode {.compileTime.} =
   case node.kind
   of nnkReturnStmt:
     result = newCall(newIdentNode("complete"), retFutureSym, node[0])
@@ -19,19 +19,19 @@ macro async2(prc: stmt): stmt {.immediate.} =
   # -> var retFuture = newFuture[T]()
   var retFutureSym = newIdentNode("retFuture") #genSym(nskVar, "retFuture")
   outerProcBody.add(
-    newVarStmt(retFutureSym, 
+    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>
+  # -> iterator nameIter(): FutureBase {.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")],
+  var closureIterator = newProc(iteratorNameSym, [newIdentNode("FutureBase")],
                                 procBody, nnkIteratorDef)
   closureIterator[4] = newNimNode(nnkPragma).add(newIdentNode("closure"))
   outerProcBody.add(closureIterator)
@@ -55,8 +55,8 @@ macro async2(prc: stmt): stmt {.immediate.} =
 
   result[6] = outerProcBody
 
-proc readStuff(): PFuture[string] {.async2.} =
-  var fut = connect(sock, "irc.freenode.org", TPort(6667))
+proc readStuff(): Future[string] {.async2.} =
+  var fut = connect(sock, "irc.freenode.org", Port(6667))
   yield fut
   var fut2 = recv(sock, 50)
   yield fut2
diff --git a/tests/macros/tgentemplates.nim b/tests/macros/tgentemplates.nim
index a7727c597..764b94bc7 100644
--- a/tests/macros/tgentemplates.nim
+++ b/tests/macros/tgentemplates.nim
@@ -2,7 +2,7 @@
 
 import parseutils, macros
 
-proc parse_until_symbol(node: PNimrodNode, value: string, index: var int): bool {.compiletime.} =
+proc parse_until_symbol(node: NimNode, value: string, index: var int): bool {.compiletime.} =
     var splitValue: string
     var read = value.parseUntil(splitValue, '$', index)
 
@@ -15,7 +15,7 @@ proc parse_until_symbol(node: PNimrodNode, value: string, index: var int): bool
     if splitValue.len > 0:
         node.insert node.len, newCall("add", ident("result"), newStrLitNode(splitValue))
 
-proc parse_template(node: PNimrodNode, value: string) {.compiletime.} =
+proc parse_template(node: NimNode, value: string) {.compiletime.} =
     var index = 0
     while index < value.len and
         parse_until_symbol(node, value, index): discard
diff --git a/tests/macros/tlexerex.nim b/tests/macros/tlexerex.nim
new file mode 100644
index 000000000..d348a4bcc
--- /dev/null
+++ b/tests/macros/tlexerex.nim
@@ -0,0 +1,16 @@
+
+import macros
+
+macro match*(s: cstring|string; pos: int; sections: untyped): untyped =
+  for sec in sections.children:
+    expectKind sec, nnkOfBranch
+    expectLen sec, 2
+  result = newStmtList()
+
+when isMainModule:
+  var input = "the input"
+  var pos = 0
+  match input, pos:
+  of r"[a-zA-Z_]\w+": echo "an identifier"
+  of r"\d+": echo "an integer"
+  of r".": echo "something else"
diff --git a/tests/macros/tmacro1.nim b/tests/macros/tmacro1.nim
index 3a67c2611..2dd5c31df 100644
--- a/tests/macros/tmacro1.nim
+++ b/tests/macros/tmacro1.nim
@@ -3,17 +3,17 @@ import  macros
 from uri import `/`
 
 macro test*(a: stmt): stmt {.immediate.} =
-  var nodes: tuple[a, b: int]  
+  var nodes: tuple[a, b: int]
   nodes.a = 4
   nodes[1] = 45
-  
+
   type
     TTypeEx = object
       x, y: int
       case b: bool
       of false: nil
       of true: z: float
-      
+
   var t: TTypeEx
   t.b = true
   t.z = 4.5
diff --git a/tests/macros/tmacro3.nim b/tests/macros/tmacro3.nim
index 162212326..d7421ff7f 100644
--- a/tests/macros/tmacro3.nim
+++ b/tests/macros/tmacro3.nim
@@ -4,7 +4,7 @@ discard """
 
 import  macros
 
-type 
+type
     TA = tuple[a: int]
     PA = ref TA
 
@@ -19,7 +19,7 @@ test:
 macro test2*(a: stmt): stmt {.immediate.} =
   proc testproc(recurse: int) =
     echo "Thats weird"
-    var o : PNimrodNode = nil
+    var o : NimNode = nil
     echo "  no its not!"
     o = newNimNode(nnkNone)
     if recurse > 0:
diff --git a/tests/macros/tmacro4.nim b/tests/macros/tmacro4.nim
index 10a23b159..a56369369 100644
--- a/tests/macros/tmacro4.nim
+++ b/tests/macros/tmacro4.nim
@@ -7,7 +7,7 @@ import
 
 macro test_macro*(n: stmt): stmt {.immediate.} =
   result = newNimNode(nnkStmtList)
-  var ass : PNimrodNode = newNimNode(nnkAsgn)
+  var ass : NimNode = newNimNode(nnkAsgn)
   add(ass, newIdentNode("str"))
   add(ass, newStrLitNode("after"))
   add(result, ass)
diff --git a/tests/macros/tmacro5.nim b/tests/macros/tmacro5.nim
index 9882ad90d..d7a4fe8c8 100644
--- a/tests/macros/tmacro5.nim
+++ b/tests/macros/tmacro5.nim
@@ -1,7 +1,7 @@
 import macros,json
 
-var decls{.compileTime.}: seq[PNimrodNode] = @[]
-var impls{.compileTime.}: seq[PNimrodNode] = @[]
+var decls{.compileTime.}: seq[NimNode] = @[]
+var impls{.compileTime.}: seq[NimNode] = @[]
 
 macro importImpl_forward(name, returns): stmt {.immediate.} =
   result = newNimNode(nnkEmpty)
@@ -38,7 +38,7 @@ macro importImpl_forward(name, returns): stmt {.immediate.} =
   decls.add res
   echo(repr(res))
 
-macro importImpl(name, returns: expr, body: stmt): stmt {.immediate.} = 
+macro importImpl(name, returns: expr, body: stmt): stmt {.immediate.} =
   #var res = getAST(importImpl_forward(name, returns))
   discard getAST(importImpl_forward(name, returns))
   var res = copyNimTree(decls[decls.high])
@@ -56,4 +56,4 @@ importImpl(Item, int):
 importImpl(Foo, int16):
   echo 77
 
-okayy
\ No newline at end of file
+okayy
diff --git a/tests/macros/tmacro_in_template.nim b/tests/macros/tmacro_in_template.nim
new file mode 100644
index 000000000..8f7753cea
--- /dev/null
+++ b/tests/macros/tmacro_in_template.nim
@@ -0,0 +1,10 @@
+
+# bug #1944
+import macros
+
+template t(e: expr): stmt =
+  macro m(eNode: expr): stmt =
+    echo eNode.treeRepr
+  m e
+
+t 5
diff --git a/tests/macros/tmacros1.nim b/tests/macros/tmacros1.nim
index 3c814ad6d..1a1073a44 100644
--- a/tests/macros/tmacros1.nim
+++ b/tests/macros/tmacros1.nim
@@ -15,10 +15,10 @@ macro outterMacro*(n: stmt): stmt {.immediate.} =
   expectKind(n, TNimrodNodeKind.nnkCall)
   if n.len != 3 or n[1].kind != TNimrodNodeKind.nnkIdent:
     error("Macro " & callNode.repr &
-      " requires the ident passed as parameter (eg: " & callNode.repr & 
+      " requires the ident passed as parameter (eg: " & callNode.repr &
       "(the_name_you_want)): statements.")
   result = newNimNode(TNimrodNodeKind.nnkStmtList)
-  var ass : PNimrodNode = newNimNode(nnkAsgn)
+  var ass : NimNode = newNimNode(nnkAsgn)
   ass.add(newIdentNode(n[1].ident))
   ass.add(newStrLitNode(innerProc(4)))
   result.add(ass)
diff --git a/tests/macros/tmacrotypes.nim b/tests/macros/tmacrotypes.nim
index f19aa2ddb..991668930 100644
--- a/tests/macros/tmacrotypes.nim
+++ b/tests/macros/tmacrotypes.nim
@@ -1,16 +1,16 @@
 discard """
-  disabled: true
+  nimout: '''void
+int'''
 """
 
-import macros, typetraits
+import macros
 
-macro checkType(ex, expected: expr): stmt {.immediate.} =
-  var t = ex.typ
-  assert t.name == expected.strVal
+macro checkType(ex: stmt; expected: expr): stmt =
+  var t = ex.getType()
+  echo t
 
 proc voidProc = echo "hello"
-proc intProc(a, b): int = 10
+proc intProc(a: int, b: float): int = 10
 
 checkType(voidProc(), "void")
 checkType(intProc(10, 20.0), "int")
-checkType(noproc(10, 20.0), "Error Type")
diff --git a/tests/macros/tnimrodnode_for_runtime.nim b/tests/macros/tnimnode_for_runtime.nim
index e73c8430f..0520cd0dd 100644
--- a/tests/macros/tnimrodnode_for_runtime.nim
+++ b/tests/macros/tnimnode_for_runtime.nim
@@ -1,10 +1,9 @@
 discard """
   output: "bla"
-  disabled: true
 """
 
 import macros
-proc makeMacro: PNimrodNode =
+proc makeMacro: NimNode =
   result = nil
 
 var p = makeMacro()
diff --git a/tests/macros/treturnsempty.nim b/tests/macros/treturnsempty.nim
new file mode 100644
index 000000000..7af26a747
--- /dev/null
+++ b/tests/macros/treturnsempty.nim
@@ -0,0 +1,12 @@
+discard """
+  errormsg: "type mismatch"
+  line: 11
+"""
+# bug #2372
+macro foo(dummy: int): stmt =
+  discard
+
+proc takeStr(s: string) = echo s
+
+takeStr foo(12)
+
diff --git a/tests/macros/tsame_name_497.nim b/tests/macros/tsame_name_497.nim
new file mode 100644
index 000000000..ed5d5c6d8
--- /dev/null
+++ b/tests/macros/tsame_name_497.nim
@@ -0,0 +1,9 @@
+discard """
+  disabled: true
+"""
+
+import macro_bug
+
+type TObj = object
+
+proc f(o: TObj) {.macro_bug.} = discard
diff --git a/tests/macros/tstringinterp.nim b/tests/macros/tstringinterp.nim
index a500ed56e..bc79cdaba 100644
--- a/tests/macros/tstringinterp.nim
+++ b/tests/macros/tstringinterp.nim
@@ -19,7 +19,7 @@ template processInterpolations(e: expr) =
 
 macro formatStyleInterpolation(e: expr): expr =
   let e = callsite()
-  var 
+  var
     formatString = ""
     arrayNode = newNimNode(nnkBracket)
     idx = 1
@@ -27,14 +27,14 @@ macro formatStyleInterpolation(e: expr): expr =
   proc addString(s: string) =
     formatString.add(s)
 
-  proc addExpr(e: PNimrodNode) =
+  proc addExpr(e: NimNode) =
     arrayNode.add(e)
     formatString.add("$" & $(idx))
     inc idx
 
   proc addDollar() =
     formatString.add("$$")
-    
+
   processInterpolations(e)
 
   result = parseExpr("\"x\" % [y]")
@@ -43,11 +43,11 @@ macro formatStyleInterpolation(e: expr): expr =
 
 macro concatStyleInterpolation(e: expr): expr =
   let e = callsite()
-  var args: seq[PNimrodNode]
+  var args: seq[NimNode]
   newSeq(args, 0)
 
   proc addString(s: string)    = args.add(newStrLitNode(s))
-  proc addExpr(e: PNimrodNode) = args.add(e)
+  proc addExpr(e: NimNode) = args.add(e)
   proc addDollar()             = args.add(newStrLitNode"$")
 
   processInterpolations(e)
@@ -59,7 +59,7 @@ macro concatStyleInterpolation(e: expr): expr =
 proc sum(a, b, c: int): int =
   return (a + b + c)
 
-var 
+var
   alice = "Alice"
   bob = "Bob"
   a = 10
diff --git a/tests/macros/ttryparseexpr.nim b/tests/macros/ttryparseexpr.nim
index af932eb7d..c7bbc8e5b 100644
--- a/tests/macros/ttryparseexpr.nim
+++ b/tests/macros/ttryparseexpr.nim
@@ -15,5 +15,6 @@ const
   valid = 45
   a = test("foo&&")
   b = test("valid")
+  c = test("\"") # bug #2504
 
 echo a, " ", b
diff --git a/tests/macros/tvarnimnode.nim b/tests/macros/tvarnimnode.nim
index 73fcc16ea..ab0f66caa 100644
--- a/tests/macros/tvarnimnode.nim
+++ b/tests/macros/tvarnimnode.nim
@@ -6,7 +6,7 @@ discard """
 
 import macros
 
-proc test(f: var PNimrodNode) {.compileTime.} =
+proc test(f: var NimNode) {.compileTime.} =
   f = newNimNode(nnkStmtList)
   f.add newCall(newIdentNode("echo"), newLit(10))
 
diff --git a/tests/macros/typesapi.nim b/tests/macros/typesapi.nim
new file mode 100644
index 000000000..670b39c9e
--- /dev/null
+++ b/tests/macros/typesapi.nim
@@ -0,0 +1,17 @@
+discard """
+  nimout: '''proc (x: int): string => typeDesc[proc[string, int]]
+proc (x: int): void => typeDesc[proc[void, int]]
+proc (x: int) => typeDesc[proc[void, int]]'''
+"""
+
+#2211
+
+import macros
+
+macro showType(t:stmt): stmt =
+  let ty = t.getType
+  echo t.repr, " => ", ty.repr
+
+showType(proc(x:int): string)
+showType(proc(x:int): void)
+showType(proc(x:int))
diff --git a/tests/macros/typesapi2.nim b/tests/macros/typesapi2.nim
new file mode 100644
index 000000000..2e59d2154
--- /dev/null
+++ b/tests/macros/typesapi2.nim
@@ -0,0 +1,49 @@
+# tests to see if a symbol returned from macros.getType() can
+# be used as a type
+import macros
+
+macro testTypesym (t:stmt): expr =
+    var ty = t.getType
+    if ty.typekind == ntyTypedesc:
+        # skip typedesc get to the real type
+        ty = ty[1].getType
+
+    if ty.kind == nnkSym: return ty
+    assert ty.kind == nnkBracketExpr
+    assert ty[0].kind == nnkSym
+    result = ty[0]
+    return
+
+type TestFN = proc(a,b:int):int
+var iii: testTypesym(TestFN)
+static: assert iii is TestFN
+
+proc foo11 : testTypesym(void) =
+    echo "HI!"
+static: assert foo11 is (proc():void {.nimcall.})
+
+var sss: testTypesym(seq[int])
+static: assert sss is seq[int]
+# very nice :>
+
+static: assert array[2,int] is testTypesym(array[2,int])
+static: assert(ref int is testTypesym(ref int))
+static: assert(void is testTypesym(void))
+
+
+macro tts2 (t:stmt, idx:int): expr =
+    var ty = t.getType
+    if ty.typekind == ntyTypedesc:
+        # skip typedesc get to the real type
+        ty = ty[1].getType
+
+    if ty.kind == nnkSym: return ty
+    assert ty.kind == nnkBracketExpr
+    return ty[idx.intval.int]
+type TestFN2 = proc(a:int,b:float):string
+static:
+    assert(tts2(TestFN2, 0) is TestFN2)
+    assert(tts2(TestFN2, 1) is string)
+    assert(tts2(TestFN2, 2) is int)
+    assert(tts2(TestFN2, 3) is float)
+
diff --git a/tests/manyloc/argument_parser/argument_parser.nim b/tests/manyloc/argument_parser/argument_parser.nim
index fec00dbf8..060610ae0 100644
--- a/tests/manyloc/argument_parser/argument_parser.nim
+++ b/tests/manyloc/argument_parser/argument_parser.nim
@@ -1,7 +1,7 @@
 ## Command line parsing module for Nimrod.
 ##
-## `Nim <http://nim-code.org>`_ provides the `parseopt module
-## <http://nim-code.org/parseopt.html>`_ to parse options from the
+## `Nim <http://nim-lang.org>`_ provides the `parseopt module
+## <http://nim-lang.org/parseopt.html>`_ to parse options from the
 ## commandline. This module tries to provide functionality to prevent you from
 ## writing commandline parsing and let you concentrate on providing the best
 ## possible experience for your users.
@@ -302,7 +302,7 @@ template build_specification_lookup():
   ## Returns the table used to keep pointers to all of the specifications.
   var result {.gensym.}: OrderedTable[string, ptr Tparameter_specification]
   result = initOrderedTable[string, ptr Tparameter_specification](
-    nextPowerOfTwo(expected.len))
+    tables.rightSize(expected.len))
   for i in 0..expected.len-1:
     for param_to_detect in expected[i].names:
       if result.hasKey(param_to_detect):
@@ -471,7 +471,7 @@ proc build_help*(expected: seq[Tparameter_specification] = @[],
   let width = prefixes.map(proc (x: string): int = 3 + len(x)).max
 
   for line in zip(prefixes, helps):
-    result.add(line.a & repeatChar(width - line.a.len) & line.b)
+    result.add(line.a & spaces(width - line.a.len) & line.b)
 
 
 proc echo_help*(expected: seq[Tparameter_specification] = @[],
diff --git a/tests/manyloc/argument_parser/ex_wget.nim b/tests/manyloc/argument_parser/ex_wget.nim
index d36947b34..625a6f595 100644
--- a/tests/manyloc/argument_parser/ex_wget.nim
+++ b/tests/manyloc/argument_parser/ex_wget.nim
@@ -8,8 +8,8 @@ const
   PARAM_BACKGROUND = @["-b", "--background"]
   PARAM_OUTPUT = @["-o", "--output"]
   PARAM_NO_CLOBBER = @["-nc", "--no-clobber"]
-  PARAM_PROGRESS = "--progress"
-  PARAM_NO_PROXY = "--no-proxy"
+  PARAM_PROGRESS = @["--progress"]
+  PARAM_NO_PROXY = @["--no-proxy"]
 
 
 template P(tnames: varargs[string], thelp: string, ttype = PK_EMPTY,
@@ -77,8 +77,8 @@ proc process_commandline(): Tcommandline_results =
       quit()
     echo "Will download to $1" % [result.options[PARAM_OUTPUT[0]].str_val]
 
-  if result.options.hasKey(PARAM_PROGRESS):
-    echo "Will use progress type $1" % [result.options[PARAM_PROGRESS].str_val]
+  if result.options.hasKey(PARAM_PROGRESS[0]):
+    echo "Will use progress type $1" % [result.options[PARAM_PROGRESS[0]].str_val]
 
 
 when isMainModule:
diff --git a/tests/manyloc/keineschweine/README.md b/tests/manyloc/keineschweine/README.md
index 2a6b78a8e..1323f4ae3 100644
--- a/tests/manyloc/keineschweine/README.md
+++ b/tests/manyloc/keineschweine/README.md
@@ -4,7 +4,7 @@ Just a dumb little game
 
 ### Dependencies
 
-* Nimrod 0.8.15, Until this version is released I'm working off Nimrod HEAD: https://github.com/Araq/Nimrod
+* nim 0.8.15, Until this version is released I'm working off nim HEAD: https://github.com/Araq/nim
 * SFML 2.0 (git), https://github.com/LaurentGomila/SFML
 * CSFML 2.0 (git), https://github.com/LaurentGomila/CSFML
 * Chipmunk 6.1.1 http://chipmunk-physics.net/downloads.php
@@ -13,7 +13,7 @@ Just a dumb little game
 
 * `git clone --recursive git://github.com/fowlmouth/keineSchweine.git somedir`
 * `cd somedir`
-*  `nimrod c -r nakefile test` or `nimrod c -r keineschweine && ./keineschweine`
+*  `nim c -r nakefile test` or `nim c -r keineschweine && ./keineschweine`
 
 ### Download the game data
 
@@ -22,5 +22,5 @@ http://dl.dropbox.com/u/37533467/data-08-01-2012.7z
 
 Unpack it to the root directory. You can use the nakefile to do this easily: 
 
-* `nimrod c -r nakefile`
+* `nim c -r nakefile`
 * `./nakefile download`
diff --git a/tests/manyloc/keineschweine/dependencies/chipmunk/chipmunk.nim b/tests/manyloc/keineschweine/dependencies/chipmunk/chipmunk.nim
index d079a2e72..493a2106c 100644
--- a/tests/manyloc/keineschweine/dependencies/chipmunk/chipmunk.nim
+++ b/tests/manyloc/keineschweine/dependencies/chipmunk/chipmunk.nim
@@ -74,7 +74,7 @@ type
     contacts*: PContact
     stamp*: TTimestamp
     handler*: PCollisionHandler
-    swappedColl*: bool32
+    swappedColl*: Bool32
     state*: TArbiterState
   PCollisionHandler* = ptr TCollisionHandler
   TCollisionHandler*{.pf.} = object 
@@ -108,7 +108,7 @@ type
   #/ Collision begin event function callback type.
   #/ Returning false from a begin callback causes the collision to be ignored until
   #/ the the separate callback is called when the objects stop colliding.
-  TCollisionBeginFunc* = proc (arb: PArbiter; space: PSpace; data: pointer): Bool{.
+  TCollisionBeginFunc* = proc (arb: PArbiter; space: PSpace; data: pointer): bool{.
       cdecl.}
   #/ Collision pre-solve event function callback type.
   #/ Returning false from a pre-step callback causes the collision to be ignored until the next step.
@@ -142,14 +142,14 @@ type
   PSpatialIndex = ptr TSpatialIndex
   TSpatialIndex{.pf.} = object 
     klass: PSpatialIndexClass
-    bbfunc: TSpatialIndexBBFunc
+    bbfun: TSpatialIndexBBFunc
     staticIndex: PSpatialIndex
     dynamicIndex: PSpatialIndex
 
   TSpatialIndexDestroyImpl* = proc (index: PSpatialIndex){.cdecl.}
   TSpatialIndexCountImpl* = proc (index: PSpatialIndex): cint{.cdecl.}
   TSpatialIndexEachImpl* = proc (index: PSpatialIndex; 
-                                 func: TSpatialIndexIteratorFunc; data: pointer){.
+                                 fun: TSpatialIndexIteratorFunc; data: pointer){.
       cdecl.}
   TSpatialIndexContainsImpl* = proc (index: PSpatialIndex; obj: pointer; 
                                      hashid: THashValue): Bool32 {.cdecl.}
@@ -161,15 +161,15 @@ type
   TSpatialIndexReindexObjectImpl* = proc (index: PSpatialIndex; 
       obj: pointer; hashid: THashValue){.cdecl.}
   TSpatialIndexReindexQueryImpl* = proc (index: PSpatialIndex; 
-      func: TSpatialIndexQueryFunc; data: pointer){.cdecl.}
+      fun: TSpatialIndexQueryFunc; data: pointer){.cdecl.}
   TSpatialIndexPointQueryImpl* = proc (index: PSpatialIndex; point: TVector; 
-                                       func: TSpatialIndexQueryFunc; 
+                                       fun: TSpatialIndexQueryFunc; 
                                        data: pointer){.cdecl.}
   TSpatialIndexSegmentQueryImpl* = proc (index: PSpatialIndex; obj: pointer; 
-      a: TVector; b: TVector; t_exit: CpFloat; func: TSpatialIndexSegmentQueryFunc; 
+      a: TVector; b: TVector; t_exit: CpFloat; fun: TSpatialIndexSegmentQueryFunc; 
       data: pointer){.cdecl.}
   TSpatialIndexQueryImpl* = proc (index: PSpatialIndex; obj: pointer; 
-                                  bb: TBB; func: TSpatialIndexQueryFunc; 
+                                  bb: TBB; fun: TSpatialIndexQueryFunc; 
                                   data: pointer){.cdecl.}
   PSpatialIndexClass* = ptr TSpatialIndexClass
   TSpatialIndexClass*{.pf.} = object 
@@ -279,14 +279,14 @@ type
   PSegmentQueryInfo* = ptr TSegmentQueryInfo
   #/ Segment query info struct.
   TSegmentQueryInfo*{.pf.} = object 
-    shape*: PShape         #/ The shape that was hit, NULL if no collision occured.
+    shape*: PShape         #/ The shape that was hit, NULL if no collision occurred.
     t*: CpFloat            #/ The normalized distance along the query segment in the range [0, 1].
     n*: TVector            #/ The normal of the surface hit.
   TShapeType*{.size: sizeof(cint).} = enum 
     CP_CIRCLE_SHAPE, CP_SEGMENT_SHAPE, CP_POLY_SHAPE, CP_NUM_SHAPES
   TShapeCacheDataImpl* = proc (shape: PShape; p: TVector; rot: TVector): TBB{.cdecl.}
   TShapeDestroyImpl* = proc (shape: PShape){.cdecl.}
-  TShapePointQueryImpl* = proc (shape: PShape; p: TVector): bool32 {.cdecl.}
+  TShapePointQueryImpl* = proc (shape: PShape; p: TVector): Bool32 {.cdecl.}
   TShapeSegmentQueryImpl* = proc (shape: PShape; a: TVector; b: TVector; 
                                   info: PSegmentQueryInfo){.cdecl.}
   PShapeClass* = ptr TShapeClass
@@ -427,7 +427,7 @@ defGetter(PSpace, CpFloat, currDt, CurrentTimeStep)
 
 
 #/ returns true from inside a callback and objects cannot be added/removed.
-proc isLocked*(space: PSpace): Bool{.inline.} = 
+proc isLocked*(space: PSpace): bool{.inline.} = 
   result = space.locked.bool
 
 #/ Set a default collision handler for this space.
@@ -478,24 +478,24 @@ proc removeBody*(space: PSpace; body: PBody){.
 proc RemoveConstraint*(space: PSpace; constraint: PConstraint){.
   cdecl, importc: "cpSpaceRemoveConstraint", dynlib: Lib.}
 #/ Test if a collision shape has been added to the space.
-proc containsShape*(space: PSpace; shape: PShape): Bool{.
+proc containsShape*(space: PSpace; shape: PShape): bool{.
   cdecl, importc: "cpSpaceContainsShape", dynlib: Lib.}
 #/ Test if a rigid body has been added to the space.
-proc containsBody*(space: PSpace; body: PBody): Bool{.
+proc containsBody*(space: PSpace; body: PBody): bool{.
   cdecl, importc: "cpSpaceContainsBody", dynlib: Lib.}
 #/ Test if a constraint has been added to the space.
 
-proc containsConstraint*(space: PSpace; constraint: PConstraint): Bool{.
+proc containsConstraint*(space: PSpace; constraint: PConstraint): bool{.
   cdecl, importc: "cpSpaceContainsConstraint", dynlib: Lib.}
 #/ Schedule a post-step callback to be called when cpSpaceStep() finishes.
 #/ @c obj is used a key, you can only register one callback per unique value for @c obj
-proc addPostStepCallback*(space: PSpace; func: TPostStepFunc; 
+proc addPostStepCallback*(space: PSpace; fun: TPostStepFunc; 
                                obj: pointer; data: pointer){.
   cdecl, importc: "cpSpaceAddPostStepCallback", dynlib: Lib.}
                                         
 #/ Query the space at a point and call @c func for each shape found.
 proc pointQuery*(space: PSpace; point: TVector; layers: TLayers; 
-                      group: TGroup; func: TSpacePointQueryFunc; data: pointer){.
+                      group: TGroup; fun: TSpacePointQueryFunc; data: pointer){.
   cdecl, importc: "cpSpacePointQuery", dynlib: Lib.}
 
 #/ Query the space at a point and return the first shape found. Returns NULL if no shapes were found.
@@ -506,7 +506,7 @@ proc pointQueryFirst*(space: PSpace; point: TVector; layers: TLayers;
 #/ Perform a directed line segment query (like a raycast) against the space calling @c func for each shape intersected.
 proc segmentQuery*(space: PSpace; start: TVector; to: TVector; 
                     layers: TLayers; group: TGroup; 
-                    func: TSpaceSegmentQueryFunc; data: pointer){.
+                    fun: TSpaceSegmentQueryFunc; data: pointer){.
   cdecl, importc: "cpSpaceSegmentQuery", dynlib: Lib.}
 #/ Perform a directed line segment query (like a raycast) against the space and return the first shape hit. Returns NULL if no shapes were hit.
 proc segmentQueryFirst*(space: PSpace; start: TVector; to: TVector; 
@@ -517,26 +517,26 @@ proc segmentQueryFirst*(space: PSpace; start: TVector; to: TVector;
 #/ Perform a fast rectangle query on the space calling @c func for each shape found.
 #/ Only the shape's bounding boxes are checked for overlap, not their full shape.
 proc BBQuery*(space: PSpace; bb: TBB; layers: TLayers; group: TGroup; 
-                   func: TSpaceBBQueryFunc; data: pointer){.
+                   fun: TSpaceBBQueryFunc; data: pointer){.
   cdecl, importc: "cpSpaceBBQuery", dynlib: Lib.}
 
 #/ Query a space for any shapes overlapping the given shape and call @c func for each shape found.
-proc shapeQuery*(space: PSpace; shape: PShape; func: TSpaceShapeQueryFunc; data: pointer): Bool {.
+proc shapeQuery*(space: PSpace; shape: PShape; fun: TSpaceShapeQueryFunc; data: pointer): bool {.
   cdecl, importc: "cpSpaceShapeQuery", dynlib: Lib.}
 #/ Call cpBodyActivate() for any shape that is overlaps the given shape.
 proc activateShapesTouchingShape*(space: PSpace; shape: PShape){.
     cdecl, importc: "cpSpaceActivateShapesTouchingShape", dynlib: Lib.}
 
 #/ Call @c func for each body in the space.
-proc eachBody*(space: PSpace; func: TSpaceBodyIteratorFunc; data: pointer){.
+proc eachBody*(space: PSpace; fun: TSpaceBodyIteratorFunc; data: pointer){.
   cdecl, importc: "cpSpaceEachBody", dynlib: Lib.}
 
 #/ Call @c func for each shape in the space.
-proc eachShape*(space: PSpace; func: TSpaceShapeIteratorFunc; 
+proc eachShape*(space: PSpace; fun: TSpaceShapeIteratorFunc; 
                      data: pointer){.
   cdecl, importc: "cpSpaceEachShape", dynlib: Lib.}
 #/ Call @c func for each shape in the space.
-proc eachConstraint*(space: PSpace; func: TSpaceConstraintIteratorFunc; 
+proc eachConstraint*(space: PSpace; fun: TSpaceConstraintIteratorFunc; 
                           data: pointer){.
   cdecl, importc: "cpSpaceEachConstraint", dynlib: Lib.}
 #/ Update the collision detection info for the static shapes in the space.
@@ -674,7 +674,7 @@ proc dist*(v1, v2: TVector): CpFloat {.inline.} =
 proc distsq*(v1, v2: TVector): CpFloat {.inline.} = 
   result = (v1 - v2).lenSq  #vlengthsq(vsub(v1, v2))
 #/ Returns true if the distance between v1 and v2 is less than dist.
-proc near*(v1, v2: TVector; dist: CpFloat): Bool{.inline.} = 
+proc near*(v1, v2: TVector; dist: CpFloat): bool{.inline.} = 
   result = v1.distSq(v2) < dist * dist
 
 
@@ -706,13 +706,13 @@ proc Sleep*(body: PBody){.importc: "cpBodySleep", dynlib: Lib.}
 proc SleepWithGroup*(body: PBody; group: PBody){.
     importc: "cpBodySleepWithGroup", dynlib: Lib.}
 #/ Returns true if the body is sleeping.
-proc isSleeping*(body: PBody): Bool {.inline.} = 
+proc isSleeping*(body: PBody): bool {.inline.} = 
   return body.node.root != nil
 #/ Returns true if the body is static.
 proc isStatic*(body: PBody): bool {.inline.} = 
   return body.node.idleTime == CpInfinity
 #/ Returns true if the body has not been added to a space.
-proc isRogue*(body: PBody): Bool {.inline.} = 
+proc isRogue*(body: PBody): bool {.inline.} = 
   return body.space == nil
 
 # #define CP_DefineBodyStructGetter(type, member, name) \
@@ -808,15 +808,15 @@ proc kineticEnergy*(body: PBOdy): CpFloat =
   result = (body.v.dot(body.v) * body.m) + (body.w * body.w * body.i)
 
 #/ Call @c func once for each shape attached to @c body and added to the space.
-proc eachShape*(body: PBody; func: TBodyShapeIteratorFunc; 
+proc eachShape*(body: PBody; fun: TBodyShapeIteratorFunc; 
                       data: pointer){.
   cdecl, importc: "cpBodyEachShape", dynlib: Lib.}
 #/ Call @c func once for each constraint attached to @c body and added to the space.
-proc eachConstraint*(body: PBody; func: TBodyConstraintIteratorFunc; 
+proc eachConstraint*(body: PBody; fun: TBodyConstraintIteratorFunc; 
                            data: pointer) {.
   cdecl, importc: "cpBodyEachConstraint", dynlib: Lib.}
 #/ Call @c func once for each arbiter that is currently active on the body.
-proc eachArbiter*(body: PBody; func: TBodyArbiterIteratorFunc; 
+proc eachArbiter*(body: PBody; fun: TBodyArbiterIteratorFunc; 
                         data: pointer){.
   cdecl, importc: "cpBodyEachArbiter", dynlib: Lib.}
 #/ Allocate a spatial hash.
@@ -824,10 +824,10 @@ proc SpaceHashAlloc*(): PSpaceHash{.
   cdecl, importc: "cpSpaceHashAlloc", dynlib: Lib.}
 #/ Initialize a spatial hash. 
 proc SpaceHashInit*(hash: PSpaceHash; celldim: CpFloat; numcells: cint; 
-                    bbfunc: TSpatialIndexBBFunc; staticIndex: PSpatialIndex): PSpatialIndex{.
+                    bbfun: TSpatialIndexBBFunc; staticIndex: PSpatialIndex): PSpatialIndex{.
   cdecl, importc: "cpSpaceHashInit", dynlib: Lib.}
 #/ Allocate and initialize a spatial hash.
-proc SpaceHashNew*(celldim: CpFloat; cells: cint; bbfunc: TSpatialIndexBBFunc; 
+proc SpaceHashNew*(celldim: CpFloat; cells: cint; bbfun: TSpatialIndexBBFunc; 
                    staticIndex: PSpatialIndex): PSpatialIndex{.
   cdecl, importc: "cpSpaceHashNew", dynlib: Lib.}
 #/ Change the cell dimensions and table size of the spatial hash to tune it.
@@ -842,18 +842,18 @@ proc SpaceHashResize*(hash: PSpaceHash; celldim: CpFloat; numcells: cint){.
 #/ Allocate a bounding box tree.
 proc BBTreeAlloc*(): PBBTree{.cdecl, importc: "cpBBTreeAlloc", dynlib: Lib.}
 #/ Initialize a bounding box tree.
-proc BBTreeInit*(tree: PBBTree; bbfunc: TSpatialIndexBBFunc; 
+proc BBTreeInit*(tree: PBBTree; bbfun: TSpatialIndexBBFunc; 
                  staticIndex: ptr TSpatialIndex): ptr TSpatialIndex{.cdecl, 
     importc: "cpBBTreeInit", dynlib: Lib.}
 #/ Allocate and initialize a bounding box tree.
-proc BBTreeNew*(bbfunc: TSpatialIndexBBFunc; staticIndex: PSpatialIndex): PSpatialIndex{.
+proc BBTreeNew*(bbfun: TSpatialIndexBBFunc; staticIndex: PSpatialIndex): PSpatialIndex{.
     cdecl, importc: "cpBBTreeNew", dynlib: Lib.}
 #/ Perform a static top down optimization of the tree.
 proc BBTreeOptimize*(index: PSpatialIndex){.
   cdecl, importc: "cpBBTreeOptimize", dynlib: Lib.}
 #/ Set the velocity function for the bounding box tree to enable temporal coherence.
 
-proc BBTreeSetVelocityFunc*(index: PSpatialIndex; func: TBBTreeVelocityFunc){.
+proc BBTreeSetVelocityFunc*(index: PSpatialIndex; fun: TBBTreeVelocityFunc){.
     cdecl, importc: "cpBBTreeSetVelocityFunc", dynlib: Lib.}
 #MARK: Single Axis Sweep
 
@@ -864,12 +864,12 @@ proc Sweep1DAlloc*(): ptr TSweep1D{.cdecl, importc: "cpSweep1DAlloc",
                                     dynlib: Lib.}
 #/ Initialize a 1D sort and sweep broadphase.
 
-proc Sweep1DInit*(sweep: ptr TSweep1D; bbfunc: TSpatialIndexBBFunc; 
+proc Sweep1DInit*(sweep: ptr TSweep1D; bbfun: TSpatialIndexBBFunc; 
                   staticIndex: ptr TSpatialIndex): ptr TSpatialIndex{.cdecl, 
     importc: "cpSweep1DInit", dynlib: Lib.}
 #/ Allocate and initialize a 1D sort and sweep broadphase.
 
-proc Sweep1DNew*(bbfunc: TSpatialIndexBBFunc; staticIndex: ptr TSpatialIndex): ptr TSpatialIndex{.
+proc Sweep1DNew*(bbfun: TSpatialIndexBBFunc; staticIndex: ptr TSpatialIndex): ptr TSpatialIndex{.
     cdecl, importc: "cpSweep1DNew", dynlib: Lib.}
 
 
@@ -1359,7 +1359,7 @@ defCProp(SlideJoint, TVector, anchr2, Anchr2)
 defCProp(SlideJoint, CpFloat, min, Min)
 defCProp(SlideJoint, CpFloat, max, Max)
 
-proc pivotJointGetClass*(): PConstraintClass {.
+proc PivotJointGetClass*(): PConstraintClass {.
   cdecl, importc: "cpPivotJointGetClass", dynlib: Lib.}
 
 #/ Allocate a pivot joint
diff --git a/tests/manyloc/keineschweine/dependencies/enet/enet.nim b/tests/manyloc/keineschweine/dependencies/enet/enet.nim
index df1b743ee..93857207a 100644
--- a/tests/manyloc/keineschweine/dependencies/enet/enet.nim
+++ b/tests/manyloc/keineschweine/dependencies/enet/enet.nim
@@ -20,7 +20,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 const Lib = "libenet.so.1(|.0.3)"
 
-{.deadCodeElim: ON.}
+{.deadCodeElim: on.}
 const 
   ENET_VERSION_MAJOR* = 1
   ENET_VERSION_MINOR* = 3
diff --git a/tests/manyloc/keineschweine/dependencies/genpacket/genpacket.nim b/tests/manyloc/keineschweine/dependencies/genpacket/genpacket.nim
index ae9dfb39f..3026cc4b9 100644
--- a/tests/manyloc/keineschweine/dependencies/genpacket/genpacket.nim
+++ b/tests/manyloc/keineschweine/dependencies/genpacket/genpacket.nim
@@ -18,9 +18,9 @@ proc `$`*[T](x: seq[T]): string =
     result.add($x[i])
   result.add ']'
 
-macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} = 
+macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} =
   result = newNimNode(nnkStmtList)
-  let 
+  let
     typeName = quoted2ident(typeNameN)
     packetID = ^"p"
     streamID = ^"s"
@@ -66,7 +66,7 @@ macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} =
     readBody = newNimNode(nnkStmtList)
     lenNames = 0
   for i in 0.. typeFields.len - 1:
-    let 
+    let
       name = typeFields[i][0]
       dotName = packetID.dot(name)
       resName = newIdentNode(!"result").dot(name)
@@ -91,11 +91,11 @@ macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} =
           newNimNode(nnkDiscardStmt).und(
             newCall("readData", streamID, newNimNode(nnkAddr).und(resName), newCall("sizeof", resName))))
         packBody.add(
-          newCall("writeData", streamID, newNimNode(nnkAddr).und(dotName), newCall("sizeof", dotName))) 
+          newCall("writeData", streamID, newNimNode(nnkAddr).und(dotName), newCall("sizeof", dotName)))
       of "seq":
         ## let lenX = readInt16(s)
         newLenName()
-        let 
+        let
           item = ^"item"  ## item name in our iterators
           seqType = typeFields[i][1][1] ## type of seq
           readName = newIdentNode("read"& $seqType.ident)
@@ -107,7 +107,7 @@ macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} =
         readBody.add(      ## result.name = @[]
           resName := ("@".prefix(newNimNode(nnkBracket))),
           newNimNode(nnkForStmt).und(  ## for item in 1..len:
-            item, 
+            item,
             infix(1.lit, "..", lenName),
             newNimNode(nnkStmtList).und(
               newCall(  ## add(result.name, unpack[seqType](stream))
@@ -117,7 +117,7 @@ macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} =
           newNimNode(nnkVarSection).und(newNimNode(nnkIdentDefs).und(
             lenName,  ## var lenName = int16(len(p.name))
             newIdentNode("int16"),
-            newCall("int16", newCall("len", dotName)))), 
+            newCall("int16", newCall("len", dotName)))),
           newCall("writeData", streamID, newNimNode(nnkAddr).und(lenName), 2.lit),
           newNimNode(nnkForStmt).und(  ## for item in 0..length - 1: pack(p.name[item], stream)
             item,
@@ -143,8 +143,8 @@ macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} =
         readBody.add(resName := newCall("read"& $typeFields[i][1].ident, streamID))
     else:
       error("I dont know what to do with: "& treerepr(typeFields[i]))
-  
-  var 
+
+  var
     toStringFunc = newNimNode(nnkProcDef).und(
       newNimNode(nnkPostfix).und(
         ^"*",
@@ -161,12 +161,12 @@ macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} =
       emptyNode(),
       newNimNode(nnkStmtList).und(#[6]
         newNimNode(nnkAsgn).und(
-          ^"result",                  ## result = 
+          ^"result",                  ## result =
           newNimNode(nnkCall).und(#[6][0][1]
             ^"format",  ## format
             emptyNode()))))  ## "[TypeName   $1   $2]"
     formatStr = "["& $typeName.ident
-  
+
   const emptyFields = {nnkEmpty, nnkNilLit}
   var objFields = newNimNode(nnkRecList)
   for i in 0.. < len(typeFields):
@@ -186,10 +186,10 @@ macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} =
       prefix("$", packetID.dot(fname)))
     formatStr.add "   $"
     formatStr.add($(i + 1))
-  
+
   formatStr.add ']'
   toStringFunc[6][0][1][1] = formatStr.lit()
-  
+
   result.add(
     newNimNode(nnkTypeSection).und(
       newNimNode(nnkTypeDef).und(
@@ -206,15 +206,15 @@ macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} =
   when defined(GenPacketShowOutput):
     echo(repr(result))
 
-proc `->`(a: string, b: string): PNimrodNode {.compileTime.} =
+proc `->`(a: string, b: string): NimNode {.compileTime.} =
   result = newNimNode(nnkIdentDefs).und(^a, ^b, newNimNode(nnkEmpty))
-proc `->`(a: string, b: PNimrodNode): PNimrodNode {.compileTime.} =
+proc `->`(a: string, b: NimNode): NimNode {.compileTime.} =
   result = newNimNode(nnkIdentDefs).und(^a, b, newNimNode(nnkEmpty))
-proc `->`(a, b: PNimrodNode): PNimrodNode {.compileTime.} =
+proc `->`(a, b: NimNode): NimNode {.compileTime.} =
   a[2] = b
   result = a
 
-proc newProc*(name: string, params: varargs[PNimrodNode], resultType: PNimrodNode): PNimrodNode {.compileTime.} =
+proc newProc*(name: string, params: varargs[NimNode], resultType: NimNode): NimNode {.compileTime.} =
   result = newNimNode(nnkProcDef).und(
     ^name,
     emptyNode(),
@@ -227,7 +227,7 @@ proc newProc*(name: string, params: varargs[PNimrodNode], resultType: PNimrodNod
 macro forwardPacket*(typeName: expr, underlyingType: typedesc): stmt {.immediate.} =
   result = newNimNode(nnkStmtList).und(
     newProc(
-      "read"& $typeName.ident, 
+      "read"& $typeName.ident,
       ["s" -> "PStream" -> newNimNode(nnkNilLit)],
       typeName),
     newProc(
@@ -258,21 +258,21 @@ when isMainModule:
       A = 0'i8,
       B, C
   forwardPacket(SomeEnum, int8)
-  
-  
+
+
   defPacket(Foo, tuple[x: array[0..4, int8]])
   var f = newFoo([4'i8, 3'i8, 2'i8, 1'i8, 0'i8])
   var s2 = newStringStream("")
   f.pack(s2)
   assert s2.data == "\4\3\2\1\0"
-  
+
   var s = newStringStream()
   s.flushImpl = proc(s: PStream) =
     var z = PStringStream(s)
     z.setPosition(0)
     z.data.setLen(0)
-  
-  
+
+
   s.setPosition(0)
   s.data.setLen(0)
   var o = B
@@ -283,7 +283,7 @@ when isMainModule:
   o.pack(s)
   assert s.data == "\1\0\2"
   s.flush
-  
+
   defPacket(Y, tuple[z: int8])
   proc `$`(z: Y): string = result = "Y("& $z.z &")"
   defPacket(TestPkt, tuple[x: seq[Y]])
@@ -292,4 +292,4 @@ when isMainModule:
   for itm in test.x:
     echo(itm)
   test.pack(s)
-  echo(repr(s.data))
\ No newline at end of file
+  echo(repr(s.data))
diff --git a/tests/manyloc/keineschweine/dependencies/genpacket/genpacket_enet.nim b/tests/manyloc/keineschweine/dependencies/genpacket/genpacket_enet.nim
index 44d00db53..7cfd67c49 100644
--- a/tests/manyloc/keineschweine/dependencies/genpacket/genpacket_enet.nim
+++ b/tests/manyloc/keineschweine/dependencies/genpacket/genpacket_enet.nim
@@ -9,18 +9,9 @@ template defPacketImports*(): stmt {.immediate, dirty.} =
   import macros, macro_dsl, estreams
   from strutils import format
 
-proc `$`*[T](x: seq[T]): string =
-  result = "[seq len="
-  result.add($x.len)
-  result.add ':'
-  for i in 0.. <len(x):
-    result.add "   "
-    result.add($x[i])
-  result.add ']'
-
-macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} = 
+macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} =
   result = newNimNode(nnkStmtList)
-  let 
+  let
     typeName = quoted2ident(typeNameN)
     packetID = ^"p"
     streamID = ^"s"
@@ -66,7 +57,7 @@ macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} =
     readBody = newNimNode(nnkStmtList)
     lenNames = 0
   for i in 0.. typeFields.len - 1:
-    let 
+    let
       name = typeFields[i][0]
       dotName = packetID.dot(name)
       resName = newIdentNode(!"result").dot(name)
@@ -76,7 +67,7 @@ macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} =
       of "seq":
         ## let lenX = readInt16(s)
         newLenName()
-        let 
+        let
           item = ^"item"  ## item name in our iterators
           seqType = typeFields[i][1][1] ## type of seq
           readName = newIdentNode("read"& $seqType.ident)
@@ -88,7 +79,7 @@ macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} =
         readBody.add(      ## result.name = @[]
           resName := ("@".prefix(newNimNode(nnkBracket))),
           newNimNode(nnkForStmt).und(  ## for item in 1..len:
-            item, 
+            item,
             infix(1.lit, "..", lenName),
             newNimNode(nnkStmtList).und(
               newCall(  ## add(result.name, unpack[seqType](stream))
@@ -98,7 +89,7 @@ macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} =
           newNimNode(nnkVarSection).und(newNimNode(nnkIdentDefs).und(
             lenName,  ## var lenName = int16(len(p.name))
             newIdentNode("int16"),
-            newCall("int16", newCall("len", dotName)))), 
+            newCall("int16", newCall("len", dotName)))),
           newCall("writeBE", streamID, lenName),
           newNimNode(nnkForStmt).und(  ## for item in 0..length - 1: pack(p.name[item], stream)
             item,
@@ -124,8 +115,8 @@ macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} =
         readBody.add(resName := newCall("read"& $typeFields[i][1].ident, streamID))
     else:
       error("I dont know what to do with: "& treerepr(typeFields[i]))
-  
-  var 
+
+  var
     toStringFunc = newNimNode(nnkProcDef).und(
       newNimNode(nnkPostfix).und(
         ^"*",
@@ -142,12 +133,12 @@ macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} =
       emptyNode(),
       newNimNode(nnkStmtList).und(#[6]
         newNimNode(nnkAsgn).und(
-          ^"result",                  ## result = 
+          ^"result",                  ## result =
           newNimNode(nnkCall).und(#[6][0][1]
             ^"format",  ## format
             emptyNode()))))  ## "[TypeName   $1   $2]"
     formatStr = "["& $typeName.ident
-  
+
   const emptyFields = {nnkEmpty, nnkNilLit}
   var objFields = newNimNode(nnkRecList)
   for i in 0.. < len(typeFields):
@@ -167,10 +158,10 @@ macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} =
       prefix("$", packetID.dot(fname)))
     formatStr.add "   $"
     formatStr.add($(i + 1))
-  
+
   formatStr.add ']'
   toStringFunc[6][0][1][1] = formatStr.lit()
-  
+
   result.add(
     newNimNode(nnkTypeSection).und(
       newNimNode(nnkTypeDef).und(
@@ -187,7 +178,7 @@ macro defPacket*(typeNameN: expr, typeFields: expr): stmt {.immediate.} =
   when defined(GenPacketShowOutput):
     echo(repr(result))
 
-proc newProc*(name: PNimrodNode; params: varargs[PNimrodNode]; resultType: PNimrodNode): PNimrodNode {.compileTime.} =
+proc newProc*(name: NimNode; params: varargs[NimNode]; resultType: NimNode): NimNode {.compileTime.} =
   result = newNimNode(nnkProcDef).und(
     name,
     emptyNode(),
@@ -198,15 +189,15 @@ proc newProc*(name: PNimrodNode; params: varargs[PNimrodNode]; resultType: PNimr
     newNimNode(nnkStmtList))
   result[3].add(params)
 
-proc body*(procNode: PNimrodNode): PNimrodNode {.compileTime.} =
+proc body*(procNode: NimNode): NimNode {.compileTime.} =
   assert procNode.kind == nnkProcDef and procNode[6].kind == nnkStmtList
   result = procNode[6]
 
-proc iddefs*(a, b: string; c: PNimrodNode): PNimrodNode {.compileTime.} =
+proc iddefs*(a, b: string; c: NimNode): NimNode {.compileTime.} =
   result = newNimNode(nnkIdentDefs).und(^a, ^b, c)
-proc iddefs*(a: string; b: PNimrodNode): PNimrodNode {.compileTime.} =
+proc iddefs*(a: string; b: NimNode): NimNode {.compileTime.} =
   result = newNimNode(nnkIdentDefs).und(^a, b, emptyNode())
-proc varTy*(a: PNimrodNode): PNimrodNode {.compileTime.} =
+proc varTy*(a: NimNode): NimNode {.compileTime.} =
   result = newNimNode(nnkVarTy).und(a)
 
 macro forwardPacket*(typeName: expr, underlyingType: expr): stmt {.immediate.} =
@@ -215,7 +206,7 @@ macro forwardPacket*(typeName: expr, underlyingType: expr): stmt {.immediate.} =
     streamID = ^"s"
   result = newNimNode(nnkStmtList).und(
     newProc(
-      (^("read"& $typeName.ident)).postfix("*"), 
+      (^("read"& $typeName.ident)).postfix("*"),
       [ iddefs("s", "PBuffer", newNimNode(nnkNilLit)) ],
       typeName),
     newProc(
@@ -227,7 +218,7 @@ macro forwardPacket*(typeName: expr, underlyingType: expr): stmt {.immediate.} =
     readBody = result[0][6]
     packBody = result[1][6]
     resName = ^"result"
-  
+
   case underlyingType.kind
   of nnkBracketExpr:
     case $underlyingType[0].ident
@@ -259,21 +250,21 @@ when isMainModule:
       A = 0'i8,
       B, C
   forwardPacket(SomeEnum, int8)
-  
-  
+
+
   defPacket(Foo, tuple[x: array[0..4, int8]])
   var f = newFoo([4'i8, 3'i8, 2'i8, 1'i8, 0'i8])
   var s2 = newStringStream("")
   f.pack(s2)
   assert s2.data == "\4\3\2\1\0"
-  
+
   var s = newStringStream()
   s.flushImpl = proc(s: PStream) =
     var z = PStringStream(s)
     z.setPosition(0)
     z.data.setLen(0)
-  
-  
+
+
   s.setPosition(0)
   s.data.setLen(0)
   var o = B
@@ -284,7 +275,7 @@ when isMainModule:
   o.pack(s)
   assert s.data == "\1\0\2"
   s.flush
-  
+
   defPacket(Y, tuple[z: int8])
   proc `$`(z: Y): string = result = "Y("& $z.z &")"
   defPacket(TestPkt, tuple[x: seq[Y]])
@@ -293,4 +284,4 @@ when isMainModule:
   for itm in test.x:
     echo(itm)
   test.pack(s)
-  echo(repr(s.data))
\ No newline at end of file
+  echo(repr(s.data))
diff --git a/tests/manyloc/keineschweine/dependencies/genpacket/macro_dsl.nim b/tests/manyloc/keineschweine/dependencies/genpacket/macro_dsl.nim
index c7b577b3d..d3a0c701d 100644
--- a/tests/manyloc/keineschweine/dependencies/genpacket/macro_dsl.nim
+++ b/tests/manyloc/keineschweine/dependencies/genpacket/macro_dsl.nim
@@ -1,42 +1,42 @@
 import macros
 {.deadCodeElim: on.}
 #Inline macro.add() to allow for easier nesting
-proc und*(a: PNimrodNode; b: PNimrodNode): PNimrodNode {.compileTime.} =
+proc und*(a: NimNode; b: NimNode): NimNode {.compileTime.} =
   a.add(b)
   result = a
-proc und*(a: PNimrodNode; b: varargs[PNimrodNode]): PNimrodNode {.compileTime.} =
+proc und*(a: NimNode; b: varargs[NimNode]): NimNode {.compileTime.} =
   a.add(b)
   result = a
 
-proc `^`*(a: string): PNimrodNode {.compileTime.} = 
+proc `^`*(a: string): NimNode {.compileTime.} =
   ## new ident node
   result = newIdentNode(!a)
-proc `[]`*(a, b: PNimrodNode): PNimrodNode {.compileTime.} =
+proc `[]`*(a, b: NimNode): NimNode {.compileTime.} =
   ## new bracket expression: node[node] not to be confused with node[indx]
   result = newNimNode(nnkBracketExpr).und(a, b)
-proc `:=`*(left, right: PNimrodNode): PNimrodNode {.compileTime.} =
+proc `:=`*(left, right: NimNode): NimNode {.compileTime.} =
   ## new Asgn node:  left = right
   result = newNimNode(nnkAsgn).und(left, right)
 
-proc lit*(a: string): PNimrodNode {.compileTime.} =
+proc lit*(a: string): NimNode {.compileTime.} =
   result = newStrLitNode(a)
-proc lit*(a: int): PNimrodNode {.compileTime.} =
+proc lit*(a: int): NimNode {.compileTime.} =
   result = newIntLitNode(a)
-proc lit*(a: float): PNimrodNode {.compileTime.} =
+proc lit*(a: float): NimNode {.compileTime.} =
   result = newFloatLitNode(a)
-proc lit*(a: char): PNimrodNode {.compileTime.} =
+proc lit*(a: char): NimNode {.compileTime.} =
   result = newNimNode(nnkCharLit)
   result.intval = a.ord
 
-proc emptyNode*(): PNimrodNode {.compileTime.} =
+proc emptyNode*(): NimNode {.compileTime.} =
   result = newNimNode(nnkEmpty)
 
-proc dot*(left, right: PNimrodNode): PNimrodNode {.compileTime.} =
+proc dot*(left, right: NimNode): NimNode {.compileTime.} =
   result = newNimNode(nnkDotExpr).und(left, right)
-proc prefix*(a: string, b: PNimrodNode): PNimrodNode {.compileTime.} =
+proc prefix*(a: string, b: NimNode): NimNode {.compileTime.} =
   result = newNimNode(nnkPrefix).und(newIdentNode(!a), b)
 
-proc quoted2ident*(a: PNimrodNode): PNimrodNode {.compileTime.} = 
+proc quoted2ident*(a: NimNode): NimNode {.compileTime.} =
   if a.kind != nnkAccQuoted:
     return a
   var pname = ""
diff --git a/tests/manyloc/keineschweine/dependencies/genpacket/streams_enh.nim b/tests/manyloc/keineschweine/dependencies/genpacket/streams_enh.nim
index a9759687f..3c5a7835c 100644
--- a/tests/manyloc/keineschweine/dependencies/genpacket/streams_enh.nim
+++ b/tests/manyloc/keineschweine/dependencies/genpacket/streams_enh.nim
@@ -1,5 +1,5 @@
 import streams
-from strutils import repeatChar
+from strutils import repeat
 
 proc readPaddedStr*(s: PStream, length: int, padChar = '\0'): TaintedString = 
   var lastChr = length
@@ -10,7 +10,7 @@ proc readPaddedStr*(s: PStream, length: int, padChar = '\0'): TaintedString =
 proc writePaddedStr*(s: PStream, str: string, length: int, padChar = '\0') =
   if str.len < length:
     s.write(str)
-    s.write(repeatChar(length - str.len, padChar))
+    s.write(repeat(padChar, length - str.len))
   elif str.len > length:
     s.write(str.substr(0, length - 1))
   else:
@@ -37,7 +37,7 @@ when isMainModule:
   testStream.setPosition 0
   testStream.writePaddedStr("Sup", 10)
   echo(repr(testStream), testStream.data.len)
-  doAssert testStream.data == "Sup"&repeatChar(7, '\0')
+  doAssert testStream.data == "Sup"&repeat('\0', 7)
   
   testStream.setPosition 0
   res = testStream.readPaddedStr(10)
diff --git a/tests/manyloc/keineschweine/dependencies/sfml/sfml.nim b/tests/manyloc/keineschweine/dependencies/sfml/sfml.nim
index 0d09d40e3..1071ec767 100644
--- a/tests/manyloc/keineschweine/dependencies/sfml/sfml.nim
+++ b/tests/manyloc/keineschweine/dependencies/sfml/sfml.nim
@@ -221,10 +221,10 @@ type
   TTransform* {.pf.} = object
     matrix*: array[0..8, cfloat]
   TColor* {.pf.} = object 
-    r*: Uint8
-    g*: Uint8
-    b*: Uint8
-    a*: Uint8
+    r*: uint8
+    g*: uint8
+    b*: uint8
+    a*: uint8
   PFloatRect* = ptr TFloatRect
   TFloatRect*{.pf.} = object 
     left*: cfloat
@@ -306,7 +306,7 @@ proc close*(window: PRenderWindow) {.
 proc isOpen*(window: PRenderWindow): bool {.
   cdecl, importc: "sfRenderWindow_isOpen", dynlib: LibG.}
 
-#void sfRenderWindow_setIcon(sfRenderWindow* renderWindow, unsigned int width, unsigned int height, const sfUint8* pixels);
+#void sfRenderWindow_setIcon(sfRenderWindow* renderWindow, unsigned int width, unsigned int height, const sfuint8* pixels);
 #proc setIcon*(window: PRenderWindow, width, height: cint, pixels: seq[uint8]) {.
 #  cdecl, importc: "sfRenderWindow_setIcon", dynlib: LibG.}
 
@@ -395,7 +395,7 @@ proc capture*(window: PRenderWindow): PImage {.
   cdecl, importc: "sfRenderWindow_capture", dynlib: LibG.}
 
 #Construct a new render texture
-proc newRenderTexture*(width, height: cint; depthBuffer: Bool): PRenderTexture {.
+proc newRenderTexture*(width, height: cint; depthBuffer: bool): PRenderTexture {.
   cdecl, importc: "sfRenderTexture_create", dynlib: LibG.}
 #Destroy an existing render texture
 proc destroy*(renderTexture: PRenderTexture){.
@@ -522,9 +522,9 @@ proc copy*(font: PFont): PFont {.
   cdecl, importc: "sfFont_copy", dynlib: LibG.}
 proc destroy*(font: PFont) {.
   cdecl, importc: "sfFont_destroy", dynlib: LibG.}
-proc getGlyph*(font: PFont, codePoint: Uint32, characterSize: cint, bold: bool): TGlyph{.
+proc getGlyph*(font: PFont, codePoint: uint32, characterSize: cint, bold: bool): TGlyph{.
   cdecl, importc: "sfFont_getGlyph", dynlib: LibG.}
-proc getKerning*(font: PFont, first: Uint32, second: Uint32, characterSize: cint): cint {.
+proc getKerning*(font: PFont, first: uint32, second: uint32, characterSize: cint): cint {.
   cdecl, importc: "sfFont_getKerning", dynlib: LibG.}
 proc getLineSpacing*(font: PFont, characterSize: cint): cint {.
   cdecl, importc: "sfFont_getLineSpacing", dynlib: LibG.}
@@ -882,7 +882,7 @@ proc getInverseTransform*(text: PText): TTransform {.
   cdecl, importc: "sfText_getInverseTransform", dynlib: LibG.}
 proc setString*(text: PText, string: cstring) {.
   cdecl, importc: "sfText_setString", dynlib: LibG.}
-proc setUnicodeString*(text: PText, string: ptr Uint32) {.
+proc setUnicodeString*(text: PText, string: ptr uint32) {.
   cdecl, importc: "sfText_setUnicodeString", dynlib: LibG.}
 proc setFont*(text: PText, font: PFont) {.
   cdecl, importc: "sfText_setFont", dynlib: LibG.}
@@ -894,13 +894,13 @@ proc setColor*(text: PText, color: TColor) {.
   cdecl, importc: "sfText_setColor", dynlib: LibG.}
 proc getString*(text: PText): cstring {.
   cdecl, importc: "sfText_getString", dynlib: LibG.}
-proc getUnicodeString*(text: PText): ptr Uint32 {.cdecl, 
+proc getUnicodeString*(text: PText): ptr uint32 {.cdecl, 
   importc: "sfText_getUnicodeString", dynlib: LibG.}
 proc getFont*(text: PText): PFont {.
   cdecl, importc: "sfText_getFont", dynlib: LibG.}
 proc getCharacterSize*(text: PText): cint {.
   cdecl, importc: "sfText_getCharacterSize", dynlib: LibG.}
-proc getStyle*(text: PText): Uint32 {.
+proc getStyle*(text: PText): uint32 {.
   cdecl, importc: "sfText_getStyle", dynlib: LibG.}
 proc getColor*(text: PText): TColor {.
   cdecl, importc: "sfText_getColor", dynlib: LibG.}
diff --git a/tests/manyloc/keineschweine/dependencies/sfml/sfml_audio.nim b/tests/manyloc/keineschweine/dependencies/sfml/sfml_audio.nim
index 3cfd33c02..5aa017ac4 100644
--- a/tests/manyloc/keineschweine/dependencies/sfml/sfml_audio.nim
+++ b/tests/manyloc/keineschweine/dependencies/sfml/sfml_audio.nim
@@ -284,7 +284,7 @@ proc newSoundBuffer*(stream: PInputStream): PSoundBuffer{.
 #/ \brief Create a new sound buffer and load it from an array of samples in memory
 #/
 #/ The assumed format of the audio samples is 16 bits signed integer
-#/ (sfInt16).
+#/ (sfint16).
 #/
 #/ \param samples      Pointer to the array of samples in memory
 #/ \param sampleCount  Number of samples in the array
@@ -334,7 +334,7 @@ proc saveToFile*(soundBuffer: PSoundBuffer; filename: cstring): bool {.
 #/ \brief Get the array of audio samples stored in a sound buffer
 #/
 #/ The format of the returned samples is 16 bits signed integer
-#/ (sfInt16). The total number of samples in this array
+#/ (sfint16). The total number of samples in this array
 #/ is given by the sfSoundBuffer_getSampleCount function.
 #/
 #/ \param soundBuffer Sound buffer object
@@ -342,7 +342,7 @@ proc saveToFile*(soundBuffer: PSoundBuffer; filename: cstring): bool {.
 #/ \return Read-only pointer to the array of sound samples
 #/
 #//////////////////////////////////////////////////////////
-proc sfSoundBuffer_getSamples*(soundBuffer: PSoundBuffer): ptr Int16{.
+proc sfSoundBuffer_getSamples*(soundBuffer: PSoundBuffer): ptr int16{.
   cdecl, importc: "sfSoundBuffer_getSamples", dynlib: Lib.}
 #//////////////////////////////////////////////////////////
 #/ \brief Get the number of samples stored in a sound buffer
diff --git a/tests/manyloc/keineschweine/enet_server/enet_client.nim b/tests/manyloc/keineschweine/enet_server/enet_client.nim
index 0c903a733..5ebbdb88b 100644
--- a/tests/manyloc/keineschweine/enet_server/enet_client.nim
+++ b/tests/manyloc/keineschweine/enet_server/enet_client.nim
@@ -105,6 +105,7 @@ proc tryLogin*(b: PButton) =
     passwd = u_passwd.getText())
   dirServer.send HLogin, login
 proc tryTransition*(b: PButton) =
+  discard
   #zone.writePkt HZoneJoinReq, myCreds
 proc tryConnect*(b: PButton) =
   if not dirServer.connected:
diff --git a/tests/manyloc/keineschweine/enet_server/enet_server.nim b/tests/manyloc/keineschweine/enet_server/enet_server.nim
index 6dd1a6a7f..c2e893273 100644
--- a/tests/manyloc/keineschweine/enet_server/enet_server.nim
+++ b/tests/manyloc/keineschweine/enet_server/enet_server.nim
@@ -144,7 +144,7 @@ when isMainModule:
     discard """block:
       var 
         TestFile: FileChallengePair
-        contents = repeatStr(2, "abcdefghijklmnopqrstuvwxyz")
+        contents = repeat("abcdefghijklmnopqrstuvwxyz", 2)
       testFile.challenge = newScFileChallenge("foobar.test", FZoneCfg, contents.len.int32) 
       testFile.file = checksumStr(contents)
       myAssets.add testFile"""
diff --git a/tests/manyloc/keineschweine/enet_server/nimrod.cfg b/tests/manyloc/keineschweine/enet_server/nim.cfg
index 72ef47ee0..72ef47ee0 100644
--- a/tests/manyloc/keineschweine/enet_server/nimrod.cfg
+++ b/tests/manyloc/keineschweine/enet_server/nim.cfg
diff --git a/tests/manyloc/keineschweine/keineschweine.nim b/tests/manyloc/keineschweine/keineschweine.nim
index e868b96a5..525d8a054 100644
--- a/tests/manyloc/keineschweine/keineschweine.nim
+++ b/tests/manyloc/keineschweine/keineschweine.nim
@@ -113,7 +113,7 @@ when defined(recordMode):
     isRecording = false
   proc zeroPad*(s: string; minLen: int): string =
     if s.len < minLen:
-      result = repeatChar(minLen - s.len, '0')
+      result = repeat(0, minLen - s.len)
       result.add s
     else:
       result = s
@@ -143,7 +143,7 @@ proc mouseToSpace*(): TVector =
 proc explode*(b: PLiveBullet)
 ## TCollisionBeginFunc
 proc collisionBulletPlayer(arb: PArbiter; space: PSpace; 
-                            data: pointer): Bool{.cdecl.} =
+                            data: pointer): bool{.cdecl.} =
   var 
     bullet = cast[PLiveBullet](arb.a.data)
     target = cast[PVehicle](arb.b.data)
@@ -152,7 +152,7 @@ proc collisionBulletPlayer(arb: PArbiter; space: PSpace;
 
 proc angularDampingSim(body: PBody, gravity: TVector, damping, dt: CpFloat){.cdecl.} =
   body.w -= (body.w * 0.98 * dt) 
-  body.updateVelocity(gravity, damping, dt)
+  body.UpdateVelocity(gravity, damping, dt)
 
 proc initLevel() =
   loadAllAssets()
@@ -227,7 +227,7 @@ proc explode*(b: PLiveBullet) =
   playSound(b.record.explosion.sound, b.body.getPos())
 
 proc bulletUpdate(body: PBody, gravity: TVector, damping, dt: CpFloat){.cdecl.} =
-  body.updateVelocity(gravity, damping, dt)
+  body.UpdateVelocity(gravity, damping, dt)
 
 template getPhysical() {.immediate.} =
   result.body = space.addBody(newBody(
@@ -237,7 +237,7 @@ template getPhysical() {.immediate.} =
     chipmunk.newCircleShape(
       result.body,
       record.physics.radius,
-      vectorZero))
+      VectorZero))
 
 proc newBullet*(record: PBulletRecord; fromPlayer: PPlayer): PLiveBullet =
   new(result, free)
@@ -480,7 +480,7 @@ when defined(DebugKeys):
       echo(repr(activeVehicle.record))
     elif keyPressed(KeyH):
       activeVehicle.body.setPos(vector(100.0, 100.0))
-      activeVehicle.body.setVel(vectorZero)
+      activeVehicle.body.setVel(VectorZero)
     elif keyPressed(KeyComma):
       activeVehicle.body.setPos mouseToSpace())
   ingameClient.registerHandler(KeyY, down, proc() =
@@ -507,7 +507,7 @@ when defined(DebugKeys):
       return
     let body = shape.getBody()
     mouseJoint = space.addConstraint(
-      newPivotJoint(mouseBody, body, vectorZero, body.world2local(point)))
+      newPivotJoint(mouseBody, body, VectorZero, body.world2local(point)))
     mouseJoint.maxForce = 50000.0
     mouseJoint.errorBias = pow(1.0 - 0.15, 60))
 
@@ -539,15 +539,15 @@ proc mainUpdate(dt: float) =
   elif not activeVehicle.isNil:
     if keyPressed(KeyUp):
       activeVehicle.accel(dt)
-    elif keyPressed(keyDown):
+    elif keyPressed(KeyDown):
       activeVehicle.reverse(dt)
     if keyPressed(KeyRight):
       activeVehicle.turn_right(dt)
     elif keyPressed(KeyLeft):
       activeVehicle.turn_left(dt)
-    if keyPressed(keyz):
+    if keyPressed(Keyz):
       activeVehicle.strafe_left(dt)
-    elif keyPressed(keyx):
+    elif keyPressed(Keyx):
       activeVehicle.strafe_right(dt)
     if keyPressed(KeyLControl):
       localPlayer.useItem 0
@@ -557,7 +557,7 @@ proc mainUpdate(dt: float) =
       localPlayer.useItem 2
     if keyPressed(KeyW):
       localPlayer.useItem 3
-    if Keypressed(keyA):
+    if keyPressed(KeyA):
       localPlayer.useItem 4
     if keyPressed(sfml.KeyS):
       localPlayer.useItem 5
@@ -666,7 +666,7 @@ when isMainModule:
   import parseopt
   
   localPlayer = newPlayer()
-  LobbyInit()
+  lobbyInit()
   
   videoMode = getClientSettings().resolution
   window = newRenderWindow(videoMode, "sup", sfDefaultStyle)
@@ -683,7 +683,7 @@ when isMainModule:
     mouseSprite.setOutlineThickness 1.4
     mouseSprite.setOrigin vec2f(14, 14)
   
-  LobbyReady()
+  lobbyReady()
   playBtn = specGui.newButton(
     "Unspec - F12", position = vec2f(680.0, 8.0), onClick = proc(b: PButton) =
       toggleSpec())
diff --git a/tests/manyloc/keineschweine/lib/game_objects.nim b/tests/manyloc/keineschweine/lib/game_objects.nim
index 37019ebcb..277ffb6cb 100644
--- a/tests/manyloc/keineschweine/lib/game_objects.nim
+++ b/tests/manyloc/keineschweine/lib/game_objects.nim
@@ -26,7 +26,7 @@ proc newObject*(record: PObjectRecord): PGameObject =
   when false:
     result.sprite = record.anim.spriteSheet.sprite.copy()
   result.body = newBody(result.record.physics.mass, 10.0)
-  result.shape = chipmunk.newCircleShape(result.body, result.record.physics.radius, vectorZero)
+  result.shape = chipmunk.newCircleShape(result.body, result.record.physics.radius, VectorZero)
   result.body.setPos(vector(100, 100))
 proc newObject*(name: string): PGameObject =
   result = newObject(fetchObj(name))
diff --git a/tests/manyloc/keineschweine/lib/gl.nim b/tests/manyloc/keineschweine/lib/gl.nim
index 9387b5bc9..c577f3404 100644
--- a/tests/manyloc/keineschweine/lib/gl.nim
+++ b/tests/manyloc/keineschweine/lib/gl.nim
@@ -38,7 +38,7 @@ type
   PGLclampf* = ptr TGLclampf
   PGLdouble* = ptr TGLdouble
   PGLclampd* = ptr TGLclampd
-  PGLvoid* = Pointer
+  PGLvoid* = pointer
   PPGLvoid* = ptr PGLvoid
   TGLenum* = cint
   TGLboolean* = bool
@@ -983,7 +983,7 @@ const                         # Version
   GL_TEXTURE_COMPONENTS* = GL_TEXTURE_INTERNAL_FORMAT
 
 proc glAccum*(op: TGLenum, value: TGLfloat){.dynlib: dllname, importc: "glAccum".}
-proc glAlphaFunc*(func: TGLenum, theref: TGLclampf){.dynlib: dllname, 
+proc glAlphaFunc*(fun: TGLenum, theref: TGLclampf){.dynlib: dllname, 
     importc: "glAlphaFunc".}
 proc glAreTexturesResident*(n: TGLsizei, textures: PGLuint, 
                             residences: PGLboolean): TGLboolean{.
@@ -998,7 +998,7 @@ proc glBitmap*(width, height: TGLsizei, xorig, yorig: TGLfloat,
 proc glBlendFunc*(sfactor, dfactor: TGLenum){.dynlib: dllname, 
     importc: "glBlendFunc".}
 proc glCallList*(list: TGLuint){.dynlib: dllname, importc: "glCallList".}
-proc glCallLists*(n: TGLsizei, atype: TGLenum, lists: Pointer){.dynlib: dllname, 
+proc glCallLists*(n: TGLsizei, atype: TGLenum, lists: pointer){.dynlib: dllname, 
     importc: "glCallLists".}
 proc glClear*(mask: TGLbitfield){.dynlib: dllname, importc: "glClear".}
 proc glClearAccum*(red, green, blue, alpha: TGLfloat){.dynlib: dllname, 
@@ -1062,7 +1062,7 @@ proc glColorMask*(red, green, blue, alpha: TGLboolean){.dynlib: dllname,
 proc glColorMaterial*(face, mode: TGLenum){.dynlib: dllname, 
     importc: "glColorMaterial".}
 proc glColorPointer*(size: TGLint, atype: TGLenum, stride: TGLsizei, 
-                     pointer: Pointer){.dynlib: dllname, 
+                     p: pointer){.dynlib: dllname, 
                                         importc: "glColorPointer".}
 proc glCopyPixels*(x, y: TGLint, width, height: TGLsizei, atype: TGLenum){.
     dynlib: dllname, importc: "glCopyPixels".}
@@ -1084,7 +1084,7 @@ proc glDeleteLists*(list: TGLuint, range: TGLsizei){.dynlib: dllname,
     importc: "glDeleteLists".}
 proc glDeleteTextures*(n: TGLsizei, textures: PGLuint){.dynlib: dllname, 
     importc: "glDeleteTextures".}
-proc glDepthFunc*(func: TGLenum){.dynlib: dllname, importc: "glDepthFunc".}
+proc glDepthFunc*(fun: TGLenum){.dynlib: dllname, importc: "glDepthFunc".}
 proc glDepthMask*(flag: TGLboolean){.dynlib: dllname, importc: "glDepthMask".}
 proc glDepthRange*(zNear, zFar: TGLclampd){.dynlib: dllname, 
     importc: "glDepthRange".}
@@ -1095,12 +1095,12 @@ proc glDrawArrays*(mode: TGLenum, first: TGLint, count: TGLsizei){.
     dynlib: dllname, importc: "glDrawArrays".}
 proc glDrawBuffer*(mode: TGLenum){.dynlib: dllname, importc: "glDrawBuffer".}
 proc glDrawElements*(mode: TGLenum, count: TGLsizei, atype: TGLenum, 
-                     indices: Pointer){.dynlib: dllname, 
+                     indices: pointer){.dynlib: dllname, 
                                         importc: "glDrawElements".}
 proc glDrawPixels*(width, height: TGLsizei, format, atype: TGLenum, 
-                   pixels: Pointer){.dynlib: dllname, importc: "glDrawPixels".}
+                   pixels: pointer){.dynlib: dllname, importc: "glDrawPixels".}
 proc glEdgeFlag*(flag: TGLboolean){.dynlib: dllname, importc: "glEdgeFlag".}
-proc glEdgeFlagPointer*(stride: TGLsizei, pointer: Pointer){.dynlib: dllname, 
+proc glEdgeFlagPointer*(stride: TGLsizei, p: pointer){.dynlib: dllname, 
     importc: "glEdgeFlagPointer".}
 proc glEdgeFlagv*(flag: PGLboolean){.dynlib: dllname, importc: "glEdgeFlagv".}
 proc glEnable*(cap: TGLenum){.dynlib: dllname, importc: "glEnable".}
@@ -1171,7 +1171,7 @@ proc glGetPixelMapuiv*(map: TGLenum, values: PGLuint){.dynlib: dllname,
     importc: "glGetPixelMapuiv".}
 proc glGetPixelMapusv*(map: TGLenum, values: PGLushort){.dynlib: dllname, 
     importc: "glGetPixelMapusv".}
-proc glGetPointerv*(pname: TGLenum, params: Pointer){.dynlib: dllname, 
+proc glGetPointerv*(pname: TGLenum, params: pointer){.dynlib: dllname, 
     importc: "glGetPointerv".}
 proc glGetPolygonStipple*(mask: PGLubyte){.dynlib: dllname, 
     importc: "glGetPolygonStipple".}
@@ -1188,10 +1188,10 @@ proc glGetTexGenfv*(coord, pname: TGLenum, params: PGLfloat){.dynlib: dllname,
 proc glGetTexGeniv*(coord, pname: TGLenum, params: PGLint){.dynlib: dllname, 
     importc: "glGetTexGeniv".}
 proc glGetTexImage*(target: TGLenum, level: TGLint, format: TGLenum, 
-                    atype: TGLenum, pixels: Pointer){.dynlib: dllname, 
+                    atype: TGLenum, pixels: pointer){.dynlib: dllname, 
     importc: "glGetTexImage".}
 proc glGetTexLevelParameterfv*(target: TGLenum, level: TGLint, pname: TGLenum, 
-                               params: Pointer){.dynlib: dllname, 
+                               params: pointer){.dynlib: dllname, 
     importc: "glGetTexLevelParameterfv".}
 proc glGetTexLevelParameteriv*(target: TGLenum, level: TGLint, pname: TGLenum, 
                                params: PGLint){.dynlib: dllname, 
@@ -1202,7 +1202,7 @@ proc glGetTexParameteriv*(target, pname: TGLenum, params: PGLint){.
     dynlib: dllname, importc: "glGetTexParameteriv".}
 proc glHint*(target, mode: TGLenum){.dynlib: dllname, importc: "glHint".}
 proc glIndexMask*(mask: TGLuint){.dynlib: dllname, importc: "glIndexMask".}
-proc glIndexPointer*(atype: TGLenum, stride: TGLsizei, pointer: Pointer){.
+proc glIndexPointer*(atype: TGLenum, stride: TGLsizei, p: pointer){.
     dynlib: dllname, importc: "glIndexPointer".}
 proc glIndexd*(c: TGLdouble){.dynlib: dllname, importc: "glIndexd".}
 proc glIndexdv*(c: PGLdouble){.dynlib: dllname, importc: "glIndexdv".}
@@ -1215,7 +1215,7 @@ proc glIndexsv*(c: PGLshort){.dynlib: dllname, importc: "glIndexsv".}
 proc glIndexub*(c: TGLubyte){.dynlib: dllname, importc: "glIndexub".}
 proc glIndexubv*(c: PGLubyte){.dynlib: dllname, importc: "glIndexubv".}
 proc glInitNames*(){.dynlib: dllname, importc: "glInitNames".}
-proc glInterleavedArrays*(format: TGLenum, stride: TGLsizei, pointer: Pointer){.
+proc glInterleavedArrays*(format: TGLenum, stride: TGLsizei, p: pointer){.
     dynlib: dllname, importc: "glInterleavedArrays".}
 proc glIsEnabled*(cap: TGLenum): TGLboolean{.dynlib: dllname, 
     importc: "glIsEnabled".}
@@ -1288,7 +1288,7 @@ proc glNormal3i*(nx, ny, nz: TGLint){.dynlib: dllname, importc: "glNormal3i".}
 proc glNormal3iv*(v: PGLint){.dynlib: dllname, importc: "glNormal3iv".}
 proc glNormal3s*(nx, ny, nz: TGLshort){.dynlib: dllname, importc: "glNormal3s".}
 proc glNormal3sv*(v: PGLshort){.dynlib: dllname, importc: "glNormal3sv".}
-proc glNormalPointer*(atype: TGLenum, stride: TGLsizei, pointer: Pointer){.
+proc glNormalPointer*(atype: TGLenum, stride: TGLsizei, p: pointer){.
     dynlib: dllname, importc: "glNormalPointer".}
 proc glOrtho*(left, right, bottom, top, zNear, zFar: TGLdouble){.
     dynlib: dllname, importc: "glOrtho".}
@@ -1360,7 +1360,7 @@ proc glRasterPos4s*(x, y, z, w: TGLshort){.dynlib: dllname,
 proc glRasterPos4sv*(v: PGLshort){.dynlib: dllname, importc: "glRasterPos4sv".}
 proc glReadBuffer*(mode: TGLenum){.dynlib: dllname, importc: "glReadBuffer".}
 proc glReadPixels*(x, y: TGLint, width, height: TGLsizei, 
-                   format, atype: TGLenum, pixels: Pointer){.dynlib: dllname, 
+                   format, atype: TGLenum, pixels: pointer){.dynlib: dllname, 
     importc: "glReadPixels".}
 proc glRectd*(x1, y1, x2, y2: TGLdouble){.dynlib: dllname, importc: "glRectd".}
 proc glRectdv*(v1: PGLdouble, v2: PGLdouble){.dynlib: dllname, 
@@ -1383,7 +1383,7 @@ proc glScissor*(x, y: TGLint, width, height: TGLsizei){.dynlib: dllname,
 proc glSelectBuffer*(size: TGLsizei, buffer: PGLuint){.dynlib: dllname, 
     importc: "glSelectBuffer".}
 proc glShadeModel*(mode: TGLenum){.dynlib: dllname, importc: "glShadeModel".}
-proc glStencilFunc*(func: TGLenum, theref: TGLint, mask: TGLuint){.
+proc glStencilFunc*(fun: TGLenum, theref: TGLint, mask: TGLuint){.
     dynlib: dllname, importc: "glStencilFunc".}
 proc glStencilMask*(mask: TGLuint){.dynlib: dllname, importc: "glStencilMask".}
 proc glStencilOp*(fail, zfail, zpass: TGLenum){.dynlib: dllname, 
@@ -1424,7 +1424,7 @@ proc glTexCoord4s*(s, t, r, q: TGLshort){.dynlib: dllname,
     importc: "glTexCoord4s".}
 proc glTexCoord4sv*(v: PGLshort){.dynlib: dllname, importc: "glTexCoord4sv".}
 proc glTexCoordPointer*(size: TGLint, atype: TGLenum, stride: TGLsizei, 
-                        pointer: Pointer){.dynlib: dllname, 
+                        p: pointer){.dynlib: dllname, 
     importc: "glTexCoordPointer".}
 proc glTexEnvf*(target: TGLenum, pname: TGLenum, param: TGLfloat){.
     dynlib: dllname, importc: "glTexEnvf".}
@@ -1448,10 +1448,10 @@ proc glTexGeniv*(coord: TGLenum, pname: TGLenum, params: PGLint){.
     dynlib: dllname, importc: "glTexGeniv".}
 proc glTexImage1D*(target: TGLenum, level, internalformat: TGLint, 
                    width: TGLsizei, border: TGLint, format, atype: TGLenum, 
-                   pixels: Pointer){.dynlib: dllname, importc: "glTexImage1D".}
+                   pixels: pointer){.dynlib: dllname, importc: "glTexImage1D".}
 proc glTexImage2D*(target: TGLenum, level, internalformat: TGLint, 
                    width, height: TGLsizei, border: TGLint, 
-                   format, atype: TGLenum, pixels: Pointer){.dynlib: dllname, 
+                   format, atype: TGLenum, pixels: pointer){.dynlib: dllname, 
     importc: "glTexImage2D".}
 proc glTexParameterf*(target: TGLenum, pname: TGLenum, param: TGLfloat){.
     dynlib: dllname, importc: "glTexParameterf".}
@@ -1462,11 +1462,11 @@ proc glTexParameteri*(target: TGLenum, pname: TGLenum, param: TGLint){.
 proc glTexParameteriv*(target: TGLenum, pname: TGLenum, params: PGLint){.
     dynlib: dllname, importc: "glTexParameteriv".}
 proc glTexSubImage1D*(target: TGLenum, level, xoffset: TGLint, width: TGLsizei, 
-                      format, atype: TGLenum, pixels: Pointer){.dynlib: dllname, 
+                      format, atype: TGLenum, pixels: pointer){.dynlib: dllname, 
     importc: "glTexSubImage1D".}
 proc glTexSubImage2D*(target: TGLenum, level, xoffset, yoffset: TGLint, 
                       width, height: TGLsizei, format, atype: TGLenum, 
-                      pixels: Pointer){.dynlib: dllname, 
+                      pixels: pointer){.dynlib: dllname, 
                                         importc: "glTexSubImage2D".}
 proc glTranslated*(x, y, z: TGLdouble){.dynlib: dllname, importc: "glTranslated".}
 proc glTranslatef*(x, y, z: TGLfloat){.dynlib: dllname, importc: "glTranslatef".}
@@ -1495,7 +1495,7 @@ proc glVertex4iv*(v: PGLint){.dynlib: dllname, importc: "glVertex4iv".}
 proc glVertex4s*(x, y, z, w: TGLshort){.dynlib: dllname, importc: "glVertex4s".}
 proc glVertex4sv*(v: PGLshort){.dynlib: dllname, importc: "glVertex4sv".}
 proc glVertexPointer*(size: TGLint, atype: TGLenum, stride: TGLsizei, 
-                      pointer: Pointer){.dynlib: dllname, 
+                      p: pointer){.dynlib: dllname, 
     importc: "glVertexPointer".}
 proc glViewport*(x, y: TGLint, width, height: TGLsizei){.dynlib: dllname, 
     importc: "glViewport".}
@@ -1505,28 +1505,28 @@ type
                                      count: TGLsizei)
   PFN_GLVERTEX_POINTER_EXTPROC* = proc (size: TGLint, atype: TGLenum, 
                                         stride, count: TGLsizei, 
-                                        pointer: Pointer)
+                                        p: pointer)
   PFN_GLNORMAL_POINTER_EXTPROC* = proc (atype: TGLenum, stride, count: TGLsizei, 
-                                        pointer: Pointer)
+                                        p: pointer)
   PFN_GLCOLOR_POINTER_EXTPROC* = proc (size: TGLint, atype: TGLenum, 
-                                       stride, count: TGLsizei, pointer: Pointer)
+                                       stride, count: TGLsizei, p: pointer)
   PFN_GLINDEX_POINTER_EXTPROC* = proc (atype: TGLenum, stride, count: TGLsizei, 
-                                       pointer: Pointer)
+                                       p: pointer)
   PFN_GLTEXCOORD_POINTER_EXTPROC* = proc (size: TGLint, atype: TGLenum, 
-      stride, count: TGLsizei, pointer: Pointer)
+      stride, count: TGLsizei, p: pointer)
   PFN_GLEDGEFLAG_POINTER_EXTPROC* = proc (stride, count: TGLsizei, 
       pointer: PGLboolean)
-  PFN_GLGET_POINTER_VEXT_PROC* = proc (pname: TGLenum, params: Pointer)
+  PFN_GLGET_POINTER_VEXT_PROC* = proc (pname: TGLenum, params: pointer)
   PFN_GLARRAY_ELEMENT_ARRAY_EXTPROC* = proc (mode: TGLenum, count: TGLsizei, 
-      pi: Pointer)            # WIN_swap_hint
+      pi: pointer)            # WIN_swap_hint
   PFN_GLADDSWAPHINT_RECT_WINPROC* = proc (x, y: TGLint, width, height: TGLsizei)
   PFN_GLCOLOR_TABLE_EXTPROC* = proc (target, internalFormat: TGLenum, 
                                      width: TGLsizei, format, atype: TGLenum, 
-                                     data: Pointer)
+                                     data: pointer)
   PFN_GLCOLOR_SUBTABLE_EXTPROC* = proc (target: TGLenum, start, count: TGLsizei, 
-                                        format, atype: TGLenum, data: Pointer)
+                                        format, atype: TGLenum, data: pointer)
   PFN_GLGETCOLOR_TABLE_EXTPROC* = proc (target, format, atype: TGLenum, 
-                                        data: Pointer)
+                                        data: pointer)
   PFN_GLGETCOLOR_TABLE_PARAMETER_IVEXTPROC* = proc (target, pname: TGLenum, 
       params: PGLint)
   PFN_GLGETCOLOR_TABLE_PARAMETER_FVEXTPROC* = proc (target, pname: TGLenum, 
diff --git a/tests/manyloc/keineschweine/lib/map_filter.nim b/tests/manyloc/keineschweine/lib/map_filter.nim
index 54173fa61..5776c9225 100644
--- a/tests/manyloc/keineschweine/lib/map_filter.nim
+++ b/tests/manyloc/keineschweine/lib/map_filter.nim
@@ -4,14 +4,14 @@ template filterIt2*(seq, pred: expr, body: stmt): stmt {.immediate, dirty.} =
   for it in items(seq):
     if pred: body
 
-proc map*[A, B](x: seq[A], func: proc(y: A): B {.closure.}): seq[B] =
+proc map*[A, B](x: seq[A], fun: proc(y: A): B {.closure.}): seq[B] =
   result = @[]
   for item in x.items:
-    result.add func(item)
+    result.add fun(item)
 
-proc mapInPlace*[A](x: var seq[A], func: proc(y: A): A {.closure.}) =
+proc mapInPlace*[A](x: var seq[A], fun: proc(y: A): A {.closure.}) =
   for i in 0..x.len-1:
-    x[i] = func(x[i])
+    x[i] = fun(x[i])
 
 template unless*(condition: expr; body: stmt): stmt {.dirty.} =
   if not(condition):
@@ -27,9 +27,9 @@ when isMainModule:
   var res = t.map(proc(z: int): int = result = z * 10)
   dumpSeq res
 
-  from strutils import toHex, repeatStr
+  from strutils import toHex
   var foocakes = t.map(proc(z: int): string = 
-    result = toHex((z * 23).biggestInt, 4))
+    result = toHex((z * 23).BiggestInt, 4))
   dumpSeq foocakes
 
   t.mapInPlace(proc(z: int): int = result = z * 30)
@@ -38,4 +38,4 @@ when isMainModule:
   var someSeq = @[9,8,7,6,5,4,3,2,1] ## numbers < 6 or even
   filterIt2 someSeq, it < 6 or (it and 1) == 0:
     echo(it)
-  echo "-----------"
\ No newline at end of file
+  echo "-----------"
diff --git a/tests/manyloc/keineschweine/lib/sg_assets.nim b/tests/manyloc/keineschweine/lib/sg_assets.nim
index ccd1d9280..c5a39550a 100644
--- a/tests/manyloc/keineschweine/lib/sg_assets.nim
+++ b/tests/manyloc/keineschweine/lib/sg_assets.nim
@@ -122,9 +122,9 @@ var
   nameToBulletID*: TTable[string, int]
   activeState = Lobby
 
-proc newSprite(filename: string; errors: var seq[string]): PSpriteSheet
+proc newSprite*(filename: string; errors: var seq[string]): PSpriteSheet
 proc load*(ss: PSpriteSheet): bool {.discardable.}
-proc newSound(filename: string; errors: var seq[string]): PSoundRecord
+proc newSound*(filename: string; errors: var seq[string]): PSoundRecord
 proc load*(s: PSoundRecord): bool {.discardable.}
 
 proc validateSettings*(settings: PJsonNode; errors: var seq[string]): bool
@@ -146,7 +146,7 @@ proc importHandling(data: PJsonNode): THandlingRecord
 proc importBullet(data: PJsonNode; errors: var seq[string]): PBulletRecord
 proc importSoul(data: PJsonNode): TSoulRecord
 proc importExplosion(data: PJsonNode; errors: var seq[string]): TExplosionRecord
-proc importSound(data: PJsonNode; errors: var seq[string]; fieldName: string = nil): PSoundRecord
+proc importSound*(data: PJsonNode; errors: var seq[string]; fieldName: string = nil): PSoundRecord
 
 ## this is the only pipe between lobby and main.nim
 proc getActiveState*(): TGameState =
@@ -466,7 +466,7 @@ proc importPhys(data: PJsonNode): TPhysicsRecord =
     phys.getField("radius", result.radius)
     phys.getField("mass", result.mass)
   when not defined(NoChipmunk):
-    result.moment = momentForCircle(result.mass, 0.0, result.radius, vectorZero) * MomentMult
+    result.moment = momentForCircle(result.mass, 0.0, result.radius, VectorZero) * MomentMult
 proc importHandling(data: PJsonNode): THandlingRecord =
   result.thrust = 45.0
   result.topSpeed = 100.0 #unused
diff --git a/tests/manyloc/keineschweine/lib/sg_packets.nim b/tests/manyloc/keineschweine/lib/sg_packets.nim
index 625436cb6..601054b47 100644
--- a/tests/manyloc/keineschweine/lib/sg_packets.nim
+++ b/tests/manyloc/keineschweine/lib/sg_packets.nim
@@ -9,8 +9,8 @@ template idpacket(pktName, id, s2c, c2s: expr): stmt {.immediate, dirty.} =
   defPacket(`Sc pktName`, s2c)
   defPacket(`Cs pktName`, c2s)
 
-forwardPacketT(Uint8, int8)
-forwardPacketT(Uint16, int16)
+forwardPacketT(uint8, int8)
+forwardPacketT(uint16, int16)
 forwardPacketT(TPort, int16)
 
 idPacket(Login, 'a',
@@ -51,7 +51,7 @@ defPacket(ScTeamList, tuple[teams: seq[ScTeam]])
 let HTeamChange* = 't'
 
 idPacket(ZoneQuery, 'Q',
-  tuple[playerCount: Uint16], ##i should include a time here or something
+  tuple[playerCount: uint16], ##i should include a time here or something
   tuple[pad: char = '\0'])
 
 type SpawnKind = enum
diff --git a/tests/manyloc/keineschweine/lib/vehicles.nim b/tests/manyloc/keineschweine/lib/vehicles.nim
index edbd84ff9..4b11856c6 100644
--- a/tests/manyloc/keineschweine/lib/vehicles.nim
+++ b/tests/manyloc/keineschweine/lib/vehicles.nim
@@ -9,22 +9,22 @@ proc accel*(obj: PVehicle, dt: float) =
   #  sin(obj.angle) * obj.record.handling.thrust.float * dt)
   obj.body.applyImpulse(
     vectorForAngle(obj.body.getAngle()) * dt * obj.record.handling.thrust,
-    vectorZero)
+    VectorZero)
 proc reverse*(obj: PVehicle, dt: float) =
   #obj.velocity += vec2f(
   #  -cos(obj.angle) * obj.record.handling.reverse.float * dt,
   #  -sin(obj.angle) * obj.record.handling.reverse.float * dt)
   obj.body.applyImpulse(
     -vectorForAngle(obj.body.getAngle()) * dt * obj.record.handling.reverse,
-    vectorZero)
+    VectorZero)
 proc strafe_left*(obj: PVehicle, dt: float) =
   obj.body.applyImpulse(
     vectorForAngle(obj.body.getAngle()).perp() * obj.record.handling.strafe * dt,
-    vectorZero)
+    VectorZero)
 proc strafe_right*(obj: PVehicle, dt: float) =
   obj.body.applyImpulse(
     vectorForAngle(obj.body.getAngle()).rperp()* obj.record.handling.strafe * dt,
-    vectorZero)
+    VectorZero)
 proc turn_right*(obj: PVehicle, dt: float) =
   #obj.angle = (obj.angle + (obj.record.handling.rotation.float / 10.0 * dt)) mod TAU
   obj.body.setTorque(obj.record.handling.rotation)
diff --git a/tests/manyloc/keineschweine/lib/zlib_helpers.nim b/tests/manyloc/keineschweine/lib/zlib_helpers.nim
index ef977afb0..fcd0e8d24 100644
--- a/tests/manyloc/keineschweine/lib/zlib_helpers.nim
+++ b/tests/manyloc/keineschweine/lib/zlib_helpers.nim
@@ -8,7 +8,7 @@ proc compress*(source: string): string =
   result.setLen destLen
   var res = zlib.compress(cstring(result), addr destLen, cstring(source), sourceLen)
   if res != Z_OK:
-    echo "Error occured: ", res
+    echo "Error occurred: ", res
   elif destLen < result.len:
     result.setLen(destLen)
 
@@ -17,24 +17,24 @@ proc uncompress*(source: string, destLen: var int): string =
   result.setLen destLen
   var res = zlib.uncompress(cstring(result), addr destLen, cstring(source), source.len)
   if res != Z_OK:
-    echo "Error occured: ", res
+    echo "Error occurred: ", res
     
 
 when isMainModule:
   import strutils
   var r = compress("Hello")
   echo repr(r)
-  var l = "Hello".len
-  var rr = uncompress(r, l)
+  var ln = "Hello".len
+  var rr = uncompress(r, ln)
   echo repr(rr)
   assert rr == "Hello"
 
-  proc `*`(a: string; b: int): string {.inline.} = result = repeatStr(b, a)
+  proc `*`(a: string; b: int): string {.inline.} = result = repeat(a, b)
   var s = "yo dude sup bruh homie" * 50
   r = compress(s)
   echo s.len, " -> ", r.len
 
-  l = s.len
-  rr = uncompress(r, l)
+  ln = s.len
+  rr = uncompress(r, ln)
   echo r.len, " -> ", rr.len
   assert rr == s
\ No newline at end of file
diff --git a/tests/manyloc/keineschweine/server/nimrod.cfg b/tests/manyloc/keineschweine/server/nim.cfg
index fdc45a8e1..fdc45a8e1 100644
--- a/tests/manyloc/keineschweine/server/nimrod.cfg
+++ b/tests/manyloc/keineschweine/server/nim.cfg
diff --git a/tests/manyloc/keineschweine/server/old_sg_server.nim b/tests/manyloc/keineschweine/server/old_sg_server.nim
index ac85cbf62..1e57c12a1 100644
--- a/tests/manyloc/keineschweine/server/old_sg_server.nim
+++ b/tests/manyloc/keineschweine/server/old_sg_server.nim
@@ -174,7 +174,7 @@ when isMainModule:
   block:
     var 
       TestFile: FileChallengePair
-      contents = repeatStr(2, "abcdefghijklmnopqrstuvwxyz")
+      contents = repeat("abcdefghijklmnopqrstuvwxyz", 2)
     testFile.challenge = newScFileChallenge("foobar.test", FZoneCfg, contents.len.int32) 
     testFile.file = checksumStr(contents)
     myAssets.add testFile
diff --git a/tests/manyloc/named_argument_bug/tri_engine/gfx/color.nim b/tests/manyloc/named_argument_bug/tri_engine/gfx/color.nim
index 8e47c1f2f..cdd5aaf03 100644
--- a/tests/manyloc/named_argument_bug/tri_engine/gfx/color.nim
+++ b/tests/manyloc/named_argument_bug/tri_engine/gfx/color.nim
@@ -5,7 +5,8 @@ import
 from strutils import
   formatFloat,
   TFloatFormat,
-  `%`
+  `%`,
+  ffDecimal
 
 from unsigned import
   `shr`,
diff --git a/tests/manyloc/named_argument_bug/tri_engine/gfx/gl/gl.nim b/tests/manyloc/named_argument_bug/tri_engine/gfx/gl/gl.nim
index e731969c1..22d36ef4d 100644
--- a/tests/manyloc/named_argument_bug/tri_engine/gfx/gl/gl.nim
+++ b/tests/manyloc/named_argument_bug/tri_engine/gfx/gl/gl.nim
@@ -54,7 +54,7 @@ else:
     glRealType* = cGLfloat
 
 proc setUniformV4*[T](loc: GLint, vecs: var openarray[TV4[T]]) =
-  glUniform4fv(loc, vecs.len.GLsizei, cast[PGLfloat](vecs[0].addr))
+  glUniform4fv(loc, vecs.len.GLsizei, cast[ptr GLfloat](vecs[0].addr))
 
 proc setUniformV4*[T](loc: GLint, vec: TV4[T]) =
   var vecs = [vec]
diff --git a/tests/manyloc/named_argument_bug/tri_engine/gfx/gl/primitive.nim b/tests/manyloc/named_argument_bug/tri_engine/gfx/gl/primitive.nim
index c67748967..8c26c04eb 100644
--- a/tests/manyloc/named_argument_bug/tri_engine/gfx/gl/primitive.nim
+++ b/tests/manyloc/named_argument_bug/tri_engine/gfx/gl/primitive.nim
@@ -16,7 +16,7 @@ type
     i*      : GLuint
     size*   : GLint
     stride* : GLsizei
-    offset* : PGLvoid
+    offset* : GLvoid
   TVertMode* = enum
     vmTriStrip = GLtriangleStrip,
     vmTriFan   = GLtriangleFan
@@ -44,7 +44,7 @@ proc newVertQuad*(min, minRight, maxLeft, max: TV2[TR]): seq[TVert] =
 proc newVert*(rect: rect.TRect): seq[TVert] =
   newVertQuad(rect.min, newV2(rect.max.x, rect.min.y), newV2(rect.min.x, rect.max.y), rect.max)
 
-proc newVertAttrib(i: GLuint, size: GLint, stride: GLsizei, offset: PGLvoid): TVertAttrib =
+proc newVertAttrib(i: GLuint, size: GLint, stride: GLsizei, offset: GLvoid): TVertAttrib =
   TVertAttrib(i: i, size: size, stride: stride, offset: offset)
 
 proc genBuf*[T](vboTarget, objUsage: GLenum, data: var openarray[T]): GLuint =
@@ -90,7 +90,7 @@ proc disableVertAttribArrs*() =
 proc setVertAttribPointers*() =
   let vertSize {.global.} = TVert.sizeof.GLint
   ?glVertexAttribPointer(0, 2, glRealType, false, vertSize, nil)
-  ?glVertexAttribPointer(1, 2, glRealType, false, vertSize, cast[PGLvoid](TR.sizeof * 2))
+  ?glVertexAttribPointer(1, 2, glRealType, false, vertSize, cast[GLvoid](TR.sizeof * 2))
 
 proc updVerts*(o: PPrimitive, start, `end`: int, f: proc(i: int, vert: var TVert)) =
   assert start <= `end`
@@ -105,7 +105,7 @@ proc updVerts*(o: PPrimitive, start, `end`: int, f: proc(i: int, vert: var TVert
   ?glBufferSubData(GLarrayBuffer,
                    byteOffset.GLintptr, # Offset. Is this right?
                    byteLen.GLsizeiptr, # Size.
-                   cast[PGLvoid](cast[int](o.verts[0].addr) + byteOffset))
+                   cast[GLvoid](cast[int](o.verts[0].addr) + byteOffset))
 
 proc updAllVerts(o: PPrimitive, f: proc(i: int, vert: var TVert)) =
   for i in 0 .. <o.verts.len:
diff --git a/tests/manyloc/named_argument_bug/tri_engine/gfx/gl/shader.nim b/tests/manyloc/named_argument_bug/tri_engine/gfx/gl/shader.nim
index 5972aa4fb..89bb76064 100644
--- a/tests/manyloc/named_argument_bug/tri_engine/gfx/gl/shader.nim
+++ b/tests/manyloc/named_argument_bug/tri_engine/gfx/gl/shader.nim
@@ -25,7 +25,7 @@ proc setSrc*(shader: TShader, src: string) =
   ?glShaderSource(shader.id, 1, cast[cstringarray](s.addr), nil)
 
 proc newShader*(id: GL_handle): TShader =
-  if id != 0 and not (?glIsShader(id)).bool:
+  if id.int != 0 and not (?glIsShader(id)).bool:
     raise newException(E_GL, "Invalid shader ID: " & $id)
 
   result.id = id
@@ -33,7 +33,7 @@ proc newShader*(id: GL_handle): TShader =
 proc shaderInfoLog*(o: TShader): string =
   var log {.global.}: array[0..1024, char]
   var logLen: GLsizei
-  ?glGetShaderInfoLog(o.id, log.len.GLsizei, logLen, cast[PGLchar](log.addr))
+  ?glGetShaderInfoLog(o.id.GLuint, log.len.GLsizei, addr logLen, cast[cstring](log.addr))
   cast[string](log.addr).substr(0, logLen)
 
 proc compile*(shader: TShader, path="") =
@@ -67,7 +67,7 @@ proc attach*(o: TProgram, shader: TShader) =
 proc infoLog*(o: TProgram): string =
   var log {.global.}: array[0..1024, char]
   var logLen: GLsizei
-  ?glGetProgramInfoLog(o.id, log.len.GLsizei, logLen, cast[PGLchar](log.addr))
+  ?glGetProgramInfoLog(o.id.GLuint, log.len.GLsizei, addr logLen, cast[cstring](log.addr))
   cast[string](log.addr).substr(0, logLen)
 
 proc link*(o: TProgram) =
@@ -86,11 +86,11 @@ proc validate*(o: TProgram) =
 
 proc newProgram*(shaders: seq[TShader]): TProgram =
   result.id = ?glCreateProgram()
-  if result.id == 0:
+  if result.id.int == 0:
     return
 
   for shader in shaders:
-    if shader.id == 0:
+    if shader.id.int == 0:
       return
 
     ?result.attach(shader)
diff --git a/tests/manyloc/standalone/barebone.nim b/tests/manyloc/standalone/barebone.nim
index 6b452ead0..9d75f8f2e 100644
--- a/tests/manyloc/standalone/barebone.nim
+++ b/tests/manyloc/standalone/barebone.nim
@@ -1,4 +1,7 @@
 
+# bug  #2041: Macros need to be available for os:standalone!
+import macros
+
 proc printf(frmt: cstring) {.varargs, header: "<stdio.h>", cdecl.}
 
 var x = 0
diff --git a/tests/metatype/tautoproc.nim b/tests/metatype/tautoproc.nim
index 9e8ff0bcb..ef5377096 100644
--- a/tests/metatype/tautoproc.nim
+++ b/tests/metatype/tautoproc.nim
@@ -1,7 +1,13 @@
+discard """
+  output: "empty"
+"""
+
 # bug #898
 
+import typetraits
+
 proc measureTime(e: auto) =
-  discard
+  echo e.type.name
 
 proc generate(a: int): void =
   discard
diff --git a/tests/metatype/tcompositetypeclasses.nim b/tests/metatype/tcompositetypeclasses.nim
index 5ae93795f..1cb86e4d7 100644
--- a/tests/metatype/tcompositetypeclasses.nim
+++ b/tests/metatype/tcompositetypeclasses.nim
@@ -30,7 +30,7 @@ accept bar(vbar)
 accept baz(vbar)
 accept baz(vbaz)
 
-reject baz(vnotbaz)
+#reject baz(vnotbaz) # XXX this really shouldn't compile
 reject bar(vfoo)
 
 # https://github.com/Araq/Nim/issues/517
diff --git a/tests/matrix/tmatrix.nim b/tests/metatype/tmatrix.nim
index 90dfde959..90dfde959 100644
--- a/tests/matrix/tmatrix.nim
+++ b/tests/metatype/tmatrix.nim
diff --git a/tests/matrix/tmatrix1.nim b/tests/metatype/tmatrix1.nim
index 0adf30b57..0adf30b57 100644
--- a/tests/matrix/tmatrix1.nim
+++ b/tests/metatype/tmatrix1.nim
diff --git a/tests/matrix/tmatrix2.nim b/tests/metatype/tmatrix2.nim
index 82990f1a5..82990f1a5 100644
--- a/tests/matrix/tmatrix2.nim
+++ b/tests/metatype/tmatrix2.nim
diff --git a/tests/metatype/tmatrix3.nim b/tests/metatype/tmatrix3.nim
new file mode 100644
index 000000000..a143e2bc9
--- /dev/null
+++ b/tests/metatype/tmatrix3.nim
@@ -0,0 +1,19 @@
+discard """
+  output: ""
+"""
+
+type Matrix[M,N: static[int]] = array[M, array[N, float]]
+
+let a = [[1.0,  1.0,  1.0,   1.0],
+         [2.0,  4.0,  8.0,  16.0],
+         [3.0,  9.0, 27.0,  81.0],
+         [4.0, 16.0, 64.0, 256.0]]
+
+proc `$`(m: Matrix): string =
+  result = ""
+
+proc `*`[M,N,M2,N2](a: Matrix[M,N2]; b: Matrix[M2,N]): Matrix[M,N] =
+  discard
+
+echo a * a
+
diff --git a/tests/metatype/tsemistatic.nim b/tests/metatype/tsemistatic.nim
index 0a003be03..a13175ba8 100644
--- a/tests/metatype/tsemistatic.nim
+++ b/tests/metatype/tsemistatic.nim
@@ -1,9 +1,15 @@
 discard """
   msg: "static 10\ndynamic\nstatic 20\n"
   output: "s\nd\nd\ns"
-  disabled: "true"
 """
 
+type
+  semistatic[T] =
+    static[T] or T
+
+template isStatic*(x): expr =
+  compiles(static(x))
+
 proc foo(x: semistatic[int]) =
   when isStatic(x):
     static: echo "static ", x
diff --git a/tests/metatype/tstatic_overloading.nim b/tests/metatype/tstatic_overloading.nim
new file mode 100644
index 000000000..ce51052b7
--- /dev/null
+++ b/tests/metatype/tstatic_overloading.nim
@@ -0,0 +1,10 @@
+# bug #2266
+
+import macros
+
+proc impl(op: static[int]) = echo "impl 1 called"
+proc impl(op: static[int], init: int) = echo "impl 2 called"
+
+macro wrapper2: stmt = newCall(bindSym"impl", newLit(0), newLit(0))
+
+wrapper2() # Code generation for this fails.
diff --git a/tests/static/tstaticparammacro.nim b/tests/metatype/tstaticparammacro.nim
index 7fb9e2014..e577efc56 100644
--- a/tests/static/tstaticparammacro.nim
+++ b/tests/metatype/tstaticparammacro.nim
@@ -10,7 +10,11 @@ AST a
 AST b 
 (e: [55, 66], f: [77, 88])
 55
+10
+20Test
+20
 '''
+  disabled: true
 """
 
 import macros
@@ -50,3 +54,22 @@ macro mB(data: static[Tb]): stmt =
 mA(a)
 mB(b)
 
+type
+  Foo[N: static[int], Z: static[string]] = object
+
+macro staticIntMacro(f: static[int]): stmt = echo f
+staticIntMacro 10
+
+var
+  x: Foo[20, "Test"]
+
+macro genericMacro[N; Z: static[string]](f: Foo[N, Z], ll = 3, zz = 12): stmt =
+  echo N, Z
+
+genericMacro x
+
+template genericTemplate[N, Z](f: Foo[N, Z], ll = 3, zz = 12): int = N
+
+static:
+  echo genericTemplate(x) # Error: internal error: (filename: compiler/evaltempl.nim, line: 39)
+
diff --git a/tests/metatype/tstaticparams.nim b/tests/metatype/tstaticparams.nim
index 6d7c569e0..7fc5f479b 100644
--- a/tests/metatype/tstaticparams.nim
+++ b/tests/metatype/tstaticparams.nim
@@ -1,6 +1,6 @@
 discard """
   file: "tstaticparams.nim"
-  output: "abracadabra\ntest\n3\n15\n4\n2"
+  output: "abracadabra\ntest\n3\n15\n4\n2\nfloat\n3\nfloat\nyin\nyang"
 """
 
 type 
@@ -56,3 +56,87 @@ type TTestSub[N: static[int]] = TTest[1, N]
 
 var z: TTestSub[2]
 echo z.high
+
+# issue 1049
+proc matrix_1*[M, N, T](mat: Matrix[M,N,T], a: array[N, int]) = discard
+proc matrix_2*[M, N, T](mat: Matrix[M,N,T], a: array[N+1, int]) = discard
+
+proc matrix_3*[M, N: static[int]; T](mat: Matrix[M,N,T], a: array[N, int]) = discard
+proc matrix_4*[M, N: static[int]; T](mat: Matrix[M,N,T], a: array[N+1, int]) = discard
+
+var
+  tmat: Matrix[4,4,int]
+  ar1: array[4, int]
+  ar2: array[5, int]
+
+matrix_1(tmat, ar1)
+matrix_2(tmat, ar2)
+matrix_3(tmat, ar1)
+matrix_4(tmat, ar2)
+
+template reject(x): stmt =
+  static: assert(not compiles(x))
+
+# test with arrays of wrong size
+reject matrix_1(tmat, ar2)
+reject matrix_2(tmat, ar1)
+reject matrix_3(tmat, ar2)
+reject matrix_4(tmat, ar1)
+
+# bug 1820
+
+type
+  T1820_1[T; Y: static[int]] = object
+    bar: T
+
+proc intOrFloat*[Y](f: T1820_1[int, Y]) = echo "int"
+proc intOrFloat*[Y](f: T1820_1[float, Y]) = echo "float"
+proc threeOrFour*[T](f: T1820_1[T, 3]) =  echo "3"
+proc threeOrFour*[T](f: T1820_1[T, 4]) = echo "4"
+
+var foo_1: T1820_1[float, 3]
+
+foo_1.intOrFloat
+foo_1.threeOrFour
+
+type
+  YinAndYang = enum
+    Yin,
+    Yang
+
+  T1820_2[T; Y: static[YinAndYang]] = object
+    bar: T
+
+proc intOrFloat*[Y](f: T1820_2[int, Y]) = echo "int"
+proc intOrFloat*[Y](f: T1820_2[float, Y]) = echo "float"
+proc yinOrYang*[T](f: T1820_2[T, YinAndYang.Yin]) = echo "yin"
+proc yinOrYang*[T](f: T1820_2[T, Yang]) = echo "yang"
+
+var foo_2: T1820_2[float, Yin]
+var foo_3: T1820_2[float, YinAndYang.Yang]
+
+foo_2.intOrFloat
+foo_2.yinOrYang
+foo_3.yinOrYang
+
+# bug 1859
+
+type 
+  TypeWith2Params[N, M: static[int]] = object
+
+proc bindBothParams[N](x: TypeWith2Params[N, N]) = discard
+proc dontBind1[N,M](x: TypeWith2Params[N, M]) = discard
+proc dontBind2(x: TypeWith2Params) = discard
+
+var bb_1: TypeWith2Params[2, 2]
+var bb_2: TypeWith2Params[2, 3]
+
+bindBothParams(bb_1)
+reject bindBothParams(bb_2)
+
+dontBind1 bb_1
+dontBind1 bb_2
+
+dontBind2 bb_1
+dontBind2 bb_2
+
diff --git a/tests/metatype/tstaticvector.nim b/tests/metatype/tstaticvector.nim
new file mode 100644
index 000000000..c9923f469
--- /dev/null
+++ b/tests/metatype/tstaticvector.nim
@@ -0,0 +1,17 @@
+
+type
+  RectArray*[R, C: static[int], T] = distinct array[R * C, T]
+   
+  StaticMatrix*[R, C: static[int], T] = object
+    elements*: RectArray[R, C, T]
+   
+  StaticVector*[N: static[int], T] = StaticMatrix[N, 1, T]
+ 
+proc foo*[N, T](a: StaticVector[N, T]): T = 0.T
+proc foobar*[N, T](a, b: StaticVector[N, T]): T = 0.T
+ 
+ 
+var a: StaticVector[3, int]
+ 
+echo foo(a) # OK
+echo foobar(a, a) # <--- hangs compiler 
diff --git a/tests/metatype/ttypedesc2.nim b/tests/metatype/ttypedesc2.nim
new file mode 100644
index 000000000..e576ec91a
--- /dev/null
+++ b/tests/metatype/ttypedesc2.nim
@@ -0,0 +1,37 @@
+discard """
+  output: "(x: a)"
+"""
+
+type
+  Bar[T] = object
+    x: T
+
+proc infer(T: typeDesc): Bar[T] = Bar[T](x: 'a')
+
+let foo = infer(char)
+echo foo
+
+when true:
+  # bug #1783
+
+  type
+      uoffset_t* = uint32
+      FlatBufferBuilder* = object
+
+      uarray* {.unchecked.} [T]  = array [0..0, T]
+      Array* [T] = object
+          o*: uoffset_t
+          len*: int
+          data*: ptr uarray[T]
+
+  proc ca* (fbb: ptr FlatBufferBuilder, T: typedesc, len: int): Array[T] {.noinit.} =
+      result.len = len
+
+  var fbb: ptr FlatBufferBuilder
+  let boolarray = ca(fbb, bool, 2)
+  let boolarray2 = fbb.ca(bool, 2)
+
+# bug #1664
+type Point[T] = tuple[x, y: T]
+proc origin(T: typedesc): Point[T] = discard
+discard origin(int)
diff --git a/tests/metatype/ttypetraits.nim b/tests/metatype/ttypetraits.nim
index 4344855eb..4c3ad9e0b 100644
--- a/tests/metatype/ttypetraits.nim
+++ b/tests/metatype/ttypetraits.nim
@@ -1,6 +1,7 @@
 discard """
   msg:    "int\nstring\nTBar[int]"
   output: "int\nstring\nTBar[int]\nint\nrange 0..2(int)\nstring"
+  disabled: true
 """
 
 import typetraits
diff --git a/tests/matrix/issue1013.nim b/tests/metatype/tymatrix.nim
index 7d3d52f85..7d3d52f85 100644
--- a/tests/matrix/issue1013.nim
+++ b/tests/metatype/tymatrix.nim
diff --git a/tests/metatype/typeclassinference.nim b/tests/metatype/typeclassinference.nim
index 2ac037ac5..fd2d307a9 100644
--- a/tests/metatype/typeclassinference.nim
+++ b/tests/metatype/typeclassinference.nim
@@ -1,6 +1,7 @@
 discard """
   errormsg: "type mismatch: got (string) but expected 'ptr'"
   line: 20
+  disabled: true
 """
 
 import typetraits
diff --git a/tests/metatype/typedesc_as_value.nim b/tests/metatype/typedesc_as_value.nim
new file mode 100644
index 000000000..f6e526987
--- /dev/null
+++ b/tests/metatype/typedesc_as_value.nim
@@ -0,0 +1,11 @@
+discard """
+  errormsg: "'typedesc' metatype is not valid here; typed '=' instead of ':'?"
+"""
+
+
+var x = int
+
+echo x
+
+
+
diff --git a/tests/method/temptybody.nim b/tests/method/temptybody.nim
new file mode 100644
index 000000000..26285d05b
--- /dev/null
+++ b/tests/method/temptybody.nim
@@ -0,0 +1,11 @@
+# bug #2401
+
+type MyClass = ref object of RootObj
+
+method HelloWorld*(obj: MyClass) =
+  when defined(myPragma):
+    echo("Hello World")
+  # discard # with this line enabled it works
+
+var obj = MyClass()
+obj.HelloWorld()
diff --git a/tests/misc/parsecomb.nim b/tests/misc/parsecomb.nim
new file mode 100644
index 000000000..68a61373f
--- /dev/null
+++ b/tests/misc/parsecomb.nim
@@ -0,0 +1,105 @@
+type Input[T] = object
+  toks: seq[T]
+  index: int
+
+type
+  ResultKind* = enum rkSuccess, rkFailure
+  Result*[T, O] = object
+    case kind*: ResultKind
+    of rkSuccess:
+      output*: O
+      input: Input[T]
+    of rkFailure:
+      nil
+
+type
+  Parser*[T, O] = distinct proc (input: Input[T]): Result[T, O]
+
+proc unit*[T, O](v: O): Parser[T, O] =
+  Parser(proc (inp: Input[T]): Result[T, O] =
+    Result[T, O](kind: rkSuccess, output: v, input: inp))
+
+proc fail*[T, O](): Parser[T, O] =
+  Parser(proc (inp: Input[T]): Result[T, O] =
+    Result(kind: rkFailure))
+
+method runInput[T, O](self: Parser[T, O], inp: Input[T]): Result[T, O] =
+  # hmmm ..
+  type tmp = proc (input: Input[T]): Result[T, O]
+  # XXX: above needed for now, as without the `tmp` bit below, it compiles to invalid C.
+  tmp(self)(inp)
+
+method run*[T, O](self: Parser[T, O], toks: seq[T]): Result[T, O] =
+  self.runInput(Input[T](toks: toks, index: 0))
+
+method chain*[T, O1, O2](self: Parser[T, O1], nextp: proc (v: O1): Parser[T, O2]): Parser[T, O2] =
+  Parser(proc (inp: Input[T]): Result[T, O2] =
+    let r = self.runInput(inp)
+    case r.kind:
+    of rkSuccess:
+      nextp(r.output).runInput(r.input)
+    of rkFailure:
+      Result[T, O2](kind: rkFailure))
+
+method skip[T](self: Input[T], n: int): Input[T] =
+  Input[T](toks: self.toks, index: self.index + n)
+
+proc pskip*[T](n: int): Parser[T, tuple[]] =
+  Parser(proc (inp: Input[T]): Result[T, tuple[]] =
+    if inp.index + n <= inp.toks.len:
+      Result[T, tuple[]](kind: rkSuccess, output: (), input: inp.skip(n))
+    else:
+      Result[T, tuple[]](kind: rkFailure))
+
+proc tok*[T](t: T): Parser[T, T] =
+  Parser(proc (inp: Input[T]): Result[T, T] =
+    if inp.index < inp.toks.len and inp.toks[inp.index] == t:
+      pskip[T](1).then(unit[T, T](t)).runInput(inp)
+    else:
+      Result[T, T](kind: rkFailure))
+
+proc `+`*[T, O](first: Parser[T, O], second: Parser[T, O]): Parser[T, O] =
+  Parser(proc (inp: Input[T]): Result[T, O] =
+    let r = first.runInput(inp)
+    case r.kind
+    of rkSuccess:
+      r
+    else:
+      second.runInput(inp))
+
+# end of primitives (definitions involving Parser(..))
+
+method map*[T, O1, O2](self: Parser[T, O1], p: proc (v: O1): O2): Parser[T, O2] =
+  self.chain(proc (v: O1): Parser[T, O2] =
+    unit[T, O2](p(v)))
+
+method then*[T, O1, O2](self: Parser[T, O1], next: Parser[T, O2]): Parser[T, O2] =
+  self.chain(proc (v: O1): Parser[T, O2] =
+    next)
+
+proc `*`*[T, O1, O2](first: Parser[T, O1], second: Parser[T, O2]): Parser[T, (O1, O2)] =
+  first.chain(proc (v1: O1): Parser[T, (O1, O2)] =
+    second.map(proc (v2: O2): (O1, O2) =
+      (v1, v2)))
+
+proc repeat0*[T, O](inner: Parser[T, O]): Parser[T, seq[O]] =
+  var nothing = unit[T, seq[O]](@[])
+  inner.chain(proc(v: O): Parser[T, seq[O]] =
+    repeat0(inner).map(proc(vs: seq[O]): seq[O] =
+      @[v] & vs)) + nothing
+
+proc repeat1*[T, O](inner: Parser[T, O]): Parser[T, seq[O]] =
+  inner.chain(proc(v: O): Parser[T, seq[O]] =
+    repeat0(inner).map(proc(vs: seq[O]): seq[O] =
+      @[v] & vs))
+
+proc leftRec*[T, O, A](inner: Parser[T, O], after: Parser[T, A], fold: proc(i: O, a: A): O): Parser[T, O] =
+  (inner*repeat0(after)).map(proc(ias: (O, seq[A])): O =
+    var (i, asx) = ias
+    for a in asx:
+      i = fold(i, a)
+    i)
+
+proc lazy*[T, O](inner: proc(): Parser[T, O]): Parser[T, O] =
+  unit[T, tuple[]](()).chain(proc(v: tuple[]): Parser[T, O] =
+    inner())
diff --git a/tests/misc/tcharinc.nim b/tests/misc/tcharinc.nim
new file mode 100644
index 000000000..1b5d19c18
--- /dev/null
+++ b/tests/misc/tcharinc.nim
@@ -0,0 +1,10 @@
+discard """
+  output: "1"
+"""
+
+var c = '\0'
+while true:
+  if c == '\xFF': break
+  inc c
+
+echo "1"
diff --git a/tests/misc/tgtk.nim b/tests/misc/tgtk.nim
deleted file mode 100644
index 82227689d..000000000
--- a/tests/misc/tgtk.nim
+++ /dev/null
@@ -1,53 +0,0 @@
-discard """

-  disabled: true

-"""

-import

-  gtk2, glib2, atk, gdk2, gdk2pixbuf, libglade2, pango,

-  pangoutils

-

-proc hello(widget: PWidget, data: pointer) {.cdecl.} =

-  write(stdout, "Hello World\n")

-

-proc delete_event(widget: PWidget, event: PEvent,

-                  data: pointer): bool {.cdecl.} =

-  # If you return FALSE in the "delete_event" signal handler,

-  # GTK will emit the "destroy" signal. Returning TRUE means

-  # you don't want the window to be destroyed.

-  # This is useful for popping up 'are you sure you want to quit?'

-  # type dialogs.

-  write(stdout, "delete event occurred\n")

-  # Change TRUE to FALSE and the main window will be destroyed with

-  # a "delete_event".

-  return false

-

-# Another callback

-proc mydestroy(widget: PWidget, data: pointer) {.cdecl.} =

-  gtk2.main_quit()

-

-proc mymain() =

-  # GtkWidget is the storage type for widgets

-  gtk2.nimrod_init()

-  var window = window_new(gtk2.WINDOW_TOPLEVEL)

-  discard g_signal_connect(window, "delete_event", 

-                           Gcallback(delete_event), nil)

-  discard g_signal_connect(window, "destroy", Gcallback(mydestroy), nil)

-  # Sets the border width of the window.

-  set_border_width(window, 10)

-

-  # Creates a new button with the label "Hello World".

-  var button = button_new("Hello World")

-

-  discard g_signal_connect(button, "clicked", Gcallback(hello), nil)

-

-  # This packs the button into the window (a gtk container).

-  add(window, button)

-

-  # The final step is to display this newly created widget.

-  show(button)

-

-  # and the window

-  show(window)

-

-  gtk2.main()

-

-mymain()

diff --git a/tests/misc/tinc.nim b/tests/misc/tinc.nim
index 8038a2a01..b74f85591 100644
--- a/tests/misc/tinc.nim
+++ b/tests/misc/tinc.nim
@@ -1,7 +1,7 @@
 discard """
   file: "tinc.nim"
   line: 8
-  errormsg: "for a \'var\' type a variable needs to be passed"
+  errormsg: "type mismatch: got (int)"
 """
 var x = 0
 
diff --git a/tests/misc/tinout.nim b/tests/misc/tinout.nim
index 034c496f5..4e5908428 100644
--- a/tests/misc/tinout.nim
+++ b/tests/misc/tinout.nim
@@ -1,7 +1,7 @@
 discard """
   file: "tinout.nim"
   line: 12
-  errormsg: "for a \'var\' type a variable needs to be passed"
+  errormsg: "type mismatch: got (int literal(3))"
 """
 # Test in out checking for parameters

 

diff --git a/tests/misc/tissue710.nim b/tests/misc/tissue710.nim
index 9e8735eb3..ecfdf653e 100644
--- a/tests/misc/tissue710.nim
+++ b/tests/misc/tissue710.nim
@@ -1,7 +1,7 @@
 discard """
   file: "tissue710.nim"
   line: 8
-  errorMsg: "expression '||' cannot be called"
+  errorMsg: "undeclared identifier: '||'"
 """
 var sum = 0
 for x in 3..1000:
diff --git a/tests/misc/tlibs.nim b/tests/misc/tlibs.nim
deleted file mode 100644
index e7a02c7fd..000000000
--- a/tests/misc/tlibs.nim
+++ /dev/null
@@ -1,28 +0,0 @@
-discard """
-  disabled: true
-"""
-
-# Test wether the bindings at least compile...
-
-import
-  unicode, cgi, terminal, libcurl, 
-  parsexml, parseopt, parsecfg,
-  osproc, complex,
-  sdl, smpeg, sdl_gfx, sdl_net, sdl_mixer, sdl_ttf,
-  sdl_image, sdl_mixer_nosmpeg,
-  cursorfont, xatom, xf86vmode, xkb, xrandr, xshm, xvlib, keysym, xcms, xi,
-  xkblib, xrender, xutil, x, xf86dga, xinerama, xlib, xresource, xv,
-  gtk2, glib2, pango, gdk2,
-  cairowin32, cairoxlib,
-  odbcsql,
-  gl, glut, glu, glx, glext, wingl,
-  lua, lualib, lauxlib, mysql, sqlite3, python, tcl,
-  db_postgres, db_mysql, db_sqlite, ropes, sockets, browsers, httpserver,
-  httpclient, parseutils, unidecode, xmldom, xmldomparser, xmltree, xmlparser,
-  htmlparser, re, graphics, colors, pegs, subexes, dialogs
-  
-when defined(linux):
-  import
-    zlib, zipfiles
-
-writeln(stdout, "test compilation of binding modules")
diff --git a/tests/misc/tnewlibs.nim b/tests/misc/tnewlibs.nim
deleted file mode 100644
index 3b74a9b63..000000000
--- a/tests/misc/tnewlibs.nim
+++ /dev/null
@@ -1,21 +0,0 @@
-discard """
-  disabled: true
-"""
-
-# Test wether the bindings at least compile...
-
-import
-  tcl,
-  sdl, smpeg, sdl_gfx, sdl_net, sdl_mixer, sdl_ttf,
-  sdl_image, sdl_mixer_nosmpeg,
-  gtk2, glib2, pango, gdk2,
-  unicode, cgi, terminal, libcurl, 
-  parsexml, parseopt, parsecfg,
-  osproc,
-  cairowin32, cairoxlib,
-  gl, glut, glu, glx, glext, wingl,
-  lua, lualib, lauxlib, mysql, sqlite3, db_mongo, md5, asyncio, mimetypes,
-  cookies, events, ftpclient, scgi, irc
-  
-
-writeln(stdout, "test compilation of binding modules")
diff --git a/tests/misc/tnoop.nim b/tests/misc/tnoop.nim
index c79403e11..10c2eb2ec 100644
--- a/tests/misc/tnoop.nim
+++ b/tests/misc/tnoop.nim
@@ -1,12 +1,11 @@
 discard """
   file: "tnoop.nim"
   line: 11
-  errormsg: "expression \'a()\' cannot be called"
+  errormsg: "undeclared identifier: 'a'"
 """
-# Tests the new check in the semantic pass
+
 
 var
   a: int
 
-a()  #ERROR_MSG expression 'a()' cannot be called
-
+a()
diff --git a/tests/misc/tparsecombnum.nim b/tests/misc/tparsecombnum.nim
new file mode 100644
index 000000000..6fe539813
--- /dev/null
+++ b/tests/misc/tparsecombnum.nim
@@ -0,0 +1,55 @@
+import parsecomb
+
+discard """
+  output: "-289096"
+"""
+
+type Num = int
+
+# forward stuff
+var exp3: Parser[string, Num]
+var exp = lazy(proc(): Parser[string, Num] = exp3)
+
+var digit = (proc(): Parser[string, Num] =
+  result = tok("0").then(unit[string, Num](Num(0)))
+  for n in 1..9:
+    result = result + tok($n).then(unit[string, Num](Num(n)))
+)()
+
+var num = repeat1(digit).map(proc(ds: seq[Num]): Num =
+  result = 0
+  for d in ds:
+    result = result*10 + d)
+
+type Op = proc(a, b: Num): Num
+
+var plusOp = tok("+").then(unit[string, Op](proc(a, b: Num): Num = a + b))
+var minusOp = tok("-").then(unit[string, Op](proc(a, b: Num): Num = a - b))
+var timesOp = tok("*").then(unit[string, Op](proc(a, b: Num): Num = a*b))
+var divideOp = tok("/").then(unit[string, Op](proc(a, b: Num): Num = a div b))
+
+var paren = (tok("(") * exp * tok(")")).map(proc(ler: ((string, Num), string)): Num =
+  var (le, r) = ler
+  var (l, e) = le
+  e)
+
+proc foldOp(a: Num, ob: (Op, Num)): Num =
+  var (o, b) = ob
+  o(a, b)
+
+var exp0 = paren + num
+var exp1 = exp0.leftRec((timesOp + divideOp)*exp0, foldOp)
+var exp2 = exp1.leftRec((plusOp + minusOp)*exp1, foldOp)
+exp3 = exp2
+
+proc strsplit(s: string): seq[string] =
+  result = @[]
+  for i in 0 .. s.len - 1:
+    result.add($s[i])
+
+var r = exp.run("523-(1243+411/744*1642/1323)*233".strsplit)
+case r.kind:
+of rkSuccess:
+  echo r.output
+of rkFailure:
+  echo "failed"
diff --git a/tests/misc/trangechecks.nim b/tests/misc/trangechecks.nim
new file mode 100644
index 000000000..2c6f0f66d
--- /dev/null
+++ b/tests/misc/trangechecks.nim
@@ -0,0 +1,43 @@
+discard """
+  output: '''10
+10
+1
+1
+true'''
+"""
+
+# bug #1344
+
+var expected: int
+var x: range[1..10] = 10
+
+try:
+  x += 1
+  echo x
+except OverflowError, RangeError:
+  expected += 1
+  echo x
+
+try:
+  inc x
+  echo x
+except OverflowError, RangeError:
+  expected += 1
+  echo x
+
+x = 1
+try:
+  x -= 1
+  echo x
+except OverflowError, RangeError:
+  expected += 1
+  echo x
+
+try:
+  dec x
+  echo x
+except OverflowError, RangeError:
+  expected += 1
+  echo x
+
+echo expected == 4
diff --git a/tests/misc/tslices.nim b/tests/misc/tslices.nim
index 0de1171e3..388a46509 100644
--- a/tests/misc/tslices.nim
+++ b/tests/misc/tslices.nim
@@ -36,7 +36,7 @@ echo()
 
 
 var myseq = @[1, 2, 3, 4, 5, 6]
-myseq[0..2] = myseq[-3.. -1]
+myseq[0..2] = myseq[^3 .. ^1]
 
 for x in items(myseq): stdout.write(x)
 echo()
@@ -46,7 +46,7 @@ echo mystr
 mystr[4..4] = "u"
 
 # test full replacement
-mystr[.. -2] = "egerichtet"
+mystr[.. ^2] = "egerichtet"
 
 echo mystr
 
@@ -54,6 +54,6 @@ mystr[0..2] = "ve"
 echo mystr
 
 var s = "abcdef"
-s[1 .. -2] = "xyz"
+s[1 .. ^2] = "xyz"
 assert s == "axyzf"
 
diff --git a/tests/misc/tunsigned64mod.nim b/tests/misc/tunsigned64mod.nim
index 9ae0d535a..3007405a2 100644
--- a/tests/misc/tunsigned64mod.nim
+++ b/tests/misc/tunsigned64mod.nim
@@ -10,3 +10,17 @@ let t1 = v1 mod 2 # works
 let t2 = 7'u64 mod 2'u64 # works
 let t3 = v2 mod 2'u64 # Error: invalid type: 'range 0..1(uint64)
 let t4 = (v2 mod 2'u64).uint64 # works
+
+# bug #2550
+
+var x: uint # doesn't work
+echo x mod 2 == 0
+
+var y: uint64 # doesn't work
+echo y mod 2 == 0
+
+var z: uint32 # works
+echo z mod 2 == 0
+
+var a: int # works
+echo a mod 2 == 0
diff --git a/tests/misc/tunsignedcomp.nim b/tests/misc/tunsignedcomp.nim
new file mode 100644
index 000000000..19c8876b1
--- /dev/null
+++ b/tests/misc/tunsignedcomp.nim
@@ -0,0 +1,136 @@
+discard """
+  output: ''''''
+  disabled: "true"
+"""
+
+# All operations involving uint64 are commented out
+# as they're not yet supported.
+# All other operations are handled by implicit conversions from uints to ints
+# uint64 could be supported but would need special implementation of the operators
+
+# unsigned < signed
+
+assert 10'u8 < 20'i8
+assert 10'u8 < 20'i16
+assert 10'u8 < 20'i32
+assert 10'u8 < 20'i64
+
+assert 10'u16 < 20'i8
+assert 10'u16 < 20'i16
+assert 10'u16 < 20'i32
+assert 10'u16 < 20'i64
+
+assert 10'u32 < 20'i8
+assert 10'u32 < 20'i16
+assert 10'u32 < 20'i32
+assert 10'u32 < 20'i64
+
+# assert 10'u64 < 20'i8
+# assert 10'u64 < 20'i16
+# assert 10'u64 < 20'i32
+# assert 10'u64 < 20'i64
+
+# signed < unsigned
+assert 10'i8 < 20'u8
+assert 10'i8 < 20'u16
+assert 10'i8 < 20'u32
+# assert 10'i8 < 20'u64
+
+assert 10'i16 < 20'u8
+assert 10'i16 < 20'u16
+assert 10'i16 < 20'u32
+# assert 10'i16 < 20'u64
+
+assert 10'i32 < 20'u8
+assert 10'i32 < 20'u16
+assert 10'i32 < 20'u32
+# assert 10'i32 < 20'u64
+
+assert 10'i64 < 20'u8
+assert 10'i64 < 20'u16
+assert 10'i64 < 20'u32
+# assert 10'i64 < 20'u64
+
+# unsigned <= signed
+assert 10'u8 <= 20'i8
+assert 10'u8 <= 20'i16
+assert 10'u8 <= 20'i32
+assert 10'u8 <= 20'i64
+
+assert 10'u16 <= 20'i8
+assert 10'u16 <= 20'i16
+assert 10'u16 <= 20'i32
+assert 10'u16 <= 20'i64
+
+assert 10'u32 <= 20'i8
+assert 10'u32 <= 20'i16
+assert 10'u32 <= 20'i32
+assert 10'u32 <= 20'i64
+
+# assert 10'u64 <= 20'i8
+# assert 10'u64 <= 20'i16
+# assert 10'u64 <= 20'i32
+# assert 10'u64 <= 20'i64
+
+# signed <= unsigned
+assert 10'i8 <= 20'u8
+assert 10'i8 <= 20'u16
+assert 10'i8 <= 20'u32
+# assert 10'i8 <= 20'u64
+
+assert 10'i16 <= 20'u8
+assert 10'i16 <= 20'u16
+assert 10'i16 <= 20'u32
+# assert 10'i16 <= 20'u64
+
+assert 10'i32 <= 20'u8
+assert 10'i32 <= 20'u16
+assert 10'i32 <= 20'u32
+# assert 10'i32 <= 20'u64
+
+assert 10'i64 <= 20'u8
+assert 10'i64 <= 20'u16
+assert 10'i64 <= 20'u32
+# assert 10'i64 <= 20'u64
+
+# signed == unsigned
+assert 10'i8 == 10'u8
+assert 10'i8 == 10'u16
+assert 10'i8 == 10'u32
+# assert 10'i8 == 10'u64
+
+assert 10'i16 == 10'u8
+assert 10'i16 == 10'u16
+assert 10'i16 == 10'u32
+# assert 10'i16 == 10'u64
+
+assert 10'i32 == 10'u8
+assert 10'i32 == 10'u16
+assert 10'i32 == 10'u32
+# assert 10'i32 == 10'u64
+
+assert 10'i64 == 10'u8
+assert 10'i64 == 10'u16
+assert 10'i64 == 10'u32
+# assert 10'i64 == 10'u64
+
+# unsigned == signed
+assert 10'u8 == 10'i8
+assert 10'u8 == 10'i16
+assert 10'u8 == 10'i32
+# assert 10'u8 == 10'i64
+
+assert 10'u16 == 10'i8
+assert 10'u16 == 10'i16
+assert 10'u16 == 10'i32
+# assert 10'u16 == 10'i64
+
+assert 10'u32 == 10'i8
+assert 10'u32 == 10'i16
+assert 10'u32 == 10'i32
+# assert 10'u32 == 10'i64
+
+# assert 10'u64 == 10'i8
+# assert 10'u64 == 10'i16
+# assert 10'u64 == 10'i32
+# assert 10'u64 == 10'i64
diff --git a/tests/misc/tunsignedconv.nim b/tests/misc/tunsignedconv.nim
new file mode 100644
index 000000000..3032f8de6
--- /dev/null
+++ b/tests/misc/tunsignedconv.nim
@@ -0,0 +1,43 @@
+
+import unsigned
+
+# Tests unsigned literals and implicit conversion between uints and ints
+# Passes if it compiles
+
+var h8:uint8 = 128
+var h16:uint16 = 32768
+var h32:uint32 = 2147483648'u32
+var h64:uint64 = 9223372036854775808'u64
+var foobar:uint64 = 9223372036854775813'u64 # Issue 728
+
+var v8:uint8 = 10
+var v16:uint16 = 10
+var v32:uint32 = 10
+var v64:uint64 = 10
+
+# u8 + literal produces u8:
+var a8: uint8 = v8 + 10
+var a16: uint16 = v16 + 10
+
+when false:
+  var d8  = v8 + 10'i8
+  var d16 = v8 + 10'i16
+  var d32 = v8 + 10'i32
+
+when false:
+  # these dont work yet because unsigned.nim is stupid. XXX We need to fix this.
+  var f8  = v16 + 10'u8
+  var f16 = v16 + 10'u16
+  var f32 = v16 + 10'u32
+
+  var g8  = v32 + 10'u8
+  var g16 = v32 + 10'u16
+  var g32 = v32 + 10'u32
+
+var ar: array[0..20, int]
+var n8 = ar[v8]
+var n16 = ar[v16]
+var n32 = ar[v32]
+var n64 = ar[v64]
+
+
diff --git a/tests/misc/tunsignedinc.nim b/tests/misc/tunsignedinc.nim
new file mode 100644
index 000000000..95622156f
--- /dev/null
+++ b/tests/misc/tunsignedinc.nim
@@ -0,0 +1,14 @@
+discard """
+  output: '''253'''
+"""
+
+# bug #2427
+
+import unsigned
+
+var x = 0'u8
+dec x # OverflowError
+x -= 1 # OverflowError
+x = x - 1 # No error
+
+echo x
diff --git a/tests/misc/tvarious.nim b/tests/misc/tvarious.nim
index ed2964cf9..8124b3fc7 100644
--- a/tests/misc/tvarious.nim
+++ b/tests/misc/tvarious.nim
@@ -1,64 +1,68 @@
-# Test various aspects

+# Test various aspects
 
 # bug #572
 var a=12345678901'u64
-

+
 var x = (x: 42, y: (a: 8, z: 10))
 echo x.y
-

-import

-  mvarious

-

-type

-  PA = ref TA

-  PB = ref TB

-

-  TB = object

-    a: PA

-

-  TA = object

-    b: TB

-    x: int

-

-proc getPA(): PA =

-  var

-    b: bool

-  b = not false

-  return nil

+
+import
+  mvarious
+
+type
+  PA = ref TA
+  PB = ref TB
+
+  TB = object
+    a: PA
+
+  TA = object
+    b: TB
+    x: int
+
+proc getPA(): PA =
+  var
+    b: bool
+  b = not false
+  return nil
 
 # bug #501
 proc f(): int = 54
-

-var

-  global: int

-

-var

-  s: string

-  i: int

-  r: TA

-

-r.b.a.x = 0

-global = global + 1

-exportme()

-write(stdout, "Hallo wie heißt du? ")

-write(stdout, getPA().x)

-s = readLine(stdin)

-i = 0

-while i < s.len:

-  if s[i] == 'c': write(stdout, "'c' in deinem Namen gefunden\n")

-  i = i + 1

-

-write(stdout, "Du heißt " & s)

+
+var
+  global: int
+
+var
+  s: string
+  i: int
+  r: TA
+
+r.b.a.x = 0
+global = global + 1
+exportme()
+write(stdout, "Hallo wie heißt du? ")
+write(stdout, getPA().x)
+s = readLine(stdin)
+i = 0
+while i < s.len:
+  if s[i] == 'c': write(stdout, "'c' in deinem Namen gefunden\n")
+  i = i + 1
+
+write(stdout, "Du heißt " & s)
 
 # bug #544
-when false:
-  # yay, fails again
-  type Bar [T; I:range] = array[I, T]
-  proc foo*[T; I:range](a, b: Bar[T, I]): Bar[T, I] =
-    when len(a) != 3: 
-      # Error: constant expression expected
-      {.fatal:"Dimensions have to be 3".}
-    #...
-  block:
-    var a, b: Bar[int, 0..2]
-    discard foo(a, b)
+
+# yay, fails again
+type Bar [T; I:range] = array[I, T]
+proc foo*[T; I:range](a, b: Bar[T, I]): Bar[T, I] =
+  when len(a) != 3:
+    # Error: constant expression expected
+    {.fatal:"Dimensions have to be 3".}
+  #...
+block:
+  var a, b: Bar[int, range[0..2]]
+  discard foo(a, b)
+
+# bug #1788
+
+echo "hello" & char(ord(' ')) & "world"
diff --git a/tests/module/trecinca.nim b/tests/module/trecinca.nim
deleted file mode 100644
index 62d37783c..000000000
--- a/tests/module/trecinca.nim
+++ /dev/null
@@ -1,12 +0,0 @@
-discard """
-  file: "tests/reject/trecincb.nim"
-  line: 9
-  errormsg: "recursive dependency: 'tests/module/trecincb.nim'"
-"""
-# Test recursive includes
-
-include trecincb #ERROR_MSG recursive dependency: 'tests/trecincb.nim'
-
-echo "trecina"
-
-
diff --git a/tests/module/trecincb.nim b/tests/module/trecincb.nim
deleted file mode 100644
index a2934052f..000000000
--- a/tests/module/trecincb.nim
+++ /dev/null
@@ -1,13 +0,0 @@
-discard """
-  file: "trecincb.nim"
-  line: 9
-  errormsg: "recursive dependency: 'tests/module/trecincb.nim'"
-"""
-# Test recursive includes
-
-
-include trecincb #ERROR_MSG recursive dependency: 'tests/trecincb.nim'
-
-echo "trecinb"
-
-
diff --git a/tests/namspc/mnamspc1.nim b/tests/modules/mnamspc1.nim
index da13c5f24..da13c5f24 100644
--- a/tests/namspc/mnamspc1.nim
+++ b/tests/modules/mnamspc1.nim
diff --git a/tests/namspc/mnamspc2.nim b/tests/modules/mnamspc2.nim
index 84ef8533e..84ef8533e 100644
--- a/tests/namspc/mnamspc2.nim
+++ b/tests/modules/mnamspc2.nim
diff --git a/tests/module/mopaque.nim b/tests/modules/mopaque.nim
index 7eee4bd96..7eee4bd96 100644
--- a/tests/module/mopaque.nim
+++ b/tests/modules/mopaque.nim
diff --git a/tests/module/mrecmod.nim b/tests/modules/mrecmod.nim
index fab9654d5..fab9654d5 100644
--- a/tests/module/mrecmod.nim
+++ b/tests/modules/mrecmod.nim
diff --git a/tests/module/mrecmod2.nim b/tests/modules/mrecmod2.nim
index 9557ce729..9557ce729 100644
--- a/tests/module/mrecmod2.nim
+++ b/tests/modules/mrecmod2.nim
diff --git a/tests/modules/tmismatchedvisibility.nim b/tests/modules/tmismatchedvisibility.nim
index 6f2f79282..325c729c0 100644
--- a/tests/modules/tmismatchedvisibility.nim
+++ b/tests/modules/tmismatchedvisibility.nim
@@ -1,9 +1,9 @@
 discard """
   line: 8
-  errormsg: "public implementation 'tmismatchedvisibility.foo(a: int): int' has non-public forward declaration in tmismatchedvisibility.nim(6,5)"
+  errormsg: "public implementation 'tmismatchedvisibility.foo(a: int)' has non-public forward declaration in "
 """
 
 proc foo(a: int): int
 
 proc foo*(a: int): int =
-  result = a + a
\ No newline at end of file
+  result = a + a
diff --git a/tests/namspc/tnamspc.nim b/tests/modules/tnamspc.nim
index 1e2049cec..1e2049cec 100644
--- a/tests/namspc/tnamspc.nim
+++ b/tests/modules/tnamspc.nim
diff --git a/tests/module/topaque.nim b/tests/modules/topaque.nim
index f0587c959..f0587c959 100644
--- a/tests/module/topaque.nim
+++ b/tests/modules/topaque.nim
diff --git a/tests/modules/trecinca.nim b/tests/modules/trecinca.nim
new file mode 100644
index 000000000..14a91ba5c
--- /dev/null
+++ b/tests/modules/trecinca.nim
@@ -0,0 +1,12 @@
+discard """
+  file: "tests/reject/trecincb.nim"
+  line: 9
+  errormsg: "recursive dependency: 'tests/modules/trecincb.nim'"
+"""
+# Test recursive includes
+
+include trecincb
+
+echo "trecina"
+
+
diff --git a/tests/modules/trecincb.nim b/tests/modules/trecincb.nim
new file mode 100644
index 000000000..299a242e1
--- /dev/null
+++ b/tests/modules/trecincb.nim
@@ -0,0 +1,13 @@
+discard """
+  file: "trecincb.nim"
+  line: 9
+  errormsg: "recursive dependency: 'tests/modules/trecincb.nim'"
+"""
+# Test recursive includes
+
+
+include trecincb
+
+echo "trecinb"
+
+
diff --git a/tests/module/trecmod.nim b/tests/modules/trecmod.nim
index 9d39d3ff7..9d39d3ff7 100644
--- a/tests/module/trecmod.nim
+++ b/tests/modules/trecmod.nim
diff --git a/tests/module/trecmod2.nim b/tests/modules/trecmod2.nim
index 85fe2215f..85fe2215f 100644
--- a/tests/module/trecmod2.nim
+++ b/tests/modules/trecmod2.nim
diff --git a/tests/notnil/tnotnil4.nim b/tests/notnil/tnotnil4.nim
index 23968ee48..2fa888357 100644
--- a/tests/notnil/tnotnil4.nim
+++ b/tests/notnil/tnotnil4.nim
@@ -11,4 +11,10 @@ proc doit() =
    if x[0] != nil:
       check(x[0])
 
-doit()
\ No newline at end of file
+doit()
+
+# bug #2352
+
+proc p(x: proc() {.noconv.} not nil) = discard
+p(proc() {.noconv.} = discard)
+# Error: cannot prove 'proc () {.noconv.} = discard ' is not nil
diff --git a/tests/notnil/tnotnil_in_generic.nim b/tests/notnil/tnotnil_in_generic.nim
new file mode 100644
index 000000000..1e2d8b940
--- /dev/null
+++ b/tests/notnil/tnotnil_in_generic.nim
@@ -0,0 +1,27 @@
+discard """
+  errormsg: "cannot prove 'x' is not nil"
+"""
+
+# bug #2216
+
+type
+    A[T] = ref object
+        x: int
+        ud: T
+
+proc good[T](p: A[T]) = 
+    discard
+
+proc bad[T](p: A[T] not nil) = 
+    discard
+
+
+proc go() = 
+    let s = A[int](x: 1)
+
+    good(s)
+    bad(s)
+    var x: A[int]
+    bad(x)
+
+go()
diff --git a/tests/notnil/tnotnil_in_objconstr.nim b/tests/notnil/tnotnil_in_objconstr.nim
new file mode 100644
index 000000000..2110bda8f
--- /dev/null
+++ b/tests/notnil/tnotnil_in_objconstr.nim
@@ -0,0 +1,14 @@
+discard """
+  errormsg: "field not initialized: bar"
+  line: "13"
+"""
+
+# bug #2355
+type
+  Foo = object
+    foo: string not nil
+    bar: string not nil
+
+# Create instance without initializaing the `bar` field
+var f = Foo(foo: "foo")
+echo f.bar.isNil # true
diff --git a/tests/objects/tillegal_recursion.nim b/tests/objects/tillegal_recursion.nim
new file mode 100644
index 000000000..171a04f87
--- /dev/null
+++ b/tests/objects/tillegal_recursion.nim
@@ -0,0 +1,7 @@
+discard """
+  errormsg: "illegal recursion in type 'object'"
+  line: 7
+"""
+# bug #1691
+type
+  Foo = ref object of Foo
diff --git a/tests/objects/tobjconstr.nim b/tests/objects/tobjconstr.nim
index 3bd785728..226fe98f7 100644
--- a/tests/objects/tobjconstr.nim
+++ b/tests/objects/tobjconstr.nim
@@ -1,14 +1,14 @@
 discard """
-  output: '''(k: kindA, a: (x: abc, z: [1, 1, 3]), empty: ())
-(k: kindA, a: (x: abc, z: [1, 2, 3]), empty: ())
-(k: kindA, a: (x: abc, z: [1, 3, 3]), empty: ())
-(k: kindA, a: (x: abc, z: [1, 4, 3]), empty: ())
-(k: kindA, a: (x: abc, z: [1, 5, 3]), empty: ())
-(k: kindA, a: (x: abc, z: [1, 6, 3]), empty: ())
-(k: kindA, a: (x: abc, z: [1, 7, 3]), empty: ())
-(k: kindA, a: (x: abc, z: [1, 8, 3]), empty: ())
-(k: kindA, a: (x: abc, z: [1, 9, 3]), empty: ())
-(k: kindA, a: (x: abc, z: [1, 10, 3]), empty: ())'''
+  output: '''(k: kindA, a: (x: abc, z: [1, 1, 3]), method: ())
+(k: kindA, a: (x: abc, z: [1, 2, 3]), method: ())
+(k: kindA, a: (x: abc, z: [1, 3, 3]), method: ())
+(k: kindA, a: (x: abc, z: [1, 4, 3]), method: ())
+(k: kindA, a: (x: abc, z: [1, 5, 3]), method: ())
+(k: kindA, a: (x: abc, z: [1, 6, 3]), method: ())
+(k: kindA, a: (x: abc, z: [1, 7, 3]), method: ())
+(k: kindA, a: (x: abc, z: [1, 8, 3]), method: ())
+(k: kindA, a: (x: abc, z: [1, 9, 3]), method: ())
+(k: kindA, a: (x: abc, z: [1, 10, 3]), method: ())'''
 """
 
 type
@@ -20,9 +20,9 @@ type
   TDummy = ref object
     case k: TKind
     of kindXY: x, y: int
-    of kindA: 
+    of kindA:
       a: TArg
-      empty: TEmpty
+      `method`: TEmpty # bug #1791
 
 proc `$`[T](s: seq[T]): string =
   # XXX why is that not in the stdlib?
@@ -34,7 +34,7 @@ proc `$`[T](s: seq[T]): string =
 
 proc main() =
   for i in 1..10:
-    let d = TDummy(k: kindA, a: TArg(x: "abc", z: @[1,i,3]), empty: TEmpty())
+    let d = TDummy(k: kindA, a: TArg(x: "abc", z: @[1,i,3]), `method`: TEmpty())
     echo d[]
 
 main()
diff --git a/tests/objects/tobjloop.nim b/tests/objects/tobjloop.nim
new file mode 100644
index 000000000..9fea1e2fb
--- /dev/null
+++ b/tests/objects/tobjloop.nim
@@ -0,0 +1,15 @@
+discard """
+  output: "is Nil false"
+"""
+# bug #1658
+
+type
+  Loop* = ref object
+    onBeforeSelect*: proc (L: Loop)
+
+var L: Loop
+new L
+L.onBeforeSelect = proc (bar: Loop) =
+  echo "is Nil ", bar.isNil
+
+L.onBeforeSelect(L)
diff --git a/tests/objects/tobjpragma.nim b/tests/objects/tobjpragma.nim
index f9fbd5e40..dda8057b6 100644
--- a/tests/objects/tobjpragma.nim
+++ b/tests/objects/tobjpragma.nim
@@ -7,8 +7,11 @@ discard """
 1
 2
 3'''
+  disabled: "true"
 """
 
+# Disabled since some versions of GCC ignore the 'packed' attribute
+
 # Test 
 
 type
diff --git a/tests/objects/trefobjsyntax.nim b/tests/objects/trefobjsyntax.nim
new file mode 100644
index 000000000..9b48de718
--- /dev/null
+++ b/tests/objects/trefobjsyntax.nim
@@ -0,0 +1,27 @@
+discard """
+  output: '''wohoo
+baz'''
+"""
+
+# Test to ensure the popular 'ref T' syntax works everywhere
+
+type
+  Foo = object
+    a, b: int
+    s: string
+
+  FooBar = object of RootObj
+    n, m: string
+  Baz = object of FooBar
+
+proc invoke(a: ref Baz) =
+  echo "baz"
+
+# check object construction:
+let x = (ref Foo)(a: 0, b: 45, s: "wohoo")
+echo x.s
+
+var y: ref FooBar = (ref Baz)(n: "n", m: "m")
+
+invoke((ref Baz)(y))
+
diff --git a/tests/objects/trefobjsyntax2.nim b/tests/objects/trefobjsyntax2.nim
new file mode 100644
index 000000000..8ee209cc7
--- /dev/null
+++ b/tests/objects/trefobjsyntax2.nim
@@ -0,0 +1,19 @@
+# bug #2508
+
+type
+  GenericNodeObj[T] = ref object
+    obj: T
+
+  Node* = ref object
+    children*: seq[Node]
+    parent*: Node
+
+    nodeObj*: GenericNodeObj[int]
+
+proc newNode*(nodeObj: GenericNodeObj): Node =
+    result = Node(nodeObj: nodeObj)
+    newSeq(result.children, 10)
+
+var genericObj = GenericNodeObj[int]()
+
+var myNode = newNode(genericObj)
diff --git a/tests/objvariant/tadrdisc.nim b/tests/objvariant/tadrdisc.nim
index 0e0324562..1afe7d04f 100644
--- a/tests/objvariant/tadrdisc.nim
+++ b/tests/objvariant/tadrdisc.nim
@@ -1,7 +1,7 @@
 discard """
   file: "tadrdisc.nim"
   line: 20
-  errormsg: "for a \'var\' type a variable needs to be passed"
+  errormsg: "type mismatch: got (TKind)"
 """
 # Test that the address of a dicriminants cannot be taken
 
@@ -12,12 +12,9 @@ type
     of ka: x, y: int
     of kb: a, b: string
     of kc: c, d: float
-    
-proc setKind(k: var TKind) = 
-  k = kc
-  
-var a: TA
-setKind(a.k) #ERROR_MSG for a 'var' type a variable needs to be passed
-
 
+proc setKind(k: var TKind) =
+  k = kc
 
+var a: TA
+setKind(a.k)
diff --git a/tests/objvariant/treassign.nim b/tests/objvariant/treassign.nim
new file mode 100644
index 000000000..2938b30a3
--- /dev/null
+++ b/tests/objvariant/treassign.nim
@@ -0,0 +1,27 @@
+discard """
+  output: "SUCCESS"
+"""
+
+type
+    BasicNumber = object of RootObj
+        value: float32
+    RefChild* = ref object
+        curr*: TokenObject
+    Token* {.pure.} = enum
+        foo,
+        bar,
+    TokenObject = object
+        case kind*: Token
+        of Token.foo:
+            foo*: string
+        of Token.bar:
+            bar*: BasicNumber
+
+
+var t = RefChild()
+
+t.curr = TokenObject(kind: Token.bar, bar: BasicNumber(value: 12.34))
+
+t.curr = TokenObject(kind: Token.foo, foo: "foo")
+
+echo "SUCCESS"
diff --git a/tests/osproc/tstdin.nim b/tests/osproc/tstdin.nim
index 2ea939992..b491c2500 100644
--- a/tests/osproc/tstdin.nim
+++ b/tests/osproc/tstdin.nim
@@ -4,13 +4,16 @@ discard """
 """
 import osproc, os, streams
 
-doAssert fileExists(getCurrentDir() / "tests" / "osproc" / "ta.exe")
+const filename = when defined(Windows): "ta.exe" else: "ta"
 
-var p = startProcess("ta.exe", getCurrentDir() / "tests" / "osproc")
+doAssert fileExists(getCurrentDir() / "tests" / "osproc" / filename)
+
+var p = startProcess(filename, getCurrentDir() / "tests" / "osproc")
 p.inputStream.write("5\n")
+p.inputStream.flush()
 while true:
   let line = p.outputStream.readLine()
   if line != "":
     echo line
   else:
-    break
\ No newline at end of file
+    break
diff --git a/tests/overload/toverprc.nim b/tests/overload/toverprc.nim
index 22b64ed48..78831f744 100644
--- a/tests/overload/toverprc.nim
+++ b/tests/overload/toverprc.nim
@@ -1,14 +1,19 @@
+discard """
+  output: '''another number: 123
+yay'''
+"""
+
 # Test overloading of procs when used as function pointers
 
 import strutils
 
-proc parseInt(x: float): int {.noSideEffect.} = nil
-proc parseInt(x: bool): int {.noSideEffect.} = nil
-proc parseInt(x: float32): int {.noSideEffect.} = nil
-proc parseInt(x: int8): int {.noSideEffect.} = nil
-proc parseInt(x: TFile): int {.noSideEffect.} = nil
-proc parseInt(x: char): int {.noSideEffect.} = nil
-proc parseInt(x: int16): int {.noSideEffect.} = nil
+proc parseInt(x: float): int {.noSideEffect.} = discard
+proc parseInt(x: bool): int {.noSideEffect.} = discard
+proc parseInt(x: float32): int {.noSideEffect.} = discard
+proc parseInt(x: int8): int {.noSideEffect.} = discard
+proc parseInt(x: TFile): int {.noSideEffect.} = discard
+proc parseInt(x: char): int {.noSideEffect.} = discard
+proc parseInt(x: int16): int {.noSideEffect.} = discard
 
 proc parseInt[T](x: T): int = echo x; 34
 
@@ -19,12 +24,13 @@ var
   q = TParseInt(parseInt)
   p: TParseInt = parseInt
 
-proc takeParseInt(x: proc (y: string): int {.noSideEffect.}): int = 
+proc takeParseInt(x: proc (y: string): int {.noSideEffect.}): int =
   result = x("123")
-  
-echo "Give a list of numbers (separated by spaces): "
-var x = stdin.readline.split.map(parseInt).max
-echo x, " is the maximum!"
+
+if false:
+  echo "Give a list of numbers (separated by spaces): "
+  var x = stdin.readline.split.map(parseInt).max
+  echo x, " is the maximum!"
 echo "another number: ", takeParseInt(parseInt)
 
 
diff --git a/tests/overload/tparams_after_varargs.nim b/tests/overload/tparams_after_varargs.nim
new file mode 100644
index 000000000..a93e280b9
--- /dev/null
+++ b/tests/overload/tparams_after_varargs.nim
@@ -0,0 +1,17 @@
+discard """
+  output: '''a 1 b 2 x @[3, 4, 5] y 6 z 7
+yay
+12'''
+"""
+
+proc test(a, b: int, x: varargs[int]; y, z: int) =
+  echo "a ", a, " b ", b, " x ", @x, " y ", y, " z ", z
+
+test 1, 2, 3, 4, 5, 6, 7
+
+template takesBlock(a, b: int, x: varargs[expr]; blck: stmt) =
+  blck
+  echo a, b
+
+takesBlock 1, 2, "some", 0.90, "random stuff":
+  echo "yay"
diff --git a/tests/overload/tprefer_specialized_generic.nim b/tests/overload/tprefer_specialized_generic.nim
new file mode 100644
index 000000000..2b41502d1
--- /dev/null
+++ b/tests/overload/tprefer_specialized_generic.nim
@@ -0,0 +1,22 @@
+discard """
+  output: '''ref ref T ptr S'''
+"""
+
+proc foo[T](x: T) =
+  echo "only T"
+
+proc foo[T](x: ref T) =
+  echo "ref T"
+
+proc foo[T, S](x: ref ref T; y: ptr S) =
+  echo "ref ref T ptr S"
+
+proc foo[T, S](x: ref T; y: ptr S) =
+  echo "ref T ptr S"
+
+proc foo[T](x: ref T; default = 0) =
+  echo "ref T; default"
+
+var x: ref ref int
+var y: ptr ptr int
+foo(x, y)
diff --git a/tests/overload/tprefer_tygenericinst.nim b/tests/overload/tprefer_tygenericinst.nim
new file mode 100644
index 000000000..9787af06b
--- /dev/null
+++ b/tests/overload/tprefer_tygenericinst.nim
@@ -0,0 +1,42 @@
+discard """
+  output: '''Version 2 was called.
+This has the highest precedence.
+This has the second-highest precedence.
+This has the lowest precedence.'''
+"""
+
+# bug #2220
+when true:
+  type A[T] = object
+  type B = A[int]
+
+  proc q[X](x: X) =
+    echo "Version 1 was called."
+
+  proc q(x: B) =
+    echo "Version 2 was called."
+
+  q(B()) # This call reported as ambiguous.
+
+# bug #2219
+template testPred(a: expr) =
+  block:
+    type A = object of RootObj
+    type B = object of A
+    type SomeA = A|A # A hack to make "A" a typeclass.
+
+    when a >= 3:
+      proc p[X](x: X) =
+        echo "This has the highest precedence."
+    when a >= 2:
+      proc p[X: A](x: X) =
+        echo "This has the second-highest precedence."
+    when a >= 1:
+      proc p[X: SomeA](x: X) =
+        echo "This has the lowest precedence."
+
+    p(B())
+
+testPred(3)
+testPred(2)
+testPred(1)
diff --git a/tests/overload/tspec.nim b/tests/overload/tspec.nim
new file mode 100644
index 000000000..f2002a390
--- /dev/null
+++ b/tests/overload/tspec.nim
@@ -0,0 +1,118 @@
+discard """
+  output: '''not a var
+not a var
+a var
+B
+int
+T
+int16
+T
+ref T
+123
+2
+1
+@[123, 2, 1]
+Called!
+merge with var
+merge no var'''
+"""
+
+# Things that's even in the spec now!
+
+proc byvar(x: var int) = echo "a var"
+proc byvar(x: int) = echo "not a var"
+byvar(89)
+
+let letSym = 0
+var varSym = 13
+
+byvar(letSym)
+byvar(varSym)
+
+type
+  A = object of RootObj
+  B = object of A
+  C = object of B
+
+proc p(obj: A) =
+  echo "A"
+
+proc p(obj: B) =
+  echo "B"
+
+var c = C()
+# not ambiguous, calls 'B', not 'A' since B is a subtype of A
+# but not vice versa:
+p(c)
+
+proc pp(obj: A, obj2: B) = echo "A B"
+proc pp(obj: B, obj2: A) = echo "B A"
+
+# but this is ambiguous:
+#pp(c, c)
+
+proc takesInt(x: int) = echo "int"
+proc takesInt[T](x: T) = echo "T"
+proc takesInt(x: int16) = echo "int16"
+
+takesInt(4) # "int"
+var x: int32
+takesInt(x) # "T"
+var y: int16
+takesInt(y) # "int16"
+var z: range[0..4] = 0
+takesInt(z) # "T"
+
+proc gen[T](x: ref ref T) = echo "ref ref T"
+proc gen[T](x: ref T) = echo "ref T"
+proc gen[T](x: T) = echo "T"
+
+var ri: ref int
+gen(ri) # "ref T"
+
+
+template rem(x: expr) = discard
+#proc rem[T](x: T) = discard
+
+rem unresolvedExpression(undeclaredIdentifier)
+
+
+proc takeV[T](a: varargs[T]) =
+  for x in a: echo x
+
+takeV([123, 2, 1]) # takeV's T is "int", not "array of int"
+echo(@[123, 2, 1])
+
+# bug #2600
+
+type
+  FutureBase* = ref object of RootObj ## Untyped future.
+
+  Future*[T] = ref object of FutureBase ## Typed future.
+    value: T ## Stored value
+
+  FutureVar*[T] = distinct Future[T]
+
+proc newFuture*[T](): Future[T] =
+  new(result)
+
+proc newFutureVar*[T](): FutureVar[T] =
+  result = FutureVar[T](newFuture[T]())
+
+proc mget*[T](future: FutureVar[T]): var T =
+  Future[T](future).value
+
+proc reset*[T](future: FutureVar[T]) =
+  echo "Called!"
+
+proc merge[T](x: Future[T]) = echo "merge no var"
+proc merge[T](x: var Future[T]) = echo "merge with var"
+
+when true:
+  var foo = newFutureVar[string]()
+  foo.mget() = ""
+  foo.mget.add("Foobar")
+  foo.reset()
+  var bar = newFuture[int]()
+  bar.merge # merge with var
+  merge(newFuture[int]()) # merge no var
diff --git a/tests/overload/tstmtoverload.nim b/tests/overload/tstmtoverload.nim
new file mode 100644
index 000000000..f1944b637
--- /dev/null
+++ b/tests/overload/tstmtoverload.nim
@@ -0,0 +1,38 @@
+
+# bug #2481
+import math
+
+template test(loopCount: int, extraI: int, testBody: stmt): stmt =
+  block:
+    for i in 0..loopCount-1:
+      testBody
+    echo "done extraI=", extraI
+
+template test(loopCount: int, extraF: float, testBody: stmt): stmt =
+  block:
+    test(loopCount, round(extraF), testBody)
+
+template test(loopCount: int, testBody: stmt): stmt =
+  block:
+    test(loopCount, 0, testBody)
+    echo "done extraI passed 0"
+
+when isMainModule:
+  var
+    loops = 0
+
+  test 0, 0:
+    loops += 1
+  echo "test 0 complete, loops=", loops
+
+  test 1, 1.0:
+    loops += 1
+  echo "test 1.0 complete, loops=", loops
+
+  when true:
+    # when true we get the following compile time error:
+    #   b.nim(35, 6) Error: expression 'loops += 1' has no type (or is ambiguous)
+    loops = 0
+    test 2:
+      loops += 1
+    echo "test no extra complete, loops=", loops
diff --git a/tests/overload/tsymtabchange_during_or.nim b/tests/overload/tsymtabchange_during_or.nim
new file mode 100644
index 000000000..b5551bcc7
--- /dev/null
+++ b/tests/overload/tsymtabchange_during_or.nim
@@ -0,0 +1,24 @@
+
+# bug #2229
+
+type Type1 = object
+        id: int
+
+type Type2 = object
+    id: int
+
+proc init(self: var Type1, a: int, b: ref Type2) =
+    echo "1"
+
+proc init(self: var Type2, a: int) =
+    echo """
+        Works when this proc commented out
+        Otherwise error:
+        test.nim(14, 4) Error: ambiguous call; both test.init(self: var Type1, a: int, b: ref Type2) and test.init(self: var Type1, a: int, b: ref Type2) match for: (Type1, int literal(1), ref Type2)
+    """
+
+var a: Type1
+init(a, 1, (
+    var b = new(Type2);
+    b
+))
diff --git a/tests/overload/tsystemcmp.nim b/tests/overload/tsystemcmp.nim
index 54dff0c46..68cbf9fa7 100644
--- a/tests/overload/tsystemcmp.nim
+++ b/tests/overload/tsystemcmp.nim
@@ -7,3 +7,16 @@ import algorithm
 # bug #1657
 var modules = @["hi", "ho", "ha", "huu"]
 sort(modules, system.cmp)
+
+type
+  MyType = object
+    x: string
+
+proc cmp(a, b: MyType): int = cmp(a.x, b.x)
+
+var modulesB = @[MyType(x: "ho"), MyType(x: "ha")]
+sort(modulesB, cmp)
+
+# bug #2397
+
+proc f(x: (proc(a,b: string): int) = system.cmp) = discard
diff --git a/tests/parallel/tarray_of_channels.nim b/tests/parallel/tarray_of_channels.nim
new file mode 100644
index 000000000..11b523401
--- /dev/null
+++ b/tests/parallel/tarray_of_channels.nim
@@ -0,0 +1,26 @@
+# bug #2257
+import threadpool
+
+type StringChannel = TChannel[string]
+var channels: array[1..3, StringChannel]
+
+type
+  MyObject[T] = object
+    x: T
+
+var global: MyObject[string]
+var globalB: MyObject[float]
+
+proc consumer(ix : int) {.thread.} =
+  echo channels[ix].recv() ###### not GC-safe: 'channels'
+  echo globalB
+
+proc main =
+  for ix in 1..3: channels[ix].open()
+  for ix in 1..3: spawn consumer(ix)
+  for ix in 1..3: channels[ix].send("test")
+  sync()
+  for ix in 1..3: channels[ix].close()
+
+when isMainModule:
+  main()
diff --git a/tests/parallel/tconvexhull.nim b/tests/parallel/tconvexhull.nim
index d7e4f7716..dffe5339b 100644
--- a/tests/parallel/tconvexhull.nim
+++ b/tests/parallel/tconvexhull.nim
@@ -6,7 +6,7 @@ true
 true
 true'''
 
-ccodeCheck: "!'deepcopy('"
+ccodeCheck: "\\i ! @'deepCopy(' .*"
 """
 
 # parallel convex hull for Nim bigbreak
diff --git a/tests/parallel/tdont_be_stupid.nim b/tests/parallel/tdont_be_stupid.nim
new file mode 100644
index 000000000..a7e82466a
--- /dev/null
+++ b/tests/parallel/tdont_be_stupid.nim
@@ -0,0 +1,15 @@
+
+import threadpool, os
+
+proc single(time: int) =
+  sleep time
+  echo time
+
+proc sleepsort(nums: openArray[int]) =
+  parallel:
+    var i = 0
+    while i <= len(nums) + -1:
+      spawn single(nums[i])
+      i += 1
+
+sleepsort([50,3,40,25])
diff --git a/tests/parallel/tgc_unsafe.nim b/tests/parallel/tgc_unsafe.nim
new file mode 100644
index 000000000..6548bbec8
--- /dev/null
+++ b/tests/parallel/tgc_unsafe.nim
@@ -0,0 +1,32 @@
+discard """
+  errormsg: "'consumer' is not GC-safe"
+  line: 19
+"""
+
+# bug #2257
+import threadpool
+
+type StringChannel = TChannel[string]
+var channels: array[1..3, StringChannel]
+
+type
+  MyObject[T] = object
+    x: T
+
+var global: MyObject[string]
+var globalB: MyObject[float]
+
+proc consumer(ix : int) {.thread.} =
+  echo channels[ix].recv() ###### not GC-safe: 'channels'
+  echo global
+  echo globalB
+
+proc main =
+  for ix in 1..3: channels[ix].open()
+  for ix in 1..3: spawn consumer(ix)
+  for ix in 1..3: channels[ix].send("test")
+  sync()
+  for ix in 1..3: channels[ix].close()
+
+when isMainModule:
+  main()
diff --git a/tests/parallel/tgc_unsafe2.nim b/tests/parallel/tgc_unsafe2.nim
new file mode 100644
index 000000000..ec4605fe9
--- /dev/null
+++ b/tests/parallel/tgc_unsafe2.nim
@@ -0,0 +1,39 @@
+discard """
+  line: 28
+  nimout: '''tgc_unsafe2.nim(22, 5) Warning: 'trick' is not GC-safe as it accesses 'global' which is a global using GC'ed memory
+tgc_unsafe2.nim(26, 5) Warning: 'track' is not GC-safe as it calls 'trick'
+tgc_unsafe2.nim(28, 5) Error: 'consumer' is not GC-safe as it calls 'track'
+'''
+  errormsg: "'consumer' is not GC-safe as it calls 'track'"
+"""
+
+import threadpool
+
+type StringChannel = TChannel[string]
+var channels: array[1..3, StringChannel]
+
+type
+  MyObject[T] = object
+    x: T
+
+var global: MyObject[string]
+var globalB: MyObject[float]
+
+proc trick(ix: int) =
+  echo global.x
+  echo channels[ix].recv()
+
+proc track(ix: int) = trick(ix)
+
+proc consumer(ix: int) {.thread.} =
+  track(ix)
+
+proc main =
+  for ix in 1..3: channels[ix].open()
+  for ix in 1..3: spawn consumer(ix)
+  for ix in 1..3: channels[ix].send("test")
+  sync()
+  for ix in 1..3: channels[ix].close()
+
+when isMainModule:
+  main()
diff --git a/tests/parallel/tmissing_deepcopy.nim b/tests/parallel/tmissing_deepcopy.nim
new file mode 100644
index 000000000..53481e4df
--- /dev/null
+++ b/tests/parallel/tmissing_deepcopy.nim
@@ -0,0 +1,40 @@
+discard """
+  ccodeCheck: "\\i @'deepCopy(' .*"
+"""
+
+# bug #2286
+
+import threadPool
+
+type
+  Person = ref object
+    name: string
+    friend: Person
+
+var
+  people: seq[Person] = @[]
+
+proc newPerson(name:string): Person =
+  result.new()
+  result.name = name
+
+proc greet(p:Person) =
+  p.friend.name &= "-MUT" # this line crashes the program
+  echo "Person {",
+    " name:", p.name, "(", cast[int](addr p.name),"),",
+    " friend:", p.friend.name, "(", cast[int](addr p.friend.name),") }"
+
+proc setup =
+  for i in 0 .. <20:
+    people.add newPerson("Person" & $(i + 1))
+  for i in 0 .. <20:
+    people[i].friend = people[19-i]
+
+proc update =
+  parallel:
+    for i in 0 .. people.high:
+      spawn people[i].greet()
+
+when isMainModule:
+  setup()
+  update()
diff --git a/tests/parallel/tsimple_array_checks.nim b/tests/parallel/tsimple_array_checks.nim
new file mode 100644
index 000000000..9874d3299
--- /dev/null
+++ b/tests/parallel/tsimple_array_checks.nim
@@ -0,0 +1,41 @@
+# bug #2287
+
+import threadPool
+
+# If `nums` is an array instead of seq,
+# NONE of the iteration ways below work (including high / len-1)
+let nums = @[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+
+proc log(n:int) =
+  echo n
+
+proc main =
+  parallel:
+    for n in nums: # Error: cannot prove: i <= len(nums) + -1
+      spawn log(n)
+    #for i in 0 .. <nums.len: # Error: cannot prove: i <= len(nums) + -1
+    #for i in 0 .. nums.len-1: # WORKS!
+    #for i in 0 .. <nums.len: # WORKS!
+    #  spawn log(nums[i])
+
+# Array needs explicit size to work, probably related to issue #2287
+#const a: array[0..5, int] = [1,2,3,4,5,6]
+
+#const a = [1,2,3,4,5,6] # Doesn't work
+const a = @[1,2,3,4,5,6] # Doesn't work
+proc f(n: int) = echo "Hello ", n
+
+proc maino =
+  parallel:
+    # while loop doesn't work:
+    var i = 0
+    while i < a.high:
+      #for i in countup(0, a.high-1, 2):
+      spawn f(a[i])
+      spawn f(a[i+1])
+      i += 2
+
+maino() # Doesn't work outside a proc
+
+when isMainModule:
+  main()
diff --git a/tests/parallel/twrong_refcounts.nim b/tests/parallel/twrong_refcounts.nim
new file mode 100644
index 000000000..db32a96d8
--- /dev/null
+++ b/tests/parallel/twrong_refcounts.nim
@@ -0,0 +1,53 @@
+discard """
+  output: "Success"
+"""
+
+import math, threadPool
+
+# ---
+
+type
+  Person = object
+    age: int
+    friend: ref Person
+
+var
+  people: seq[ref Person] = @[]
+
+proc newPerson(age:int): ref Person =
+  result.new()
+  result.age = age
+
+proc greet(p:Person) =
+  #echo p.age, ", ", p.friend.age
+  p.friend.age += 1
+
+# ---
+
+proc setup =
+  for i in 0 .. <20:
+    people.add newPerson(i + 1)
+  for i in 0 .. <20:
+    people[i].friend = people[random(20)]
+
+proc update =
+  var countA: array[20, int]
+  var countB: array[20, int]
+
+  for i, p in people:
+    countA[i] = getRefCount(p)
+  parallel:
+    for i in 0 .. people.high:
+      spawn greet(people[i][])
+  for i, p in people:
+    countB[i] = getRefCount(p)
+
+  for i in 0 .. <20:
+    doAssert countA[i] == countB[i]
+  echo "Success"
+
+# ---
+
+when isMainModule:
+  setup()
+  update()
diff --git a/tests/parser/tcommand_as_expr.nim b/tests/parser/tcommand_as_expr.nim
index 22c49ab3f..730e9cbb7 100644
--- a/tests/parser/tcommand_as_expr.nim
+++ b/tests/parser/tcommand_as_expr.nim
@@ -1,7 +1,8 @@
 discard """
   output: '''140
 5-120-120
-359'''
+359
+77'''
 """
 #import math
 
@@ -16,8 +17,10 @@ proc foo(x, y: int): int = x-y
 let x = optarg foo 7.foo
 let y = singlearg foo(1, foo 8)
 let z = singlearg 1.foo foo 8
-    
+
 echo x, y, z
 
 let a = [2,4,8].map do (d:int) -> int: d + 1
-echo a[0], a[1], a[2]
\ No newline at end of file
+echo a[0], a[1], a[2]
+
+echo(foo 8, foo 8)
diff --git a/tests/parser/tinvcolonlocation1.nim b/tests/parser/tinvcolonlocation1.nim
new file mode 100644
index 000000000..cacde48bd
--- /dev/null
+++ b/tests/parser/tinvcolonlocation1.nim
@@ -0,0 +1,12 @@
+discard """
+  file: "tinvcolonlocation1.nim"
+  line: 8
+  column: 3
+  errormsg: "':' expected"
+"""
+try #<- missing ':'
+  echo "try"
+except:
+  echo "except"
+finally:
+  echo "finally"
diff --git a/tests/parser/tinvcolonlocation2.nim b/tests/parser/tinvcolonlocation2.nim
new file mode 100644
index 000000000..2b6a92b9d
--- /dev/null
+++ b/tests/parser/tinvcolonlocation2.nim
@@ -0,0 +1,15 @@
+discard """
+  file: "tinvcolonlocation2.nim"
+  line: 11
+  column: 1
+  errormsg: "':' expected"
+"""
+try:
+  echo "try"
+except #<- missing ':'
+  echo "except"
+finally:
+#<-- error will be here above, at the beginning of finally,
+#    since compiler tries to consome echo and part of except
+#    expression
+  echo "finally"
diff --git a/tests/parser/tinvcolonlocation3.nim b/tests/parser/tinvcolonlocation3.nim
new file mode 100644
index 000000000..2b30b1dbe
--- /dev/null
+++ b/tests/parser/tinvcolonlocation3.nim
@@ -0,0 +1,12 @@
+discard """
+  file: "tinvcolonlocation3.nim"
+  line: 12
+  column: 3
+  errormsg: "':' expected"
+"""
+try:
+  echo "try"
+except:
+  echo "except"
+finally #<- missing ':'
+  echo "finally"
diff --git a/tests/parser/tproctype_pragmas.nim b/tests/parser/tproctype_pragmas.nim
new file mode 100644
index 000000000..8c7acd0cf
--- /dev/null
+++ b/tests/parser/tproctype_pragmas.nim
@@ -0,0 +1,19 @@
+discard """
+  output: '''39
+40'''
+"""
+
+# bug 1802
+# Ensure proc pragmas are attached properly:
+
+proc makeStdcall(s: string): (proc(i: int) {.stdcall.}) =
+  (proc (x: int) {.stdcall.} = echo x)
+
+proc makeNimcall(s: string): (proc(i: int)) {.stdcall.} =
+  (proc (x: int) {.nimcall.} = echo x)
+
+let stdc: proc (y: int) {.stdcall.} = makeStdcall("bu")
+let nimc: proc (y: int) {.closure.} = makeNimcall("ba")
+
+stdc(39)
+nimc(40)
diff --git a/tests/parser/tstrongspaces.nim b/tests/parser/tstrongspaces.nim
index 91506daf0..e70b91988 100644
--- a/tests/parser/tstrongspaces.nim
+++ b/tests/parser/tstrongspaces.nim
@@ -2,6 +2,12 @@
 
 discard """
   output: '''35
+true
+true
+4
+true
+1
+false
 77
 (Field0: 1, Field1: 2, Field2: 2)
 ha
@@ -9,11 +15,26 @@ true
 tester args
 all
 all args
+19
+-3
+false
+-2
 '''
 """
 
 echo 2+5 * 5
 
+# Keyword operators
+echo 1 + 16 shl 1 == 1 + (16 shl 1)
+echo 2 and 1  in  {0, 30}
+echo 2+2 * 2 shr 1
+echo false  or  2 and 1  in  {0, 30}
+
+proc `^`(a, b: int): int = a + b div 2
+echo 19 mod 16 ^ 4  +  2 and 1
+echo 18 mod 16 ^ 4 > 0
+
+# echo $foo gotcha
 let foo = 77
 echo $foo
 
@@ -27,7 +48,7 @@ when true:
   let b = 66
   let c = 90
   let bar = 8000
-  if foo+4 * 4 == 8 and b&c | 9  ++
+  if foo+4 * 4 == 8  and  b&c | 9  ++
       bar:
     echo "ho"
   else:
@@ -50,3 +71,13 @@ const
 echo tester & " " & args|"all"
 echo "all"  |  tester & " " & args
 echo "all"|tester & " " & args
+
+# Test arrow like operators. See also tests/macros/tclosuremacro.nim
+proc `+->`(a, b: int): int = a + b*4
+template `===>`(a, b: int): expr = a - b shr 1
+
+echo 3 +-> 2 + 2 and 4
+var arrowed = 3+->2 + 2 and 4  # arrowed = 4
+echo arrowed ===> 15
+echo (2 * 3+->2) == (2*3 +-> 2)
+echo arrowed ===> 2 + 3+->2
diff --git a/tests/parser/ttupleunpack.nim b/tests/parser/ttupleunpack.nim
new file mode 100644
index 000000000..aaa06f9f4
--- /dev/null
+++ b/tests/parser/ttupleunpack.nim
@@ -0,0 +1,35 @@
+discard """
+  file: "ttupleunpack.nim"
+  output: ""
+  exitcode: 0
+"""
+
+proc returnsTuple(): (int, int, int) = (4, 2, 3)
+
+proc main2 =
+  let (x, _, z) = returnsTuple()
+
+proc main() =
+
+  proc foo(): tuple[x, y, z: int] =
+    return (4, 2, 3)
+
+  var (x, _, y) = foo()
+  doAssert x == 4
+  doAssert y == 3
+
+  var (a, _, _) = foo()
+  doAssert a == 4
+
+  var (aa, _, _) = foo()
+  doAssert aa == 4
+
+  iterator bar(): tuple[x, y, z: int] =
+    yield (1,2,3)
+
+  for x, y, _ in bar():
+    doAssert x == 1
+    doAssert y == 2
+
+main()
+main2()
diff --git a/tests/parser/ttypeof.nim b/tests/parser/ttypeof.nim
new file mode 100644
index 000000000..24f98059e
--- /dev/null
+++ b/tests/parser/ttypeof.nim
@@ -0,0 +1,26 @@
+discard """
+  output: '''12
+int
+int
+int'''
+"""
+
+import typetraits
+
+# bug #1805
+
+proc foob(x: int): string = "foo"
+proc barb(x: string): int = 12
+
+echo(foob(10).barb()) # works
+echo(type(10).name()) # doesn't work
+
+echo(name(type(10))) # works
+echo((type(10)).name()) # works
+
+
+# test that 'addr' still works
+proc poo(x, y: ptr int) = discard
+
+var someInt: int
+poo(addr someInt, addr someInt)
diff --git a/tests/parser/twhen_in_enum.nim b/tests/parser/twhen_in_enum.nim
new file mode 100644
index 000000000..d4a3ea56a
--- /dev/null
+++ b/tests/parser/twhen_in_enum.nim
@@ -0,0 +1,11 @@
+discard """
+  errormsg: "identifier expected, but found 'keyword when'"
+"""
+
+# bug #2123
+type num = enum
+    NUM_NONE = 0
+    NUM_ALL = 1
+    when defined(macosx): NUM_OSX = 10 # only this differs for real
+    NUM_XTRA = 20
+
diff --git a/tests/rodfiles/nimrod.cfg b/tests/rodfiles/nim.cfg
index 78fc8db64..78fc8db64 100644
--- a/tests/rodfiles/nimrod.cfg
+++ b/tests/rodfiles/nim.cfg
diff --git a/tests/seq/tsequtils.nim b/tests/seq/tsequtils.nim
index 3a7eeeffa..ea85a7f21 100644
--- a/tests/seq/tsequtils.nim
+++ b/tests/seq/tsequtils.nim
@@ -7,7 +7,7 @@ Filter Iterator: 7
 Filter: [3, 5, 7]
 FilterIt: [1, 3, 7]
 Concat: [1, 3, 5, 7, 2, 4, 6]
-Distnct: [1, 2, 3, 4, 5, 7]'''
+Deduplicate: [1, 2, 3, 4, 5, 7]'''
 
 """
 
diff --git a/tests/sets/tsets.nim b/tests/sets/tsets.nim
index e370209ed..646175329 100644
--- a/tests/sets/tsets.nim
+++ b/tests/sets/tsets.nim
@@ -1,6 +1,7 @@
 discard """

   file: "tsets.nim"

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

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

+false'''

 """

 # Test the handling of sets

 

@@ -15,30 +16,30 @@ type
   TAZ = range['a'..'z']

   TAZset = set[TAZ]

 

-  TTokType* = enum 

+  TTokType* = enum

     tkInvalid, tkEof,

     tkSymbol,

-    tkAddr, tkAnd, tkAs, tkAsm, tkBlock, tkBreak, tkCase, tkCast, tkConst, 

-    tkContinue, tkConverter, tkDiscard, tkDiv, tkElif, tkElse, tkEnd, tkEnum, 

-    tkExcept, tkException, tkFinally, tkFor, tkFrom, tkGeneric, tkIf, tkImplies, 

-    tkImport, tkIn, tkInclude, tkIs, tkIsnot, tkIterator, tkLambda, tkMacro, 

-    tkMethod, tkMod, tkNil, tkNot, tkNotin, tkObject, tkOf, tkOr, tkOut, tkProc, 

-    tkPtr, tkRaise, tkRecord, tkRef, tkReturn, tkShl, tkShr, tkTemplate, tkTry, 

+    tkAddr, tkAnd, tkAs, tkAsm, tkBlock, tkBreak, tkCase, tkCast, tkConst,

+    tkContinue, tkConverter, tkDiscard, tkDiv, tkElif, tkElse, tkEnd, tkEnum,

+    tkExcept, tkException, tkFinally, tkFor, tkFrom, tkGeneric, tkIf, tkImplies,

+    tkImport, tkIn, tkInclude, tkIs, tkIsnot, tkIterator, tkLambda, tkMacro,

+    tkMethod, tkMod, tkNil, tkNot, tkNotin, tkObject, tkOf, tkOr, tkOut, tkProc,

+    tkPtr, tkRaise, tkRecord, tkRef, tkReturn, tkShl, tkShr, tkTemplate, tkTry,

     tkType, tkVar, tkWhen, tkWhere, tkWhile, tkWith, tkWithout, tkXor, tkYield,

-    tkIntLit, tkInt8Lit, tkInt16Lit, tkInt32Lit, tkInt64Lit, tkFloatLit, 

-    tkFloat32Lit, tkFloat64Lit, tkStrLit, tkRStrLit, tkTripleStrLit, tkCharLit, 

-    tkRCharLit, tkParLe, tkParRi, tkBracketLe, tkBracketRi, tkCurlyLe, 

-    tkCurlyRi, tkBracketDotLe, tkBracketDotRi, 

-    tkCurlyDotLe, tkCurlyDotRi, 

+    tkIntLit, tkInt8Lit, tkInt16Lit, tkInt32Lit, tkInt64Lit, tkFloatLit,

+    tkFloat32Lit, tkFloat64Lit, tkStrLit, tkRStrLit, tkTripleStrLit, tkCharLit,

+    tkRCharLit, tkParLe, tkParRi, tkBracketLe, tkBracketRi, tkCurlyLe,

+    tkCurlyRi, tkBracketDotLe, tkBracketDotRi,

+    tkCurlyDotLe, tkCurlyDotRi,

     tkParDotLe, tkParDotRi,

-    tkComma, tkSemiColon, tkColon, tkEquals, tkDot, tkDotDot, tkHat, tkOpr, 

+    tkComma, tkSemiColon, tkColon, tkEquals, tkDot, tkDotDot, tkHat, tkOpr,

     tkComment, tkAccent, tkInd, tkSad, tkDed,

     tkSpaces, tkInfixOpr, tkPrefixOpr, tkPostfixOpr

   TTokTypeRange = range[tkSymbol..tkDed]

   TTokTypes* = set[TTokTypeRange]

 

 const

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

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

                          tkStrLit..tkTripleStrLit}

 

 var

@@ -62,3 +63,142 @@ for x in low(TTokTypeRange) .. high(TTokTypeRange):
 #OUT Ha ein F ist in s!

 

 

+type

+  TMsgKind* = enum

+    errUnknown, errIllFormedAstX, errInternal, errCannotOpenFile, errGenerated,

+    errXCompilerDoesNotSupportCpp, errStringLiteralExpected,

+    errIntLiteralExpected, errInvalidCharacterConstant,

+    errClosingTripleQuoteExpected, errClosingQuoteExpected,

+    errTabulatorsAreNotAllowed, errInvalidToken, errLineTooLong,

+    errInvalidNumber, errNumberOutOfRange, errNnotAllowedInCharacter,

+    errClosingBracketExpected, errMissingFinalQuote, errIdentifierExpected,

+    errNewlineExpected,

+    errInvalidModuleName,

+    errOperatorExpected, errTokenExpected, errStringAfterIncludeExpected,

+    errRecursiveDependencyX, errOnOrOffExpected, errNoneSpeedOrSizeExpected,

+    errInvalidPragma, errUnknownPragma, errInvalidDirectiveX,

+    errAtPopWithoutPush, errEmptyAsm, errInvalidIndentation,

+    errExceptionExpected, errExceptionAlreadyHandled,

+    errYieldNotAllowedHere, errYieldNotAllowedInTryStmt,

+    errInvalidNumberOfYieldExpr, errCannotReturnExpr, errAttemptToRedefine,

+    errStmtInvalidAfterReturn, errStmtExpected, errInvalidLabel,

+    errInvalidCmdLineOption, errCmdLineArgExpected, errCmdLineNoArgExpected,

+    errInvalidVarSubstitution, errUnknownVar, errUnknownCcompiler,

+    errOnOrOffExpectedButXFound, errNoneBoehmRefcExpectedButXFound,

+    errNoneSpeedOrSizeExpectedButXFound, errGuiConsoleOrLibExpectedButXFound,

+    errUnknownOS, errUnknownCPU, errGenOutExpectedButXFound,

+    errArgsNeedRunOption, errInvalidMultipleAsgn, errColonOrEqualsExpected,

+    errExprExpected, errUndeclaredIdentifier, errUseQualifier, errTypeExpected,

+    errSystemNeeds, errExecutionOfProgramFailed, errNotOverloadable,

+    errInvalidArgForX, errStmtHasNoEffect, errXExpectsTypeOrValue,

+    errXExpectsArrayType, errIteratorCannotBeInstantiated, errExprXAmbiguous,

+    errConstantDivisionByZero, errOrdinalTypeExpected,

+    errOrdinalOrFloatTypeExpected, errOverOrUnderflow,

+    errCannotEvalXBecauseIncompletelyDefined, errChrExpectsRange0_255,

+    errDynlibRequiresExportc, errUndeclaredFieldX, errNilAccess,

+    errIndexOutOfBounds, errIndexTypesDoNotMatch, errBracketsInvalidForType,

+    errValueOutOfSetBounds, errFieldInitTwice, errFieldNotInit,

+    errExprXCannotBeCalled, errExprHasNoType, errExprXHasNoType,

+    errCastNotInSafeMode, errExprCannotBeCastedToX, errCommaOrParRiExpected,

+    errCurlyLeOrParLeExpected, errSectionExpected, errRangeExpected,

+    errMagicOnlyInSystem, errPowerOfTwoExpected,

+    errStringMayNotBeEmpty, errCallConvExpected, errProcOnlyOneCallConv,

+    errSymbolMustBeImported, errExprMustBeBool, errConstExprExpected,

+    errDuplicateCaseLabel, errRangeIsEmpty, errSelectorMustBeOfCertainTypes,

+    errSelectorMustBeOrdinal, errOrdXMustNotBeNegative, errLenXinvalid,

+    errWrongNumberOfVariables, errExprCannotBeRaised, errBreakOnlyInLoop,

+    errTypeXhasUnknownSize, errConstNeedsConstExpr, errConstNeedsValue,

+    errResultCannotBeOpenArray, errSizeTooBig, errSetTooBig,

+    errBaseTypeMustBeOrdinal, errInheritanceOnlyWithNonFinalObjects,

+    errInheritanceOnlyWithEnums, errIllegalRecursionInTypeX,

+    errCannotInstantiateX, errExprHasNoAddress, errXStackEscape,

+    errVarForOutParamNeeded,

+    errPureTypeMismatch, errTypeMismatch, errButExpected, errButExpectedX,

+    errAmbiguousCallXYZ, errWrongNumberOfArguments,

+    errXCannotBePassedToProcVar,

+    errXCannotBeInParamDecl, errPragmaOnlyInHeaderOfProc, errImplOfXNotAllowed,

+    errImplOfXexpected, errNoSymbolToBorrowFromFound, errDiscardValueX,

+    errInvalidDiscard, errIllegalConvFromXtoY, errCannotBindXTwice,

+    errInvalidOrderInArrayConstructor,

+    errInvalidOrderInEnumX, errEnumXHasHoles, errExceptExpected, errInvalidTry,

+    errOptionExpected, errXisNoLabel, errNotAllCasesCovered,

+    errUnknownSubstitionVar, errComplexStmtRequiresInd, errXisNotCallable,

+    errNoPragmasAllowedForX, errNoGenericParamsAllowedForX,

+    errInvalidParamKindX, errDefaultArgumentInvalid, errNamedParamHasToBeIdent,

+    errNoReturnTypeForX, errConvNeedsOneArg, errInvalidPragmaX,

+    errXNotAllowedHere, errInvalidControlFlowX,

+    errXisNoType, errCircumNeedsPointer, errInvalidExpression,

+    errInvalidExpressionX, errEnumHasNoValueX, errNamedExprExpected,

+    errNamedExprNotAllowed, errXExpectsOneTypeParam,

+    errArrayExpectsTwoTypeParams, errInvalidVisibilityX, errInitHereNotAllowed,

+    errXCannotBeAssignedTo, errIteratorNotAllowed, errXNeedsReturnType,

+    errNoReturnTypeDeclared,

+    errInvalidCommandX, errXOnlyAtModuleScope,

+    errXNeedsParamObjectType,

+    errTemplateInstantiationTooNested, errInstantiationFrom,

+    errInvalidIndexValueForTuple, errCommandExpectsFilename,

+    errMainModuleMustBeSpecified,

+    errXExpected,

+    errTIsNotAConcreteType,

+    errInvalidSectionStart, errGridTableNotImplemented, errGeneralParseError,

+    errNewSectionExpected, errWhitespaceExpected, errXisNoValidIndexFile,

+    errCannotRenderX, errVarVarTypeNotAllowed, errInstantiateXExplicitly,

+    errOnlyACallOpCanBeDelegator, errUsingNoSymbol,

+    errMacroBodyDependsOnGenericTypes,

+    errDestructorNotGenericEnough,

+    errInlineIteratorsAsProcParams,

+    errXExpectsTwoArguments,

+    errXExpectsObjectTypes, errXcanNeverBeOfThisSubtype, errTooManyIterations,

+    errCannotInterpretNodeX, errFieldXNotFound, errInvalidConversionFromTypeX,

+    errAssertionFailed, errCannotGenerateCodeForX, errXRequiresOneArgument,

+    errUnhandledExceptionX, errCyclicTree, errXisNoMacroOrTemplate,

+    errXhasSideEffects, errIteratorExpected, errLetNeedsInit,

+    errThreadvarCannotInit, errWrongSymbolX, errIllegalCaptureX,

+    errXCannotBeClosure, errXMustBeCompileTime,

+    errCannotInferTypeOfTheLiteral,

+    errCannotInferReturnType,

+    errGenericLambdaNotAllowed,

+    errCompilerDoesntSupportTarget,

+    errUser,

+    warnCannotOpenFile,

+    warnOctalEscape, warnXIsNeverRead, warnXmightNotBeenInit,

+    warnDeprecated, warnConfigDeprecated,

+    warnSmallLshouldNotBeUsed, warnUnknownMagic, warnRedefinitionOfLabel,

+    warnUnknownSubstitutionX, warnLanguageXNotSupported,

+    warnFieldXNotSupported, warnCommentXIgnored,

+    warnNilStatement, warnTypelessParam,

+    warnDifferentHeaps, warnWriteToForeignHeap, warnUnsafeCode,

+    warnEachIdentIsTuple, warnShadowIdent,

+    warnProveInit, warnProveField, warnProveIndex, warnGcUnsafe, warnGcUnsafe2,

+    warnUninit, warnGcMem, warnDestructor, warnLockLevel, warnResultShadowed,

+    warnUser,

+    hintSuccess, hintSuccessX,

+    hintLineTooLong, hintXDeclaredButNotUsed, hintConvToBaseNotNeeded,

+    hintConvFromXtoItselfNotNeeded, hintExprAlwaysX, hintQuitCalled,

+    hintProcessing, hintCodeBegin, hintCodeEnd, hintConf, hintPath,

+    hintConditionAlwaysTrue, hintName, hintPattern,

+    hintUser

+

+const

+  fatalMin* = errUnknown

+  fatalMax* = errInternal

+  errMin* = errUnknown

+  errMax* = errUser

+  warnMin* = warnCannotOpenFile

+  warnMax* = pred(hintSuccess)

+  hintMin* = hintSuccess

+  hintMax* = high(TMsgKind)

+

+type

+  TNoteKind* = range[warnMin..hintMax] # "notes" are warnings or hints

+  TNoteKinds* = set[TNoteKind]

+

+var

+  gNotes*: TNoteKinds = {low(TNoteKind)..high(TNoteKind)} -

+                        {warnShadowIdent, warnUninit,

+                         warnProveField, warnProveIndex, warnGcUnsafe}

+

+

+#import compiler.msgs

+

+echo warnUninit in gNotes

diff --git a/tests/showoff/tdrdobbs_examples.nim b/tests/showoff/tdrdobbs_examples.nim
index 13a685950..78f711325 100644
--- a/tests/showoff/tdrdobbs_examples.nim
+++ b/tests/showoff/tdrdobbs_examples.nim
@@ -13,7 +13,7 @@ var g = 70
 ++g
 g ++ 7
 g.`++`(10, 20)
-echo g 
+echo g
 
 
 #let lv = stdin.readline
@@ -56,7 +56,7 @@ type
     fkLit,        ## element is a literal like 0.1
     fkAdd,        ## element is an addition operation
     fkMul,        ## element is a multiplication operation
-    fkExp         ## element is an exponentiation operation 
+    fkExp         ## element is an exponentiation operation
 
 type
   Formula = ref object
@@ -78,16 +78,16 @@ proc evaluate(n: Formula, varToVal: proc (name: string): float): float =
 echo evaluate(Formula(kind: fkLit, value: 0.4), nil)
 
 proc isPolyTerm(n: Formula): bool =
-  n.kind == fkMul and n.left.kind == fkLit and (let e = n.right; 
+  n.kind == fkMul and n.left.kind == fkLit and (let e = n.right;
     e.kind == fkExp and e.left.kind == fkVar and e.right.kind == fkLit)
 
 proc isPolynomial(n: Formula): bool =
-  isPolyTerm(n) or 
+  isPolyTerm(n) or
     (n.kind == fkAdd and isPolynomial(n.left) and isPolynomial(n.right))
 
 let myFormula = Formula(kind: fkMul,
                         left: Formula(kind: fkLit, value: 2.0),
-                        right: Formula(kind: fkExp, 
+                        right: Formula(kind: fkExp,
                           left: Formula(kind: fkVar, name: "x"),
                           right: Formula(kind: fkLit, value: 5.0)))
 
@@ -104,7 +104,7 @@ proc pat2kind(pattern: string): FormulaKind =
 
 import macros
 
-proc matchAgainst(n, pattern: PNimrodNode): PNimrodNode {.compileTime.} =
+proc matchAgainst(n, pattern: NimNode): NimNode {.compileTime.} =
   template `@`(current, field: expr): expr =
     newDotExpr(current, newIdentNode(astToStr(field)))
 
diff --git a/tests/stdlib/tcount.nim b/tests/stdlib/tcount.nim
new file mode 100644
index 000000000..ce1d14b6c
--- /dev/null
+++ b/tests/stdlib/tcount.nim
@@ -0,0 +1,29 @@
+discard """
+  output: '''1
+2
+3
+4
+5
+done'''
+"""
+
+# bug #1845, #2224
+
+var arr = [3,2,1,5,4]
+
+# bubble sort
+for i in low(arr)..high(arr):
+  for j in i+1..high(arr): # Error: unhandled exception: value out of range: 5 [RangeError]
+    if arr[i] > arr[j]:
+      let tmp = arr[i]
+      arr[i] = arr[j]
+      arr[j] = tmp
+
+for i in low(arr)..high(arr):
+  echo arr[i]
+
+# check this terminates:
+for x in countdown('\255', '\0'):
+  discard
+
+echo "done"
diff --git a/tests/stdlib/tdialogs.nim b/tests/stdlib/tdialogs.nim
deleted file mode 100644
index d161a976d..000000000
--- a/tests/stdlib/tdialogs.nim
+++ /dev/null
@@ -1,17 +0,0 @@
-# Test the dialogs module
-
-import dialogs, gtk2
-
-gtk2.nimrod_init()
-
-var x = ChooseFilesToOpen(nil)
-for a in items(x):
-  writeln(stdout, a)
-
-info(nil, "start with an info box")
-warning(nil, "now a warning ...")
-error(nil, "... and an error!")
-
-writeln(stdout, ChooseFileToOpen(nil))
-writeln(stdout, ChooseFileToSave(nil))
-writeln(stdout, ChooseDir(nil))
diff --git a/tests/stdlib/tgetfileinfo.nim b/tests/stdlib/tgetfileinfo.nim
index 49a019061..8a0538a5f 100644
--- a/tests/stdlib/tgetfileinfo.nim
+++ b/tests/stdlib/tgetfileinfo.nim
@@ -32,7 +32,7 @@ proc caseOneAndTwo(followLink: bool) =
   try:
     discard getFileInfo(getAppFilename(), followLink)
     #echo("String : Existing File : Symlink $# : Success" % $followLink)
-  except EOS:
+  except OSError:
     echo("String : Existing File : Symlink $# : Failure" % $followLink)
 
 proc caseThreeAndFour(followLink: bool) =
@@ -40,7 +40,8 @@ proc caseThreeAndFour(followLink: bool) =
   try:
     discard getFileInfo(invalidName, true)
     echo("String : Non-existing File : Symlink $# : Failure" % $followLink)
-  except EOS:
+  except OSError:
+    discard
     #echo("String : Non-existing File : Symlink $# : Success" % $followLink)
 
 proc testGetFileInfo =
@@ -64,13 +65,13 @@ proc testGetFileInfo =
     try:
       discard getFileInfo(testFile)
       #echo("Handle : Valid File : Success")
-    except EIO:
+    except IOError:
       echo("Handle : Valid File : Failure")
 
     try:
       discard getFileInfo(testHandle)
       #echo("Handle : Valid File : Success")
-    except EIO:
+    except IOError:
       echo("Handle : Valid File : Failure")
 
   # Case 6 and 8
@@ -81,13 +82,15 @@ proc testGetFileInfo =
     try:
       discard getFileInfo(testFile)
       echo("Handle : Invalid File : Failure")
-    except EIO, EOS:
+    except IOError, OSError:
+      discard
       #echo("Handle : Invalid File : Success")
 
     try:
       discard getFileInfo(testHandle)
       echo("Handle : Invalid File : Failure")
-    except EIO, EOS:
+    except IOError, OSError:
+      discard
       #echo("Handle : Invalid File : Success")
 
-testGetFileInfo()
\ No newline at end of file
+testGetFileInfo()
diff --git a/tests/stdlib/tircbot.nim b/tests/stdlib/tircbot.nim
deleted file mode 100644
index b91300762..000000000
--- a/tests/stdlib/tircbot.nim
+++ /dev/null
@@ -1,452 +0,0 @@
-import irc, sockets, asyncio, json, os, strutils, times, redis
-
-type
-  TDb* = object
-    r*: TRedis
-    lastPing: float
-
-  TBuildResult* = enum
-    bUnknown, bFail, bSuccess
-
-  TTestResult* = enum
-    tUnknown, tFail, tSuccess
-
-  TEntry* = tuple[c: TCommit, p: seq[TPlatform]]
-  
-  TCommit* = object
-    commitMsg*, username*, hash*: string
-    date*: TTime
-
-  TPlatform* = object
-    buildResult*: TBuildResult
-    testResult*: TTestResult
-    failReason*, platform*: string
-    total*, passed*, skipped*, failed*: biggestInt
-    csources*: bool
-
-const
-  listName = "commits"
-  failOnExisting = False
-
-proc open*(host = "localhost", port: TPort): TDb =
-  result.r = redis.open(host, port)
-  result.lastPing = epochTime()
-
-discard """proc customHSet(database: TDb, name, field, value: string) =
-  if database.r.hSet(name, field, value).int == 0:
-    if failOnExisting:
-      assert(false)
-    else:
-      echo("[Warning:REDIS] ", field, " already exists in ", name)"""
-
-proc updateProperty*(database: TDb, commitHash, platform, property,
-                    value: string) =
-  var name = platform & ":" & commitHash
-  if database.r.hSet(name, property, value).int == 0:
-    echo("[INFO:REDIS] '$1' field updated in hash" % [property])
-  else:
-    echo("[INFO:REDIS] '$1' new field added to hash" % [property])
-
-proc globalProperty*(database: TDb, commitHash, property, value: string) =
-  if database.r.hSet(commitHash, property, value).int == 0:
-    echo("[INFO:REDIS] '$1' field updated in hash" % [property])
-  else:
-    echo("[INFO:REDIS] '$1' new field added to hash" % [property])
-
-proc addCommit*(database: TDb, commitHash, commitMsg, user: string) =
-  # Add the commit hash to the `commits` list.
-  discard database.r.lPush(listName, commitHash)
-  # Add the commit message, current date and username as a property
-  globalProperty(database, commitHash, "commitMsg", commitMsg)
-  globalProperty(database, commitHash, "date", $int(getTime()))
-  globalProperty(database, commitHash, "username", user)
-
-proc keepAlive*(database: var TDb) =
-  ## Keep the connection alive. Ping redis in this case. This functions does
-  ## not guarantee that redis will be pinged.
-  var t = epochTime()
-  if t - database.lastPing >= 60.0:
-    echo("PING -> redis")
-    assert(database.r.ping() == "PONG")
-    database.lastPing = t
-    
-proc getCommits*(database: TDb,
-                 plStr: var seq[string]): seq[TEntry] =
-  result = @[]
-  var commitsRaw = database.r.lrange("commits", 0, -1)
-  for c in items(commitsRaw):
-    var commit: TCommit
-    commit.hash = c
-    for key, value in database.r.hPairs(c):
-      case normalize(key)
-      of "commitmsg": commit.commitMsg = value
-      of "date": commit.date = TTime(parseInt(value))
-      of "username": commit.username = value
-      else:
-        echo(key)
-        assert(false)
-
-    var platformsRaw = database.r.lrange(c & ":platforms", 0, -1)
-    var platforms: seq[TPlatform] = @[]
-    for p in items(platformsRaw):
-      var platform: TPlatform
-      for key, value in database.r.hPairs(p & ":" & c):
-        case normalize(key)
-        of "buildresult":
-          platform.buildResult = parseInt(value).TBuildResult
-        of "testresult":
-          platform.testResult = parseInt(value).TTestResult
-        of "failreason":
-          platform.failReason = value
-        of "total":
-          platform.total = parseBiggestInt(value)
-        of "passed":
-          platform.passed = parseBiggestInt(value)
-        of "skipped":
-          platform.skipped = parseBiggestInt(value)
-        of "failed":
-          platform.failed = parseBiggestInt(value)
-        of "csources":
-          platform.csources = if value == "t": true else: false
-        else:
-          echo(normalize(key))
-          assert(false)
-      
-      platform.platform = p
-      
-      platforms.add(platform)
-      if p notin plStr:
-        plStr.add(p)
-    result.add((commit, platforms))
-
-proc commitExists*(database: TDb, commit: string, starts = false): bool =
-  # TODO: Consider making the 'commits' list a set.
-  for c in items(database.r.lrange("commits", 0, -1)):
-    if starts:
-      if c.startsWith(commit): return true
-    else:
-      if c == commit: return true
-  return false
-
-proc platformExists*(database: TDb, commit: string, platform: string): bool =
-  for p in items(database.r.lrange(commit & ":" & "platforms", 0, -1)):
-    if p == platform: return true
-
-proc expandHash*(database: TDb, commit: string): string =
-  for c in items(database.r.lrange("commits", 0, -1)):
-    if c.startsWith(commit): return c
-  assert false
-
-proc isNewest*(database: TDb, commit: string): bool =
-  return database.r.lIndex("commits", 0) == commit
-
-proc getNewest*(database: TDb): string =
-  return database.r.lIndex("commits", 0)
-
-proc addPlatform*(database: TDb, commit: string, platform: string) =
-  assert database.commitExists(commit)
-  assert (not database.platformExists(commit, platform))
-  var name = platform & ":" & commit
-  if database.r.exists(name):
-    if failOnExisting: quit("[FAIL] " & name & " already exists!", 1)
-    else: echo("[Warning] " & name & " already exists!")
-
-  discard database.r.lPush(commit & ":" & "platforms", platform)
-
-proc `[]`*(p: seq[TPlatform], name: string): TPlatform =
-  for platform in items(p):
-    if platform.platform == name:
-      return platform
-  raise newException(EInvalidValue, name & " platforms not found in commits.")
-  
-proc contains*(p: seq[TPlatform], s: string): bool =
-  for i in items(p):
-    if i.platform == s:
-      return True
-    
-
-type
-  PState = ref TState
-  TState = object of TObject
-    dispatcher: PDispatcher
-    sock: PAsyncSocket
-    ircClient: PAsyncIRC
-    hubPort: TPort
-    database: TDb
-    dbConnected: bool
-
-  TSeenType = enum
-    PSeenJoin, PSeenPart, PSeenMsg, PSeenNick, PSeenQuit
-  
-  TSeen = object
-    nick: string
-    channel: string
-    timestamp: TTime
-    case kind*: TSeenType
-    of PSeenJoin: nil
-    of PSeenPart, PSeenQuit, PSeenMsg:
-      msg: string
-    of PSeenNick:
-      newNick: string
-
-const
-  ircServer = "irc.freenode.net"
-  joinChans = @["#nim"]
-  botNickname = "NimBot"
-
-proc setSeen(d: TDb, s: TSeen) =
-  discard d.r.del("seen:" & s.nick)
-
-  var hashToSet = @[("type", $s.kind.int), ("channel", s.channel),
-                    ("timestamp", $s.timestamp.int)]
-  case s.kind
-  of PSeenJoin: discard
-  of PSeenPart, PSeenMsg, PSeenQuit:
-    hashToSet.add(("msg", s.msg))
-  of PSeenNick:
-    hashToSet.add(("newnick", s.newNick))
-  
-  d.r.hMSet("seen:" & s.nick, hashToSet)
-
-proc getSeen(d: TDb, nick: string, s: var TSeen): bool =
-  if d.r.exists("seen:" & nick):
-    result = true
-    s.nick = nick
-    # Get the type first
-    s.kind = d.r.hGet("seen:" & nick, "type").parseInt.TSeenType
-    
-    for key, value in d.r.hPairs("seen:" & nick):
-      case normalize(key)
-      of "type":
-        #s.kind = value.parseInt.TSeenType
-      of "channel":
-        s.channel = value
-      of "timestamp":
-        s.timestamp = TTime(value.parseInt)
-      of "msg":
-        s.msg = value
-      of "newnick":
-        s.newNick = value
-
-template createSeen(typ: TSeenType, n, c: string): stmt {.immediate, dirty.} =
-  var seenNick: TSeen
-  seenNick.kind = typ
-  seenNick.nick = n
-  seenNick.channel = c
-  seenNick.timestamp = getTime()
-
-proc parseReply(line: string, expect: string): Bool =
-  var jsonDoc = parseJson(line)
-  return jsonDoc["reply"].str == expect
-
-proc limitCommitMsg(m: string): string =
-  ## Limits the message to 300 chars and adds ellipsis.
-  var m1 = m
-  if NewLines in m1:
-    m1 = m1.splitLines()[0]
-  
-  if m1.len >= 300:
-    m1 = m1[0..300]
-
-  if m1.len >= 300 or NewLines in m: m1.add("... ")
-
-  if NewLines in m: m1.add($m.splitLines().len & " more lines")
-
-  return m1
-
-proc handleWebMessage(state: PState, line: string) =
-  echo("Got message from hub: " & line)
-  var json = parseJson(line)
-  if json.hasKey("payload"):
-    for i in 0..min(4, json["payload"]["commits"].len-1):
-      var commit = json["payload"]["commits"][i]
-      # Create the message
-      var message = ""
-      message.add(json["payload"]["repository"]["owner"]["name"].str & "/" &
-                  json["payload"]["repository"]["name"].str & " ")
-      message.add(commit["id"].str[0..6] & " ")
-      message.add(commit["author"]["name"].str & " ")
-      message.add("[+" & $commit["added"].len & " ")
-      message.add("±" & $commit["modified"].len & " ")
-      message.add("-" & $commit["removed"].len & "]: ")
-      message.add(limitCommitMsg(commit["message"].str))
-
-      # Send message to #nim.
-      state.ircClient.privmsg(joinChans[0], message)
-  elif json.hasKey("redisinfo"):
-    assert json["redisinfo"].hasKey("port")
-    #let redisPort = json["redisinfo"]["port"].num
-    state.dbConnected = true
-
-proc hubConnect(state: PState)
-proc handleConnect(s: PAsyncSocket, state: PState) =
-  try:
-    # Send greeting
-    var obj = newJObject()
-    obj["name"] = newJString("irc")
-    obj["platform"] = newJString("?")
-    state.sock.send($obj & "\c\L")
-
-    # Wait for reply.
-    var line = ""
-    sleep(1500)
-    if state.sock.recvLine(line):
-      assert(line != "")
-      doAssert parseReply(line, "OK")
-      echo("The hub accepted me!")
-    else:
-      raise newException(EInvalidValue,
-                         "Hub didn't accept me. Waited 1.5 seconds.")
-    
-    # ask for the redis info
-    var riobj = newJObject()
-    riobj["do"] = newJString("redisinfo")
-    state.sock.send($riobj & "\c\L")
-    
-  except EOS:
-    echo(getCurrentExceptionMsg())
-    s.close()
-    echo("Waiting 5 seconds...")
-    sleep(5000)
-    state.hubConnect()
-
-proc handleRead(s: PAsyncSocket, state: PState) =
-  var line = ""
-  if state.sock.recvLine(line):
-    if line != "":
-      # Handle the message
-      state.handleWebMessage(line)
-    else:
-      echo("Disconnected from hub: ", OSErrorMsg())
-      s.close()
-      echo("Reconnecting...")
-      state.hubConnect()
-  else:
-    echo(OSErrorMsg())
-
-proc hubConnect(state: PState) =
-  state.sock = AsyncSocket()
-  state.sock.connect("127.0.0.1", state.hubPort)
-  state.sock.handleConnect =
-    proc (s: PAsyncSocket) =
-      handleConnect(s, state)
-  state.sock.handleRead =
-    proc (s: PAsyncSocket) =
-      handleRead(s, state)
-
-  state.dispatcher.register(state.sock)
-
-proc handleIrc(irc: PAsyncIRC, event: TIRCEvent, state: PState) =
-  case event.typ
-  of EvConnected: discard
-  of EvDisconnected:
-    while not state.ircClient.isConnected:
-      try:
-        state.ircClient.connect()
-      except:
-        echo("Error reconnecting: ", getCurrentExceptionMsg())
-      
-      echo("Waiting 5 seconds...")
-      sleep(5000)
-    echo("Reconnected successfully!")
-  of EvMsg:
-    echo("< ", event.raw)
-    case event.cmd
-    of MPrivMsg:
-      let msg = event.params[event.params.len-1]
-      let words = msg.split(' ')
-      template pm(msg: string): stmt =
-        state.ircClient.privmsg(event.origin, msg)
-      case words[0]
-      of "!ping": pm("pong")
-      of "!lag":
-        if state.ircClient.getLag != -1.0:
-          var lag = state.ircClient.getLag
-          lag = lag * 1000.0
-          pm($int(lag) & "ms between me and the server.")
-        else:
-          pm("Unknown.")
-      of "!seen":
-        if words.len > 1:
-          let nick = words[1]
-          if nick == botNickname:
-            pm("Yes, I see myself.")
-          echo(nick)
-          var seenInfo: TSeen
-          if state.database.getSeen(nick, seenInfo):
-            #var mSend = ""
-            case seenInfo.kind
-            of PSeenMsg:
-              pm("$1 was last seen on $2 in $3 saying: $4" %
-                    [seenInfo.nick, $seenInfo.timestamp,
-                     seenInfo.channel, seenInfo.msg])
-            of PSeenJoin:
-              pm("$1 was last seen on $2 joining $3" %
-                        [seenInfo.nick, $seenInfo.timestamp, seenInfo.channel])
-            of PSeenPart:
-              pm("$1 was last seen on $2 leaving $3 with message: $4" %
-                        [seenInfo.nick, $seenInfo.timestamp, seenInfo.channel,
-                         seenInfo.msg])
-            of PSeenQuit:
-              pm("$1 was last seen on $2 quitting with message: $3" %
-                        [seenInfo.nick, $seenInfo.timestamp, seenInfo.msg])
-            of PSeenNick:
-              pm("$1 was last seen on $2 changing nick to $3" %
-                        [seenInfo.nick, $seenInfo.timestamp, seenInfo.newNick])
-            
-          else:
-            pm("I have not seen " & nick)
-        else:
-          pm("Syntax: !seen <nick>")
-
-      # TODO: ... commands
-
-      # -- Seen
-      # Log this as activity.
-      createSeen(PSeenMsg, event.nick, event.origin)
-      seenNick.msg = msg
-      state.database.setSeen(seenNick)
-    of MJoin:
-      createSeen(PSeenJoin, event.nick, event.origin)
-      state.database.setSeen(seenNick)
-    of MPart:
-      createSeen(PSeenPart, event.nick, event.origin)
-      let msg = event.params[event.params.high]
-      seenNick.msg = msg
-      state.database.setSeen(seenNick)
-    of MQuit:
-      createSeen(PSeenQuit, event.nick, event.origin)
-      let msg = event.params[event.params.high]
-      seenNick.msg = msg
-      state.database.setSeen(seenNick)
-    of MNick:
-      createSeen(PSeenNick, event.nick, "#nim")
-      seenNick.newNick = event.params[0]
-      state.database.setSeen(seenNick)
-    else:
-      discard # TODO: ?
-
-proc open(port: TPort = TPort(5123)): PState =
-  var res: PState
-  new(res)
-  res.dispatcher = newDispatcher()
-  
-  res.hubPort = port
-  res.hubConnect()
-  let hirc =
-    proc (a: PAsyncIRC, ev: TIRCEvent) =
-      handleIrc(a, ev, res)
-  # Connect to the irc server.
-  res.ircClient = AsyncIrc(ircServer, nick = botNickname, user = botNickname,
-                 joinChans = joinChans, ircEvent = hirc)
-  res.ircClient.connect()
-  res.dispatcher.register(res.ircClient)
-
-  res.dbConnected = false
-  result = res
-
-var state = tircbot.open() # Connect to the website and the IRC server.
-
-while state.dispatcher.poll():
-  if state.dbConnected:
-    state.database.keepAlive()
diff --git a/tests/stdlib/tmarshal.nim b/tests/stdlib/tmarshal.nim
index 1b83aab53..a778d2f77 100644
--- a/tests/stdlib/tmarshal.nim
+++ b/tests/stdlib/tmarshal.nim
@@ -6,11 +6,11 @@ import marshal
 
 template testit(x: expr) = discard $$to[type(x)]($$x)
 
-var x: array[0..4, array[0..4, string]] = [

-  ["test", "1", "2", "3", "4"], ["test", "1", "2", "3", "4"], 

-  ["test", "1", "2", "3", "4"], ["test", "1", "2", "3", "4"], 

-  ["test", "1", "2", "3", "4"]]

-testit(x)

+var x: array[0..4, array[0..4, string]] = [
+  ["test", "1", "2", "3", "4"], ["test", "1", "2", "3", "4"],
+  ["test", "1", "2", "3", "4"], ["test", "1", "2", "3", "4"],
+  ["test", "1", "2", "3", "4"]]
+testit(x)
 var test2: tuple[name: string, s: int] = ("tuple test", 56)
 testit(test2)
 
@@ -24,7 +24,7 @@ type
     of blah:
       help: string
     else:
-      nil
+      discard
       
   PNode = ref TNode
   TNode = object
diff --git a/tests/stdlib/tmitems.nim b/tests/stdlib/tmitems.nim
new file mode 100644
index 000000000..2c0a0392a
--- /dev/null
+++ b/tests/stdlib/tmitems.nim
@@ -0,0 +1,136 @@
+discard """
+  output: '''@[11, 12, 13]
+@[11, 12, 13]
+@[1, 3, 5]
+@[1, 3, 5]
+gppcbs
+gppcbs
+fpqeew
+fpqeew
+[11, 12, 13]
+[11, 12, 13]
+[11, 12, 13]
+[11, 12, 13]
+{"key1": 11, "key2": 12, "key3": 13}
+[11, 12, 13]
+<Students>
+  <Student Name="Aprilfoo" />
+  <Student Name="bar" />
+</Students>'''
+"""
+
+block:
+  var xs = @[1,2,3]
+  for x in xs.mitems:
+    x += 10
+  echo xs
+
+block:
+  var xs = [1,2,3]
+  for x in xs.mitems:
+    x += 10
+  echo(@xs)
+
+block:
+  var xs = @[1,2,3]
+  for i, x in xs.mpairs:
+    x += i
+  echo xs
+
+block:
+  var xs = [1,2,3]
+  for i, x in xs.mpairs:
+    x += i
+  echo(@xs)
+
+block:
+  var x = "foobar"
+  for c in x.mitems:
+    inc c
+  echo x
+
+block:
+  var x = "foobar"
+  var y = cast[cstring](addr x[0])
+  for c in y.mitems:
+    inc c
+  echo x
+
+block:
+  var x = "foobar"
+  for i, c in x.mpairs:
+    inc c, i
+  echo x
+
+block:
+  var x = "foobar"
+  var y = cast[cstring](addr x[0])
+  for i, c in y.mpairs:
+    inc c, i
+  echo x
+
+import lists
+
+block:
+  var sl = initSinglyLinkedList[int]()
+  sl.prepend(3)
+  sl.prepend(2)
+  sl.prepend(1)
+  for x in sl.mitems:
+    x += 10
+  echo sl
+
+block:
+  var sl = initDoublyLinkedList[int]()
+  sl.append(1)
+  sl.append(2)
+  sl.append(3)
+  for x in sl.mitems:
+    x += 10
+  echo sl
+
+block:
+  var sl = initDoublyLinkedRing[int]()
+  sl.append(1)
+  sl.append(2)
+  sl.append(3)
+  for x in sl.mitems:
+    x += 10
+  echo sl
+
+import queues
+
+block:
+  var q = initQueue[int]()
+  q.add(1)
+  q.add(2)
+  q.add(3)
+  for x in q.mitems:
+    x += 10
+  echo q
+
+import json
+
+block:
+  var j = parseJson """{"key1": 1, "key2": 2, "key3": 3}"""
+  for key,val in j.pairs:
+    val.num += 10
+  echo j
+
+block:
+  var j = parseJson """[1, 2, 3]"""
+  for x in j.mitems:
+    x.num += 10
+  echo j
+
+import xmltree, xmlparser, streams, strtabs
+
+block:
+  var d = parseXml(newStringStream """<Students>
+    <Student Name="April" Gender="F" DateOfBirth="1989-01-02" />
+    <Student Name="Bob" Gender="M"  DateOfBirth="1990-03-04" />
+  </Students>""")
+  for x in d.mitems:
+    x = <>Student(Name=x.attrs["Name"] & "foo")
+  d.mget(1).attrs["Name"] = "bar"
+  echo d
diff --git a/tests/stdlib/tnet.nim b/tests/stdlib/tnet.nim
new file mode 100644
index 000000000..e8ada05e7
--- /dev/null
+++ b/tests/stdlib/tnet.nim
@@ -0,0 +1,47 @@
+import net
+import unittest
+
+suite "isIpAddress tests":
+  test "127.0.0.1 is valid":
+    check isIpAddress("127.0.0.1") == true
+
+  test "ipv6 localhost is valid":
+    check isIpAddress("::1") == true
+
+  test "fqdn is not an ip address":
+    check isIpAddress("example.com") == false
+
+  test "random string is not an ipaddress":
+    check isIpAddress("foo bar") == false
+
+  test "5127.0.0.1 is invalid":
+    check isIpAddress("5127.0.0.1") == false
+
+  test "ipv6 is valid":
+    check isIpAddress("2001:cdba:0000:0000:0000:0000:3257:9652") == true
+
+  test "invalid ipv6":
+    check isIpAddress("gggg:cdba:0000:0000:0000:0000:3257:9652") == false
+
+
+suite "parseIpAddress tests":
+  test "127.0.0.1 is valid":
+    discard parseIpAddress("127.0.0.1")
+
+  test "ipv6 localhost is valid":
+    discard parseIpAddress("::1")
+
+  test "fqdn is not an ip address":
+    expect(ValueError):
+      discard parseIpAddress("example.com")
+
+  test "random string is not an ipaddress":
+    expect(ValueError):
+      discard parseIpAddress("foo bar")
+
+  test "ipv6 is valid":
+    discard parseIpAddress("2001:cdba:0000:0000:0000:0000:3257:9652")
+
+  test "invalid ipv6":
+    expect(ValueError):
+      discard parseIpAddress("gggg:cdba:0000:0000:0000:0000:3257:9652")
diff --git a/tests/stdlib/tpegs.nim b/tests/stdlib/tpegs.nim
index 1bc2669c3..cceea1693 100644
--- a/tests/stdlib/tpegs.nim
+++ b/tests/stdlib/tpegs.nim
@@ -533,7 +533,7 @@ proc bounds*(c: TCaptures,
 
 when not useUnicode:
   type
-    TRune = char
+    Rune = char
   template fastRuneAt(s, i, ch: expr) =
     ch = s[i]
     inc(i)
@@ -563,7 +563,7 @@ proc rawMatch*(s: string, p: TPeg, start: int, c: var TCaptures): int {.
       result = -1
   of pkLetter: 
     if s[start] != '\0':
-      var a: TRune
+      var a: Rune
       result = start
       fastRuneAt(s, result, a)
       if isAlpha(a): dec(result, start)
@@ -572,7 +572,7 @@ proc rawMatch*(s: string, p: TPeg, start: int, c: var TCaptures): int {.
       result = -1
   of pkLower: 
     if s[start] != '\0':
-      var a: TRune
+      var a: Rune
       result = start
       fastRuneAt(s, result, a)
       if isLower(a): dec(result, start)
@@ -581,7 +581,7 @@ proc rawMatch*(s: string, p: TPeg, start: int, c: var TCaptures): int {.
       result = -1
   of pkUpper: 
     if s[start] != '\0':
-      var a: TRune
+      var a: Rune
       result = start
       fastRuneAt(s, result, a)
       if isUpper(a): dec(result, start)
@@ -590,7 +590,7 @@ proc rawMatch*(s: string, p: TPeg, start: int, c: var TCaptures): int {.
       result = -1
   of pkTitle: 
     if s[start] != '\0':
-      var a: TRune
+      var a: Rune
       result = start
       fastRuneAt(s, result, a)
       if isTitle(a): dec(result, start) 
@@ -599,7 +599,7 @@ proc rawMatch*(s: string, p: TPeg, start: int, c: var TCaptures): int {.
       result = -1
   of pkWhitespace: 
     if s[start] != '\0':
-      var a: TRune
+      var a: Rune
       result = start
       fastRuneAt(s, result, a)
       if isWhitespace(a): dec(result, start)
@@ -623,7 +623,7 @@ proc rawMatch*(s: string, p: TPeg, start: int, c: var TCaptures): int {.
   of pkTerminalIgnoreCase:
     var
       i = 0
-      a, b: TRune
+      a, b: Rune
     result = start
     while i < len(p.term):
       fastRuneAt(p.term, i, a)
@@ -635,15 +635,15 @@ proc rawMatch*(s: string, p: TPeg, start: int, c: var TCaptures): int {.
   of pkTerminalIgnoreStyle:
     var
       i = 0
-      a, b: TRune
+      a, b: Rune
     result = start
     while i < len(p.term):
       while true:
         fastRuneAt(p.term, i, a)
-        if a != TRune('_'): break
+        if a != Rune('_'): break
       while true:
         fastRuneAt(s, result, b)
-        if b != TRune('_'): break
+        if b != Rune('_'): break
       if toLower(a) != toLower(b):
         result = -1
         break
@@ -865,7 +865,7 @@ template `=~`*(s: string, pattern: TPeg): expr =
   ##   else:
   ##     echo("syntax error")
   ##  
-  when not definedInScope(matches):
+  when not declaredInScope(matches):
     var matches {.inject.}: array[0..MaxSubpatterns-1, string]
   match(s, pattern, matches)
 
@@ -964,7 +964,7 @@ proc transformFile*(infile, outfile: string,
   ## error occurs. This is supposed to be used for quick scripting.
   var x = readFile(infile)
   if not isNil(x):
-    var f: TFile
+    var f: File
     if open(f, outfile, fmWrite):
       write(f, x.parallelReplace(subs))
       close(f)
@@ -1404,8 +1404,8 @@ proc arrowIsNextTok(c: TPegLexer): bool =
 # ----------------------------- parser ----------------------------------------
     
 type
-  EInvalidPeg* = object of EInvalidValue ## raised if an invalid
-                                         ## PEG has been detected
+  EInvalidPeg* = object of ValueError ## raised if an invalid
+                                      ## PEG has been detected
   TPegParser = object of TPegLexer ## the PEG parser object
     tok: TToken
     nonterms: seq[PNonTerminal]
diff --git a/tests/stdlib/tpermutations.nim b/tests/stdlib/tpermutations.nim
new file mode 100644
index 000000000..a6e07ded6
--- /dev/null
+++ b/tests/stdlib/tpermutations.nim
@@ -0,0 +1,19 @@
+discard """
+  output: '''@[0, 2, 1]
+@[1, 0, 2]
+@[1, 2, 0]
+@[2, 0, 1]
+@[2, 1, 0]
+@[2, 0, 1]
+@[1, 2, 0]
+@[1, 0, 2]
+@[0, 2, 1]
+@[0, 1, 2]'''
+"""
+import algorithm
+
+var v = @[0, 1, 2]
+while v.nextPermutation():
+  echo v
+while v.prevPermutation():
+  echo v
diff --git a/tests/stdlib/treloop.nim b/tests/stdlib/treloop.nim
new file mode 100644
index 000000000..35236708c
--- /dev/null
+++ b/tests/stdlib/treloop.nim
@@ -0,0 +1,9 @@
+discard """
+  output: "@[(, +,  1,  2, )]"
+"""
+
+import re
+
+let str = "(+ 1 2)"
+var tokenRE = re"""[\s,]*(~@|[\[\]{}()'`~^@]|"(?:\\.|[^\\"])*"|;.*|[^\s\[\]{}('"`,;)]*)"""
+echo str.findAll(tokenRE)
diff --git a/tests/stdlib/tsinglylinkedring.nim b/tests/stdlib/tsinglylinkedring.nim
new file mode 100644
index 000000000..93f0c69cd
--- /dev/null
+++ b/tests/stdlib/tsinglylinkedring.nim
@@ -0,0 +1,29 @@
+discard """
+  output: '''[5]
+[4, 5]
+[3, 4, 5]
+[2, 3, 4, 5]
+[2, 3, 4, 5, 6]
+[2, 3, 4, 5, 6, 7]
+[2, 3, 4, 5, 6, 7, 8]
+[1, 2, 3, 4, 5, 6, 7, 8]'''
+"""
+import lists
+
+var r = initSinglyLinkedRing[int]()
+r.prepend(5)
+echo r
+r.prepend(4)
+echo r
+r.prepend(3)
+echo r
+r.prepend(2)
+echo r
+r.append(6)
+echo r
+r.append(7)
+echo r
+r.append(8)
+echo r
+r.prepend(1)
+echo r
diff --git a/tests/stdlib/tstrutil.nim b/tests/stdlib/tstrutil.nim
index da65d1f89..3db484faa 100644
--- a/tests/stdlib/tstrutil.nim
+++ b/tests/stdlib/tstrutil.nim
@@ -2,18 +2,18 @@ discard """
   file: "tstrutil.nim"
   output: "ha/home/a1xyz/usr/bin"
 """
-# test the new strutils module

-

-import

-  strutils

-

-proc testStrip() =

-  write(stdout, strip("  ha  "))

-

-proc main() = 

-  testStrip()

-  for p in split("/home/a1:xyz:/usr/bin", {':'}):

-    write(stdout, p)

+# test the new strutils module
+
+import
+  strutils
+
+proc testStrip() =
+  write(stdout, strip("  ha  "))
+
+proc main() = 
+  testStrip()
+  for p in split("/home/a1:xyz:/usr/bin", {':'}):
+    write(stdout, p)
 
 proc testDelete = 
   var s = "0123456789ABCDEFGH"
@@ -25,25 +25,34 @@ proc testDelete =
   assert s == "1236789ABCDEFG"
 
 testDelete()  
-    

+    
 assert(insertSep($1000_000) == "1_000_000")
 assert(insertSep($232) == "232")
 assert(insertSep($12345, ',') == "12,345")
 assert(insertSep($0) == "0")
-

-assert(editDistance("prefix__hallo_suffix", "prefix__hallo_suffix") == 0)

-assert(editDistance("prefix__hallo_suffix", "prefix__hallo_suffi1") == 1)

-assert(editDistance("prefix__hallo_suffix", "prefix__HALLO_suffix") == 5)

-assert(editDistance("prefix__hallo_suffix", "prefix__ha_suffix") == 3)

-assert(editDistance("prefix__hallo_suffix", "prefix") == 14)

-assert(editDistance("prefix__hallo_suffix", "suffix") == 14)

-assert(editDistance("prefix__hallo_suffix", "prefix__hao_suffix") == 2)

+
+assert(editDistance("prefix__hallo_suffix", "prefix__hallo_suffix") == 0)
+assert(editDistance("prefix__hallo_suffix", "prefix__hallo_suffi1") == 1)
+assert(editDistance("prefix__hallo_suffix", "prefix__HALLO_suffix") == 5)
+assert(editDistance("prefix__hallo_suffix", "prefix__ha_suffix") == 3)
+assert(editDistance("prefix__hallo_suffix", "prefix") == 14)
+assert(editDistance("prefix__hallo_suffix", "suffix") == 14)
+assert(editDistance("prefix__hallo_suffix", "prefix__hao_suffix") == 2)
 
 assert "/1/2/3".rfind('/') == 4
 assert "/1/2/3".rfind('/', 1) == 0
 assert "/1/2/3".rfind('0') == -1
-

-main()

-#OUT ha/home/a1xyz/usr/bin

 
+assert(toHex(100i16, 32) == "00000000000000000000000000000064")
+assert(toHex(-100i16, 32) == "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF9C")
+
+assert(' '.repeat(8)== "        ")
+assert(" ".repeat(8) == "        ")
+assert(spaces(8) == "        ")
+
+assert(' '.repeat(0) == "")
+assert(" ".repeat(0) == "")
+assert(spaces(0) == "")
 
+main()
+#OUT ha/home/a1xyz/usr/bin
diff --git a/tests/system/tsettostring.nim b/tests/system/tsettostring.nim
new file mode 100644
index 000000000..c6846ee99
--- /dev/null
+++ b/tests/system/tsettostring.nim
@@ -0,0 +1,8 @@
+discard """
+  output: "{a, b, c}"
+"""
+
+# bug #2395
+
+let alphaSet: set[char] = {'a'..'c'}
+echo alphaSet
diff --git a/tests/table/ttables.nim b/tests/table/ttables.nim
deleted file mode 100644
index de4aaed5e..000000000
--- a/tests/table/ttables.nim
+++ /dev/null
@@ -1,128 +0,0 @@
-discard """
-  output: '''true'''
-"""
-
-import hashes, tables
-
-const
-  data = {
-    "34": 123456, "12": 789,
-    "90": 343, "0": 34404,
-    "1": 344004, "2": 344774,
-    "3": 342244, "4": 3412344,
-    "5": 341232144, "6": 34214544,
-    "7": 3434544, "8": 344544,
-    "9": 34435644, "---00": 346677844,
-    "10": 34484, "11": 34474, "19": 34464,
-    "20": 34454, "30": 34141244, "40": 344114,
-    "50": 344490, "60": 344491, "70": 344492,
-    "80": 344497}
-
-  sorteddata = {
-    "---00": 346677844,
-    "0": 34404,
-    "1": 344004,
-    "10": 34484, 
-    "11": 34474,
-    "12": 789,
-    "19": 34464,
-    "2": 344774, "20": 34454, 
-    "3": 342244, "30": 34141244,
-    "34": 123456,
-    "4": 3412344, "40": 344114,
-    "5": 341232144, "50": 344490, 
-    "6": 34214544, "60": 344491,
-    "7": 3434544, "70": 344492,
-    "8": 344544, "80": 344497,
-    "9": 34435644,
-    "90": 343}
-
-block tableTest1:
-  var t = initTable[tuple[x, y: int], string]()
-  t[(0,0)] = "00"
-  t[(1,0)] = "10"
-  t[(0,1)] = "01"
-  t[(1,1)] = "11"
-  for x in 0..1:
-    for y in 0..1:
-      assert t[(x,y)] == $x & $y
-  assert($t == 
-    "{(x: 0, y: 0): 00, (x: 0, y: 1): 01, (x: 1, y: 0): 10, (x: 1, y: 1): 11}")
-
-block tableTest2:
-  var t = initTable[string, float]()
-  t["test"] = 1.2345
-  t["111"] = 1.000043
-  t["123"] = 1.23
-  t.del("111")
-  
-  t["012"] = 67.9
-  t["123"] = 1.5 # test overwriting
-  
-  assert t["123"] == 1.5
-  assert t["111"] == 0.0 # deleted
-  assert(not hasKey(t, "111"))
-  
-  for key, val in items(data): t[key] = val.toFloat
-  for key, val in items(data): assert t[key] == val.toFloat
-  
-
-block orderedTableTest1:
-  var t = initOrderedTable[string, int](2)
-  for key, val in items(data): t[key] = val
-  for key, val in items(data): assert t[key] == val
-  var i = 0
-  # `pairs` needs to yield in insertion order:
-  for key, val in pairs(t):
-    assert key == data[i][0]
-    assert val == data[i][1]
-    inc(i)
-
-  for key, val in mpairs(t): val = 99
-  for val in mvalues(t): assert val == 99
-
-block countTableTest1:
-  var s = data.toTable
-  var t = initCountTable[string]()
-  for k in s.keys: t.inc(k)
-  for k in t.keys: assert t[k] == 1
-  t.inc("90", 3)
-  t.inc("12", 2)
-  t.inc("34", 1)
-  assert t.largest()[0] == "90"
-
-  t.sort()
-  var i = 0
-  for k, v in t.pairs:
-    case i
-    of 0: assert k == "90" and v == 4
-    of 1: assert k == "12" and v == 3
-    of 2: assert k == "34" and v == 2
-    else: break
-    inc i
-
-block SyntaxTest:
-  var x = toTable[int, string]({:})
-
-proc orderedTableSortTest() =
-  var t = initOrderedTable[string, int](2)
-  for key, val in items(data): t[key] = val
-  for key, val in items(data): assert t[key] == val
-  t.sort(proc (x, y: tuple[key: string, val: int]): int = cmp(x.key, y.key))
-  var i = 0
-  # `pairs` needs to yield in sorted order:
-  for key, val in pairs(t):
-    doAssert key == sorteddata[i][0]
-    doAssert val == sorteddata[i][1]
-    inc(i)
-
-  # check that lookup still works:
-  for key, val in pairs(t):
-    doAssert val == t[key]
-  # check that insert still works:
-  t["newKeyHere"] = 80
-
-
-orderedTableSortTest()
-echo "true"
-
diff --git a/tests/template/t2do.nim b/tests/template/t2do.nim
new file mode 100644
index 000000000..b87e3328c
--- /dev/null
+++ b/tests/template/t2do.nim
@@ -0,0 +1,22 @@
+discard """
+  output: "8.0"
+"""
+
+# bug #2057
+
+proc mpf_get_d(x: int): float = float(x)
+proc mpf_cmp_d(a: int; b: float): int = 0
+
+template toFloatHelper(result: expr; tooSmall, tooLarge: stmt) {.immediate.} =
+  result = mpf_get_d(a)
+  if result == 0.0 and mpf_cmp_d(a,0.0) != 0:
+    tooSmall
+  if result == Inf:
+    tooLarge
+
+proc toFloat*(a: int): float =
+  toFloatHelper(result)
+    do: raise newException(ValueError, "number too small"):
+        raise newException(ValueError, "number too large")
+
+echo toFloat(8)
diff --git a/tests/template/t_otemplates.nim b/tests/template/t_otemplates.nim
index 1a9075d20..db535d818 100644
--- a/tests/template/t_otemplates.nim
+++ b/tests/template/t_otemplates.nim
@@ -18,7 +18,7 @@ const identChars = {'a'..'z', 'A'..'Z', '0'..'9', '_'}
 

 

 # Procedure Declarations

-proc parse_template(node: PNimrodNode, value: string) {.compiletime.}

+proc parse_template(node: NimNode, value: string) {.compiletime.}

 

 

 # Procedure Definitions

@@ -166,7 +166,7 @@ iterator parse_compound_statements(value, identifier: string, index: int): strin
             get_next_ident(["try", "$except", "$finally"])

 

 

-proc parse_complex_stmt(value, identifier: string, index: var int): PNimrodNode {.compiletime.} =

+proc parse_complex_stmt(value, identifier: string, index: var int): NimNode {.compiletime.} =

     ## Parses if/when/try /elif /else /except /finally statements

 

     # Build up complex statement string

@@ -218,7 +218,7 @@ proc parse_complex_stmt(value, identifier: string, index: var int): PNimrodNode
         inc(resultIndex)

 

 

-proc parse_simple_statement(value: string, index: var int): PNimrodNode {.compiletime.} =

+proc parse_simple_statement(value: string, index: var int): NimNode {.compiletime.} =

     ## Parses for/while

 

     # Detect indentation

@@ -252,7 +252,7 @@ proc parse_simple_statement(value: string, index: var int): PNimrodNode {.compil
     inc(index, value.parse_thru_eol(index))

 

 

-proc parse_until_symbol(node: PNimrodNode, value: string, index: var int): bool {.compiletime.} =

+proc parse_until_symbol(node: NimNode, value: string, index: var int): bool {.compiletime.} =

     ## Parses a string until a $ symbol is encountered, if

     ## two $$'s are encountered in a row, a split will happen

     ## removing one of the $'s from the resulting output

@@ -311,7 +311,7 @@ proc parse_until_symbol(node: PNimrodNode, value: string, index: var int): bool
         node.insert insertionPoint, newCall("add", ident("result"), newStrLitNode(splitValue))

 

 

-proc parse_template(node: PNimrodNode, value: string) =

+proc parse_template(node: NimNode, value: string) =

     ## Parses through entire template, outputing valid

     ## Nim code into the input `node` AST.

     var index = 0

diff --git a/tests/template/texponential_eval.nim b/tests/template/texponential_eval.nim
new file mode 100644
index 000000000..32af9e8f7
--- /dev/null
+++ b/tests/template/texponential_eval.nim
@@ -0,0 +1,47 @@
+# bug #1940
+
+discard """
+  nimout: '''===
+merge (A) with (B)
+merge (A B) with (C)
+merge (A B C) with (D)
+merge (A B C D) with (E)
+merge (A B C D E) with (F)
+==='''
+"""
+
+type SqlStmt = tuple
+  sql: string
+  parts: int
+
+proc sql(q: string): SqlStmt =
+  result.sql = q
+  result.parts = 1
+
+template `&%%`(x, y: SqlStmt): SqlStmt =
+  const a = x
+  const b = y
+
+  static:
+    #echo "some merge"
+    echo "merge (", a.sql, ") with (", b.sql, ")"
+
+
+  const newSql = a.sql & " " & b.sql
+  const newParts = a.parts + b.parts
+
+  SqlStmt((sql: newSql, parts: newParts))
+
+static:
+  echo "==="
+
+let c =(sql("A") &%%
+        sql("B")) &%%
+        sql("C")  &%%
+        sql("D") &%%
+        sql("E") &%%
+        sql("F")
+echo c.sql
+
+static:
+  echo "==="
diff --git a/tests/template/tparams_gensymed.nim b/tests/template/tparams_gensymed.nim
new file mode 100644
index 000000000..6c4413866
--- /dev/null
+++ b/tests/template/tparams_gensymed.nim
@@ -0,0 +1,62 @@
+
+# bug #1915
+
+import macros
+
+# Test that parameters are properly gensym'ed finally:
+
+template genNodeKind(kind, name: expr): stmt =
+  proc name*(children: varargs[PNimrodNode]): PNimrodNode {.compiletime.}=
+    result = newNimNode(kind)
+    for c in children:
+      result.add(c)
+
+genNodeKind(nnkNone, None)
+
+
+# Test that generics in templates still work (regression to fix #1915)
+
+# bug #2004
+
+type Something = object
+
+proc testA(x: Something) = discard
+
+template def(name: expr) {.immediate.} =
+  proc testB[T](reallyUniqueName: T) =
+    `test name`(reallyUniqueName)
+def A
+
+var x: Something
+testB(x)
+
+
+# bug #2215
+# Test that templates in generics still work (regression to fix the
+# regression...)
+
+template forStatic(index: expr, slice: Slice[int], predicate: stmt):
+                   stmt {.immediate.} =
+  const a = slice.a
+  const b = slice.b
+  when a <= b:
+    template iteration(i: int) =
+      block:
+        const index = i
+        predicate
+    template iterateStartingFrom(i: int): stmt =
+      when i <= b:
+        iteration i
+        iterateStartingFrom i + 1
+    iterateStartingFrom a
+
+proc concreteProc(x: int) =
+  forStatic i, 0..3:
+    echo i
+
+proc genericProc(x: any) =
+  forStatic i, 0..3:
+    echo i
+
+concreteProc(7) # This works
+genericProc(7)  # This doesn't compile
diff --git a/tests/template/tscope.nim b/tests/template/tscope.nim
new file mode 100644
index 000000000..2d5841af3
--- /dev/null
+++ b/tests/template/tscope.nim
@@ -0,0 +1,12 @@
+discard """
+  errormsg: "redefinition of 'x'"
+"""
+
+var x = 1
+template quantity(): stmt {.immediate.} =
+  # Causes internal error in compiler/sem.nim
+  proc unit*(x = 1.0): float = 12
+  # Throws the correct error: redefinition of 'x'
+  #proc unit*(y = 1.0): float = 12
+quantity()
+var x = 2
diff --git a/tests/template/tstmt_semchecked_twice.nim b/tests/template/tstmt_semchecked_twice.nim
new file mode 100644
index 000000000..05c16c3c9
--- /dev/null
+++ b/tests/template/tstmt_semchecked_twice.nim
@@ -0,0 +1,30 @@
+
+# bug #2585
+
+type
+    RenderPass = object
+       state: ref int
+
+    RenderData* = object
+        fb: int
+        walls: seq[RenderPass]
+
+    Mat2 = int
+    Vector2[T] = T
+    Pixels=int
+
+template use*(fb: int, st: stmt) : stmt =
+    echo "a ", $fb
+    st
+    echo "a ", $fb
+
+proc render(rdat: var RenderData; passes: var openarray[RenderPass]; proj: Mat2;
+            indexType = 1) =
+    for i in 0 .. <len(passes):
+        echo "blah ", repr(passes[i])
+
+
+
+proc render2*(rdat: var RenderData; screenSz: Vector2[Pixels]; proj: Mat2) =
+    use rdat.fb:
+        render(rdat, rdat.walls, proj, 1)
diff --git a/tests/template/ttempl2.nim b/tests/template/ttempl2.nim
index 142bbb8c7..aaa2f1344 100644
--- a/tests/template/ttempl2.nim
+++ b/tests/template/ttempl2.nim
@@ -3,12 +3,12 @@ discard """
   line: 18
   errormsg: "undeclared identifier: \'b\'"
 """
-template declareInScope(x: expr, t: typeDesc): stmt {.immediate.} =
+template declareInScope(x: untyped, t: typeDesc): untyped {.immediate.} =
   var x: t
-  
-template declareInNewScope(x: expr, t: typeDesc): stmt {.immediate.} =
+
+template declareInNewScope(x: untyped, t: typeDesc): untyped {.immediate.} =
   # open a new scope:
-  block: 
+  block:
     var x: t
 
 declareInScope(a, int)
diff --git a/tests/template/twrongmapit.nim b/tests/template/twrongmapit.nim
index 4b3e1553f..bca1292b8 100644
--- a/tests/template/twrongmapit.nim
+++ b/tests/template/twrongmapit.nim
@@ -1,7 +1,7 @@
 discard """
   errormsg: "'"
   file: "sequtils.nim"
-  line: 416
+  line: 435
 """
 # unfortunately our tester doesn't support multiple lines of compiler
 # error messages yet...
diff --git a/tests/template/utemplates.nim b/tests/template/utemplates.nim
index 38ad4f515..8b9ae5d26 100644
--- a/tests/template/utemplates.nim
+++ b/tests/template/utemplates.nim
@@ -12,7 +12,7 @@ test "previous definitions can be further overloaded or hidden in local scopes":
 
   check t(true) == "bool"
   check t(10) == "int"
-  
+
   template t(a: int): expr = "inner int"
   check t(10) == "inner int"
   check t("test") == "string"
@@ -21,12 +21,12 @@ test "templates can be redefined multiple times":
   template customAssert(cond: bool, msg: string): stmt {.immediate, dirty.} =
     if not cond: fail(msg)
 
-  template assertion_failed(body: stmt) {.immediate.} =
+  template assertion_failed(body: stmt) {.immediate, dirty.} =
     template fail(msg: string): stmt = body
 
   assertion_failed: check msg == "first fail path"
   customAssert false, "first fail path"
 
-  assertion_failed: check msg == "second fail path"  
+  assertion_failed: check msg == "second fail path"
   customAssert false, "second fail path"
 
diff --git a/tests/testament/backend.nim b/tests/testament/backend.nim
index c7122e1b2..11743c337 100644
--- a/tests/testament/backend.nim
+++ b/tests/testament/backend.nim
@@ -1,7 +1,7 @@
 #
 #
 #              The Nim Tester
-#        (c) Copyright 2014 Andreas Rumpf
+#        (c) Copyright 2015 Andreas Rumpf
 #
 #    Look at license.txt for more info.
 #    All rights reserved.
diff --git a/tests/testament/caasdriver.nim b/tests/testament/caasdriver.nim
index 8f2eec33b..c61a9f108 100644
--- a/tests/testament/caasdriver.nim
+++ b/tests/testament/caasdriver.nim
@@ -1,4 +1,5 @@
 import osproc, streams, os, strutils, re
+{.experimental.}
 
 ## Compiler as a service tester.
 ##
@@ -10,7 +11,7 @@ type
     ProcRun, CaasRun, SymbolProcRun
 
   NimSession* = object
-    nim: PProcess # Holds the open process for CaasRun sessions, nil otherwise.
+    nim: Process # Holds the open process for CaasRun sessions, nil otherwise.
     mode: TRunMode # Stores the type of run mode the session was started with.
     lastOutput: string # Preserves the last output, needed for ProcRun mode.
     filename: string # Appended to each command starting with '>'. Also a var.
@@ -70,8 +71,10 @@ proc doCaasCommand(session: var NimSession, command: string): string =
       break
 
 proc doProcCommand(session: var NimSession, command: string): string =
-  assert session.mode == ProcRun or session.mode == SymbolProcRun
-  except: result = "FAILED TO EXECUTE: " & command & "\n" & result
+  try:
+    assert session.mode == ProcRun or session.mode == SymbolProcRun
+  except:
+    result = "FAILED TO EXECUTE: " & command & "\n" & result
   var
     process = startProcess(NimBin, args = session.replaceVars(command).split)
     stream = outputStream(process)
@@ -102,11 +105,11 @@ proc doCommand(session: var NimSession, command: string) =
     session.lastOutput = doProcCommand(session,
                                        command & " " & session.filename)
 
-proc close(session: var NimSession) {.destructor.} =
+proc destroy(session: var NimSession) {.destructor.} =
   if session.mode == CaasRun:
     session.nim.close
 
-proc doScenario(script: string, output: PStream, mode: TRunMode, verbose: bool): bool =
+proc doScenario(script: string, output: Stream, mode: TRunMode, verbose: bool): bool =
   result = true
 
   var f = open(script)
@@ -171,7 +174,7 @@ when isMainModule:
     failures = 0
     verbose = false
 
-  for i in 0..ParamCount() - 1:
+  for i in 0..paramCount() - 1:
     let param = string(paramStr(i + 1))
     case param
     of "verbose": verbose = true
diff --git a/tests/testament/categories.nim b/tests/testament/categories.nim
index ae9905cde..07a2421a6 100644
--- a/tests/testament/categories.nim
+++ b/tests/testament/categories.nim
@@ -1,7 +1,7 @@
 #
 #
 #            Nim Tester
-#        (c) Copyright 2014 Andreas Rumpf
+#        (c) Copyright 2015 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
@@ -22,35 +22,35 @@ proc delNimCache() =
     removeDir(nimcacheDir)
   except OSError:
     echo "[Warning] could not delete: ", nimcacheDir
-    
+
 proc runRodFiles(r: var TResults, cat: Category, options: string) =
   template test(filename: expr): stmt =
     testSpec r, makeTest(rodfilesDir / filename, options, cat, actionRun)
-  
+
   delNimCache()
-  
+
   # test basic recompilation scheme:
   test "hallo"
   test "hallo"
   # test incremental type information:
   test "hallo2"
   delNimCache()
-  
+
   # test type converters:
   test "aconv"
   test "bconv"
   delNimCache()
-  
+
   # test G, A, B example from the documentation; test init sections:
   test "deada"
   test "deada2"
   delNimCache()
-  
+
   # test method generation:
   test "bmethods"
   test "bmethods2"
   delNimCache()
-  
+
   # test generics:
   test "tgeneric1"
   test "tgeneric2"
@@ -79,26 +79,26 @@ proc runBasicDLLTest(c, r: var TResults, cat: Category, options: string) =
     options & " --app:lib -d:createNimRtl", cat)
   testSpec c, makeTest("tests/dll/server.nim",
     options & " --app:lib -d:useNimRtl", cat)
-  
-  when defined(Windows): 
+
+  when defined(Windows):
     # windows looks in the dir of the exe (yay!):
     var nimrtlDll = DynlibFormat % "nimrtl"
     safeCopyFile("lib" / nimrtlDll, "tests/dll" / nimrtlDll)
   else:
     # posix relies on crappy LD_LIBRARY_PATH (ugh!):
-    var libpath = getenv"LD_LIBRARY_PATH".string
-    if peg"\i '/nim' (!'/')* '/lib'" notin libpath:
-      echo "[Warning] insufficient LD_LIBRARY_PATH"
+    var libpath = getEnv"LD_LIBRARY_PATH".string
+    # Temporarily add the lib directory to LD_LIBRARY_PATH:
+    putEnv("LD_LIBRARY_PATH", "lib:" & libpath)
     var serverDll = DynlibFormat % "server"
     safeCopyFile("tests/dll" / serverDll, "lib" / serverDll)
-  
-  testSpec r, makeTest("tests/dll/client.nim", options & " -d:useNimRtl", 
+
+  testSpec r, makeTest("tests/dll/client.nim", options & " -d:useNimRtl",
                        cat, actionRun)
 
 proc dllTests(r: var TResults, cat: Category, options: string) =
   # dummy compile result:
   var c = initResults()
-  
+
   runBasicDLLTest c, r, cat, options
   runBasicDLLTest c, r, cat, options & " -d:release"
   runBasicDLLTest c, r, cat, options & " --gc:boehm"
@@ -107,30 +107,36 @@ proc dllTests(r: var TResults, cat: Category, options: string) =
 # ------------------------------ GC tests -------------------------------------
 
 proc gcTests(r: var TResults, cat: Category, options: string) =
-  template test(filename: expr): stmt =
+  template testWithoutMs(filename: expr): stmt =
     testSpec r, makeTest("tests/gc" / filename, options, cat, actionRun)
     testSpec r, makeTest("tests/gc" / filename, options &
                   " -d:release", cat, actionRun)
     testSpec r, makeTest("tests/gc" / filename, options &
                   " -d:release -d:useRealtimeGC", cat, actionRun)
+
+  template test(filename: expr): stmt =
+    testWithoutMs filename
     testSpec r, makeTest("tests/gc" / filename, options &
                   " --gc:markAndSweep", cat, actionRun)
     testSpec r, makeTest("tests/gc" / filename, options &
                   " -d:release --gc:markAndSweep", cat, actionRun)
-  
+
+  test "growobjcrash"
   test "gcbench"
   test "gcleak"
   test "gcleak2"
   test "gctest"
   test "gcleak3"
   test "gcleak4"
-  test "gcleak5"
+  # Disabled because it works and takes too long to run:
+  #test "gcleak5"
   test "weakrefs"
   test "cycleleak"
   test "closureleak"
-  test "refarrayleak"
+  testWithoutMs "refarrayleak"
+
   test "stackrefleak"
-  
+  test "cyclecollector"
 
 # ------------------------- threading tests -----------------------------------
 
@@ -141,7 +147,7 @@ proc threadTests(r: var TResults, cat: Category, options: string) =
       " -d:release", cat, actionRun)
     testSpec r, makeTest("tests/threads" / filename, options &
       " --tlsEmulation:on", cat, actionRun)
-  
+
   test "tactors"
   test "tactors2"
   test "threadex"
@@ -176,7 +182,7 @@ proc jsTests(r: var TResults, cat: Category, options: string) =
                          actionRun, targetJS)
     testSpec r, makeTest(filename, options & " -d:nodejs -d:release", cat,
                          actionRun, targetJS)
-    
+
   for t in os.walkFiles("tests/js/t*.nim"):
     test(t)
   for testfile in ["exception/texceptions", "exception/texcpt1",
@@ -193,13 +199,13 @@ proc jsTests(r: var TResults, cat: Category, options: string) =
 
 proc findMainFile(dir: string): string =
   # finds the file belonging to ".nim.cfg"; if there is no such file
-  # it returns the some ".nim" file if there is only one: 
+  # it returns the some ".nim" file if there is only one:
   const cfgExt = ".nim.cfg"
   result = ""
   var nimFiles = 0
   for kind, file in os.walkDir(dir):
     if kind == pcFile:
-      if file.endsWith(cfgExt): return file[.. -(cfgExt.len+1)] & ".nim"
+      if file.endsWith(cfgExt): return file[.. ^(cfgExt.len+1)] & ".nim"
       elif file.endsWith(".nim"):
         if result.len == 0: result = file
         inc nimFiles
@@ -209,7 +215,7 @@ proc manyLoc(r: var TResults, cat: Category, options: string) =
   for kind, dir in os.walkDir("tests/manyloc"):
     if kind == pcDir:
       let mainfile = findMainFile(dir)
-      if mainfile != ".nim":
+      if mainfile != "":
         testNoSpec r, makeTest(mainfile, options, cat)
 
 proc compileExample(r: var TResults, pattern, options: string, cat: Category) =
@@ -220,21 +226,21 @@ proc testStdlib(r: var TResults, pattern, options: string, cat: Category) =
   for test in os.walkFiles(pattern):
     let contents = readFile(test).string
     if contents.contains("when isMainModule"):
-      testSpec r, makeTest(test, options, cat, actionRun)
+      testSpec r, makeTest(test, options, cat, actionRunNoSpec)
     else:
       testNoSpec r, makeTest(test, options, cat, actionCompile)
 
-# ----------------------------- babel ----------------------------------------
+# ----------------------------- nimble ----------------------------------------
 type PackageFilter = enum
   pfCoreOnly
   pfExtraOnly
   pfAll
 
-let 
-  babelExe = findExe("babel")
-  babelDir = getHomeDir() / ".babel"
-  packageDir = babelDir / "pkgs"
-  packageIndex = babelDir / "packages.json"
+let
+  nimbleExe = findExe("nimble")
+  nimbleDir = getHomeDir() / ".nimble"
+  packageDir = nimbleDir / "pkgs"
+  packageIndex = nimbleDir / "packages.json"
 
 proc waitForExitEx(p: Process): int =
   var outp = outputStream(p)
@@ -249,7 +255,7 @@ proc waitForExitEx(p: Process): int =
 
 proc getPackageDir(package: string): string =
   ## TODO - Replace this with dom's version comparison magic.
-  var commandOutput = execCmdEx("babel path $#" % package)
+  var commandOutput = execCmdEx("nimble path $#" % package)
   if commandOutput.exitCode != QuitSuccess:
     return ""
   else:
@@ -262,7 +268,7 @@ iterator listPackages(filter: PackageFilter): tuple[name, url: string] =
     let
       name = package["name"].str
       url = package["url"].str
-      isCorePackage = "nimrod-code" in normalize(url)
+      isCorePackage = "nim-lang" in normalize(url)
     case filter:
     of pfCoreOnly:
       if isCorePackage:
@@ -273,13 +279,13 @@ iterator listPackages(filter: PackageFilter): tuple[name, url: string] =
     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.")
+proc testNimblePackages(r: var TResults, cat: Category, filter: PackageFilter) =
+  if nimbleExe == "":
+    echo("[Warning] - Cannot run nimble tests: Nimble binary not found.")
     return
 
-  if execCmd("$# update" % babelExe) == QuitFailure:
-    echo("[Warning] - Cannot run babel tests: Babel update failed.")
+  if execCmd("$# update" % nimbleExe) == QuitFailure:
+    echo("[Warning] - Cannot run nimble tests: Nimble update failed.")
     return
 
   let packageFileTest = makeTest("PackageFileParsed", "", cat)
@@ -288,7 +294,7 @@ proc testBabelPackages(r: var TResults, cat: Category, filter: PackageFilter) =
       var test = makeTest(name, "", cat)
       echo(url)
       let
-        installProcess = startProcess(babelExe, "", ["install", "-y", name])
+        installProcess = startProcess(nimbleExe, "", ["install", "-y", name])
         installStatus = waitForExitEx(installProcess)
       installProcess.close
       if installStatus != QuitSuccess:
@@ -296,9 +302,8 @@ proc testBabelPackages(r: var TResults, cat: Category, filter: PackageFilter) =
         continue
 
       let
-        buildPath = getPackageDir(name)[0.. -3]
-      let
-        buildProcess = startProcess(babelExe, buildPath, ["build"])
+        buildPath = getPackageDir(name).strip
+        buildProcess = startProcess(nimbleExe, buildPath, ["build"])
         buildStatus = waitForExitEx(buildProcess)
       buildProcess.close
       if buildStatus != QuitSuccess:
@@ -306,13 +311,13 @@ proc testBabelPackages(r: var TResults, cat: Category, filter: PackageFilter) =
       r.addResult(test, "", "", reSuccess)
     r.addResult(packageFileTest, "", "", reSuccess)
   except JsonParsingError:
-    echo("[Warning] - Cannot run babel tests: Invalid package file.")
+    echo("[Warning] - Cannot run nimble tests: Invalid package file.")
     r.addResult(packageFileTest, "", "", reBuildFailed)
 
 
 # ----------------------------------------------------------------------------
 
-const AdditionalCategories = ["debugger", "examples", "lib", "babel-core"]
+const AdditionalCategories = ["debugger", "examples", "lib"]
 
 proc `&.?`(a, b: string): string =
   # candidate for the stdlib?
@@ -325,8 +330,9 @@ proc `&?.`(a, b: string): string =
 proc processCategory(r: var TResults, cat: Category, options: string) =
   case cat.string.normalize
   of "rodfiles":
-    compileRodFiles(r, cat, options)
-    runRodFiles(r, cat, options)
+    discard # Disabled for now
+    #compileRodFiles(r, cat, options)
+    #runRodFiles(r, cat, options)
   of "js":
     # XXX JS doesn't need to be special anymore
     jsTests(r, cat, options)
@@ -349,12 +355,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)
+  of "nimble-core":
+    testNimblePackages(r, cat, pfCoreOnly)
+  of "nimble-extra":
+    testNimblePackages(r, cat, pfExtraOnly)
+  of "nimble-all":
+    testNimblePackages(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 b9eda5383..a9f739995 100644
--- a/tests/testament/htmlgen.nim
+++ b/tests/testament/htmlgen.nim
@@ -1,7 +1,7 @@
 #
 #
 #            Nim Tester
-#        (c) Copyright 2014 Andreas Rumpf
+#        (c) Copyright 2015 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
@@ -20,7 +20,7 @@ const
                           <td>Success</td></tr>"""
   TableFooter = "</table>"
   HtmlBegin = """<html>
-    <head> 
+    <head>
       <title>Test results</title>
       <style type="text/css">
       <!--""" & slurp("css/boilerplate.css") & "\n" &
@@ -28,13 +28,13 @@ const
       """
 ul#tabs { list-style-type: none; margin: 30px 0 0 0; padding: 0 0 0.3em 0; }
 ul#tabs li { display: inline; }
-ul#tabs li a { color: #42454a; background-color: #dedbde; 
-               border: 1px solid #c9c3ba; border-bottom: none; 
+ul#tabs li a { color: #42454a; background-color: #dedbde;
+               border: 1px solid #c9c3ba; border-bottom: none;
                padding: 0.3em; text-decoration: none; }
 ul#tabs li a:hover { background-color: #f1f0ee; }
-ul#tabs li a.selected { color: #000; background-color: #f1f0ee; 
+ul#tabs li a.selected { color: #000; background-color: #f1f0ee;
                         font-weight: bold; padding: 0.7em 0.3em 0.38em 0.3em; }
-div.tabContent { border: 1px solid #c9c3ba; 
+div.tabContent { border: 1px solid #c9c3ba;
                  padding: 0.5em; background-color: #f1f0ee; }
 div.tabContent.hide { display: none; }
       -->
@@ -43,7 +43,7 @@ div.tabContent.hide { display: none; }
 
     var tabLinks = new Array();
     var contentDivs = new Array();
-    
+
     function init() {
       // Grab the tab links and content divs from the page
       var tabListItems = document.getElementById('tabs').childNodes;
@@ -103,7 +103,7 @@ div.tabContent.hide { display: none; }
 
     </head>
     <body onload="init()">"""
-  
+
   HtmlEnd = "</body></html>"
 
 proc td(s: string): string =
@@ -115,8 +115,8 @@ proc getCommit(db: TDbConn, c: int): string =
     if commit == 0: result = thisCommit[0]
     inc commit
 
-proc generateHtml*(filename: string, commit: int) =
-  const selRow = """select name, category, target, action, 
+proc generateHtml*(filename: string, commit: int; onlyFailing: bool) =
+  const selRow = """select name, category, target, action,
                            expected, given, result
                     from TestResult
                     where [commit] = ? and machine = ?
@@ -140,17 +140,20 @@ proc generateHtml*(filename: string, commit: int) =
   for m in db.rows(sql"select id, name, os, cpu from Machine order by id"):
     outfile.writeln """<li><a href="#$#">$#: $#, $#</a></li>""" % m
   outfile.write("</ul>")
-  
+
   for currentMachine in db.rows(sql"select id from Machine order by id"):
     let m = currentMachine[0]
     outfile.write("""<div class="tabContent" id="$#">""" % m)
 
     outfile.write(TableHeader)
     for row in db.rows(sql(selRow), lastCommit, m):
-      outfile.write("<tr>")
-      for x in row:
-        outfile.write(x.td)
-      outfile.write("</tr>")
+      if onlyFailing and row.len > 0 and row[row.high] == "reSuccess":
+        discard
+      else:
+        outfile.write("<tr>")
+        for x in row:
+          outfile.write(x.td)
+        outfile.write("</tr>")
 
     outfile.write(TableFooter)
     outfile.write("</div>")
@@ -161,7 +164,7 @@ proc generateHtml*(filename: string, commit: int) =
 proc generateJson*(filename: string, commit: int) =
   const
     selRow = """select count(*),
-                           sum(result = 'reSuccess'), 
+                           sum(result = 'reSuccess'),
                            sum(result = 'reIgnored')
                 from TestResult
                 where [commit] = ? and machine = ?
@@ -174,9 +177,9 @@ proc generateJson*(filename: string, commit: int) =
                 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 
+    selResults = """select
+                      category || '/' || target || '/' || name,
+                      category, target, action, result, expected, given
                     from TestResult
                     where [commit] = ?"""
   var db = open(connection="testament.db", user="testament", password="",
diff --git a/tests/testament/specs.nim b/tests/testament/specs.nim
index 37fe8cfee..9306bf025 100644
--- a/tests/testament/specs.nim
+++ b/tests/testament/specs.nim
@@ -1,7 +1,7 @@
 #
 #
 #            Nim Tester
-#        (c) Copyright 2014 Andreas Rumpf
+#        (c) Copyright 2015 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
@@ -10,13 +10,14 @@
 import parseutils, strutils, os, osproc, streams, parsecfg
 
 const
-  cmdTemplate* = r"nim $target --hints:on $options $file"
+  cmdTemplate* = r"nim $target --hints:on -d:testing $options $file"
 
 type
   TTestAction* = enum
     actionCompile = "compile"
     actionRun = "run"
     actionReject = "reject"
+    actionRunNoSpec = "runNoSpec"
   TResultEnum* = enum
     reNimcCrash,     # nim compiler seems to have crashed
     reMsgsDiffer,       # error messages differ
@@ -42,12 +43,14 @@ type
     action*: TTestAction
     file*, cmd*: string
     outp*: string
-    line*, exitCode*: int
+    line*, column*: int
+    exitCode*: int
     msg*: string
     ccodeCheck*: string
     err*: TResultEnum
     substr*, sortoutput*: bool
     targets*: set[TTarget]
+    nimout*: string
 
 const
   targetToExt*: array[TTarget, string] = ["c", "cpp", "m", "js"]
@@ -76,7 +79,7 @@ proc extractSpec(filename: string): string =
 when not defined(nimhygiene):
   {.pragma: inject.}
 
-template parseSpecAux(fillResult: stmt) {.immediate.} =
+template parseSpecAux(fillResult: untyped) =
   var ss = newStringStream(extractSpec(filename))
   var p {.inject.}: CfgParser
   open(p, ss, filename, 1)
@@ -90,12 +93,18 @@ template parseSpecAux(fillResult: stmt) {.immediate.} =
       fillResult
   close(p)
 
-proc parseSpec*(filename: string): TSpec =
-  result.file = filename
+proc specDefaults*(result: var TSpec) =
   result.msg = ""
   result.outp = ""
+  result.nimout = ""
   result.ccodeCheck = ""
   result.cmd = cmdTemplate
+  result.line = 0
+  result.column = 0
+
+proc parseSpec*(filename: string): TSpec =
+  specDefaults(result)
+  result.file = filename
   parseSpecAux:
     case normalize(e.key)
     of "action":
@@ -106,7 +115,8 @@ proc parseSpec*(filename: string): TSpec =
       else: echo ignoreMsg(p, e)
     of "file": result.file = e.value
     of "line": discard parseInt(e.value, result.line)
-    of "output": 
+    of "column": discard parseInt(e.value, result.column)
+    of "output":
       result.action = actionRun
       result.outp = e.value
     of "outputsub":
@@ -115,7 +125,7 @@ proc parseSpec*(filename: string): TSpec =
       result.substr = true
     of "sortoutput":
       result.sortoutput = parseCfgBool(e.value)
-    of "exitcode": 
+    of "exitcode":
       discard parseInt(e.value, result.exitCode)
     of "msg":
       result.msg = e.value
@@ -124,6 +134,8 @@ proc parseSpec*(filename: string): TSpec =
     of "errormsg":
       result.msg = e.value
       result.action = actionReject
+    of "nimout":
+      result.nimout = e.value
     of "disabled":
       if parseCfgBool(e.value): result.err = reIgnored
     of "cmd": result.cmd = e.value
diff --git a/tests/testament/tester.nim b/tests/testament/tester.nim
index b74fa99c8..b3e65959a 100644
--- a/tests/testament/tester.nim
+++ b/tests/testament/tester.nim
@@ -1,7 +1,7 @@
 #
 #
 #            Nim Tester
-#        (c) Copyright 2014 Andreas Rumpf
+#        (c) Copyright 2015 Andreas Rumpf
 #
 #    See the file "copying.txt", included in this
 #    distribution, for details about the copyright.
@@ -12,7 +12,7 @@
 import
   parseutils, strutils, pegs, os, osproc, streams, parsecfg, json,
   marshal, backend, parseopt, specs, htmlgen, browsers, terminal,
-  algorithm
+  algorithm, compiler/nodejs
 
 const
   resultsFile = "testresults.html"
@@ -30,6 +30,7 @@ Arguments:
   arguments are passed to the compiler
 Options:
   --print                   also print results to the console
+  --failing                 only show failing/ignored tests
 """ % resultsFile
 
 type
@@ -48,8 +49,8 @@ type
 # ----------------------------------------------------------------------------
 
 let
-  pegLineError = 
-    peg"{[^(]*} '(' {\d+} ', ' \d+ ') ' ('Error') ':' \s* {.*}"
+  pegLineError =
+    peg"{[^(]*} '(' {\d+} ', ' {\d+} ') ' ('Error') ':' \s* {.*}"
   pegOtherError = peg"'Error:' \s* {.*}"
   pegSuccess = peg"'Hint: operation successful'.*"
   pegOfInterest = pegLineError / pegOtherError
@@ -57,14 +58,16 @@ let
 proc callCompiler(cmdTemplate, filename, options: string,
                   target: TTarget): TSpec =
   let c = parseCmdLine(cmdTemplate % ["target", targetToCmd[target],
-                       "options", options, "file", filename])
-  var p = startProcess(command=c[0], args=c[1.. -1],
+                       "options", options, "file", filename.quoteShell])
+  var p = startProcess(command=c[0], args=c[1.. ^1],
                        options={poStdErrToStdOut, poUseShell})
   let outp = p.outputStream
   var suc = ""
   var err = ""
   var x = newStringOfCap(120)
+  result.nimout = ""
   while outp.readLine(x.TaintedString) or running(p):
+    result.nimout.add(x & "\n")
     if x =~ pegOfInterest:
       # `err` should contain the last error/warning message
       err = x
@@ -74,11 +77,13 @@ proc callCompiler(cmdTemplate, filename, options: string,
   result.msg = ""
   result.file = ""
   result.outp = ""
-  result.line = -1
+  result.line = 0
+  result.column = 0
   if err =~ pegLineError:
     result.file = extractFilename(matches[0])
     result.line = parseInt(matches[1])
-    result.msg = matches[2]
+    result.column = parseInt(matches[2])
+    result.msg = matches[3]
   elif err =~ pegOtherError:
     result.msg = matches[0]
   elif suc =~ pegSuccess:
@@ -105,14 +110,16 @@ proc addResult(r: var TResults, test: TTest,
                expected, given: string, success: TResultEnum) =
   let name = test.name.extractFilename & test.options
   backend.writeTestResult(name = name,
-                          category = test.cat.string, 
+                          category = test.cat.string,
                           target = $test.target,
                           action = $test.action,
                           result = $success,
                           expected = expected,
                           given = given)
   r.data.addf("$#\t$#\t$#\t$#", name, expected, given, $success)
-  if success notin {reSuccess, reIgnored}:
+  if success == reIgnored:
+    styledEcho styleBright, name, fgYellow, " [", $success, "]"
+  elif success != reSuccess:
     styledEcho styleBright, name, fgRed, " [", $success, "]"
     echo"Expected:"
     styledEcho styleBright, expected
@@ -125,8 +132,11 @@ proc cmpMsgs(r: var TResults, expected, given: TSpec, test: TTest) =
   elif extractFilename(expected.file) != extractFilename(given.file) and
       "internal error:" notin expected.msg:
     r.addResult(test, expected.file, given.file, reFilesDiffer)
-  elif expected.line != given.line and expected.line != 0:
-    r.addResult(test, $expected.line, $given.line, reLinesDiffer)
+  elif expected.line   != given.line   and expected.line   != 0 or
+       expected.column != given.column and expected.column != 0:
+    r.addResult(test, $expected.line & ':' & $expected.column,
+                      $given.line    & ':' & $given.column,
+                      reLinesDiffer)
   else:
     r.addResult(test, expected.msg, given.msg, reSuccess)
     inc(r.passed)
@@ -134,47 +144,74 @@ proc cmpMsgs(r: var TResults, expected, given: TSpec, test: TTest) =
 proc generatedFile(path, name: string, target: TTarget): string =
   let ext = targetToExt[target]
   result = path / "nimcache" /
-    (if target == targetJS: path.splitPath.tail & "_" else: "") &
+    (if target == targetJS: path.splitPath.tail & "_" else: "compiler_") &
     name.changeFileExt(ext)
 
 proc codegenCheck(test: TTest, check: string, given: var TSpec) =
-  if check.len > 0:
-    try:
-      let (path, name, ext2) = test.name.splitFile
-      let genFile = generatedFile(path, name, test.target)
-      echo genFile
-      let contents = readFile(genFile).string
-      if contents.find(check.peg) < 0:
+  try:
+    let (path, name, ext2) = test.name.splitFile
+    let genFile = generatedFile(path, name, test.target)
+    let contents = readFile(genFile).string
+    if check[0] == '\\':
+      # little hack to get 'match' support:
+      if not contents.match(check.peg):
         given.err = reCodegenFailure
-    except ValueError:
-      given.err = reInvalidPeg
-    except IOError:
-      given.err = reCodeNotFound
+    elif contents.find(check.peg) < 0:
+      given.err = reCodegenFailure
+  except ValueError:
+    given.err = reInvalidPeg
+    echo getCurrentExceptionMsg()
+  except IOError:
+    given.err = reCodeNotFound
+
+proc nimoutCheck(test: TTest; expectedNimout: string; given: var TSpec) =
+  let exp = expectedNimout.strip.replace("\C\L", "\L")
+  let giv = given.nimout.strip.replace("\C\L", "\L")
+  if exp notin giv:
+    given.err = reMsgsDiffer
 
 proc makeDeterministic(s: string): string =
   var x = splitLines(s)
   sort(x, system.cmp)
   result = join(x, "\n")
 
+proc compilerOutputTests(test: TTest, given: var TSpec, expected: TSpec;
+                         r: var TResults) =
+  var expectedmsg: string = ""
+  var givenmsg: string = ""
+  if given.err == reSuccess:
+    if expected.ccodeCheck.len > 0:
+      codegenCheck(test, expected.ccodeCheck, given)
+      expectedmsg = expected.ccodeCheck
+      givenmsg = given.msg
+    if expected.nimout.len > 0:
+      expectedmsg = expected.nimout
+      givenmsg = given.nimout.strip
+      nimoutCheck(test, expectedmsg, given)
+  if given.err == reSuccess: inc(r.passed)
+  r.addResult(test, expectedmsg, givenmsg, given.err)
+
 proc testSpec(r: var TResults, test: TTest) =
   # major entry point for a single test
   let tname = test.name.addFileExt(".nim")
   inc(r.total)
   styledEcho "Processing ", fgCyan, extractFilename(tname)
-  var expected = parseSpec(tname)
+  var expected: TSpec
+  if test.action != actionRunNoSpec:
+    expected = parseSpec(tname)
+  else:
+    specDefaults expected
+    expected.action = actionRunNoSpec
   if expected.err == reIgnored:
     r.addResult(test, "", "", reIgnored)
     inc(r.skipped)
   else:
     case expected.action
     of actionCompile:
-      var given = callCompiler(expected.cmd, test.name, test.options,
-                               test.target)
-      if given.err == reSuccess:
-        codegenCheck(test, expected.ccodeCheck, given)
-      r.addResult(test, "", given.msg, given.err)
-      if given.err == reSuccess: inc(r.passed)
-    of actionRun:
+      var given = callCompiler(expected.cmd, test.name,
+        test.options & " --hint[Path]:off --hint[Processing]:off", test.target)
+      compilerOutputTests(test, given, expected, r)
+    of actionRun, actionRunNoSpec:
       var given = callCompiler(expected.cmd, test.name, test.options,
                                test.target)
       if given.err != reSuccess:
@@ -187,12 +224,13 @@ proc testSpec(r: var TResults, test: TTest) =
         else:
           exeFile = changeFileExt(tname, ExeExt)
         if existsFile(exeFile):
-          if test.target == targetJS and findExe("nodejs") == "":
+          let nodejs = findNodeJs()
+          if test.target == targetJS and nodejs == "":
             r.addResult(test, expected.outp, "nodejs binary not in PATH",
                         reExeNotFound)
             return
           var (buf, exitCode) = execCmdEx(
-            (if test.target == targetJS: "nodejs " else: "") & exeFile)
+            (if test.target == targetJS: nodejs & " " else: "") & exeFile)
           if exitCode != expected.exitCode:
             r.addResult(test, "exitcode: " & $expected.exitCode,
                               "exitcode: " & $exitCode, reExitCodesDiffer)
@@ -202,10 +240,7 @@ proc testSpec(r: var TResults, test: TTest) =
             if bufB != strip(expected.outp):
               if not (expected.substr and expected.outp in bufB):
                 given.err = reOutputsDiffer
-            if given.err == reSuccess:
-              codeGenCheck(test, expected.ccodeCheck, given)
-            if given.err == reSuccess: inc(r.passed)
-            r.addResult(test, expected.outp, buf.string, given.err)
+            compilerOutputTests(test, given, expected, r)
         else:
           r.addResult(test, expected.outp, "executable not found", reExeNotFound)
     of actionReject:
@@ -241,11 +276,13 @@ proc main() =
 
   backend.open()
   var optPrintResults = false
+  var optFailing = false
   var p = initOptParser()
   p.next()
-  if p.kind == cmdLongoption:
+  while p.kind == cmdLongoption:
     case p.key.string.normalize
     of "print", "verbose": optPrintResults = true
+    of "failing": optFailing = true
     else: quit Usage
     p.next()
   if p.kind != cmdArgument: quit Usage
@@ -257,7 +294,7 @@ proc main() =
     let testsDir = "tests" & DirSep
     for kind, dir in walkDir(testsDir):
       assert testsDir.startsWith(testsDir)
-      let cat = dir[testsDir.len .. -1]
+      let cat = dir[testsDir.len .. ^1]
       if kind == pcDir and cat notin ["testament", "testdata", "nimcache"]:
         processCategory(r, Category(cat), p.cmdLineRest.string)
     for a in AdditionalCategories:
@@ -269,7 +306,7 @@ proc main() =
   of "html":
     var commit = 0
     discard parseInt(p.cmdLineRest.string, commit)
-    generateHtml(resultsFile, commit)
+    generateHtml(resultsFile, commit, optFailing)
     generateJson(jsonFile, commit)
   else:
     quit Usage
diff --git a/tests/testament/tester.nim.cfg b/tests/testament/tester.nim.cfg
new file mode 100644
index 000000000..27fd67075
--- /dev/null
+++ b/tests/testament/tester.nim.cfg
@@ -0,0 +1 @@
+path = "$nim" # For compiler/nodejs
diff --git a/tests/threads/ttryrecv.nim b/tests/threads/ttryrecv.nim
new file mode 100644
index 000000000..acccf182c
--- /dev/null
+++ b/tests/threads/ttryrecv.nim
@@ -0,0 +1,35 @@
+discard """
+  outputsub: "channel is empty"
+"""
+
+# bug #1816
+
+from math import random
+from os import sleep
+
+type PComm = ptr TChannel[int]
+
+proc doAction(outC: PComm) {.thread.} =
+  for i in 0.. <5:
+    sleep(random(100))
+    send(outC[], i)
+
+var
+  thr: TThread[PComm]
+  chan: TChannel[int]
+
+open(chan)
+createThread[PComm](thr, doAction, addr(chan))
+
+while true:
+  let (flag, x) = tryRecv(chan)
+  if flag:
+    echo("received from chan: " & $x)
+  else:
+    echo "channel is empty"
+    break
+
+echo "Finished listening"
+
+joinThread(thr)                                                       
+close(chan)
diff --git a/tests/trmacros/tor.nim b/tests/trmacros/tor.nim
index dc72a96cd..500851582 100644
--- a/tests/trmacros/tor.nim
+++ b/tests/trmacros/tor.nim
@@ -1,5 +1,5 @@
 discard """
-  output: '''3060
+  output: '''3030
 true
 3'''
 """
diff --git a/tests/tuples/tanontuples.nim b/tests/tuples/tanontuples.nim
index 80bd32b7b..49803e5ac 100644
--- a/tests/tuples/tanontuples.nim
+++ b/tests/tuples/tanontuples.nim
@@ -1,6 +1,5 @@
 discard """
-  output: '''61, 125
-89'''
+  output: '''61, 125'''
 """
 
 proc `^` (a, b: int): int =
@@ -13,7 +12,3 @@ var n = (56, 3)
 m = (n[0] + m[1], m[1] ^ n[1])
 
 echo m[0], ", ", m[1]
-
-var x = (bar: 38)
-x = (foo: 89)
-echo x[0]
diff --git a/tests/tuples/tdifferent_instantiations.nim b/tests/tuples/tdifferent_instantiations.nim
new file mode 100644
index 000000000..93b1777b5
--- /dev/null
+++ b/tests/tuples/tdifferent_instantiations.nim
@@ -0,0 +1,9 @@
+# bug #1910
+import tables
+
+var p: OrderedTable[tuple[a:int], int]
+var q: OrderedTable[tuple[x:int], int]
+for key in p.keys:
+  echo key.a
+for key in q.keys:
+  echo key.x
diff --git a/tests/tuples/tgeneric_tuple.nim b/tests/tuples/tgeneric_tuple.nim
new file mode 100644
index 000000000..32f081596
--- /dev/null
+++ b/tests/tuples/tgeneric_tuple.nim
@@ -0,0 +1,9 @@
+# bug #2121
+
+type
+  Item[K,V] = tuple
+    key: K
+    value: V
+
+var q = newseq[Item[int,int]](0)
+let (x,y) = q[0]
diff --git a/tests/tuples/tgeneric_tuple2.nim b/tests/tuples/tgeneric_tuple2.nim
new file mode 100644
index 000000000..c0c292388
--- /dev/null
+++ b/tests/tuples/tgeneric_tuple2.nim
@@ -0,0 +1,17 @@
+
+# bug #2369
+
+type HashedElem[T] = tuple[num: int, storedVal: ref T]
+
+proc append[T](tab: var seq[HashedElem[T]], n: int, val: ref T) =
+    #tab.add((num: n, storedVal: val))
+    var he: HashedElem[T] = (num: n, storedVal: val)
+    #tab.add(he)
+
+var g: seq[HashedElem[int]] = @[]
+
+proc foo() =
+    var x: ref int
+    new(x)
+    x[] = 77
+    g.append(44, x)
diff --git a/tests/tuples/tuint_tuple.nim b/tests/tuples/tuint_tuple.nim
new file mode 100644
index 000000000..24bcead5e
--- /dev/null
+++ b/tests/tuples/tuint_tuple.nim
@@ -0,0 +1,10 @@
+# bug #1986 found by gdmoore
+
+proc test(): int64 =
+  return 0xdeadbeef.int64
+
+const items = [
+  (var1: test(), var2: 100'u32),
+  (var1: test(), var2: 192'u32)
+]
+
diff --git a/tests/tuples/tuple_with_nil.nim b/tests/tuples/tuple_with_nil.nim
new file mode 100644
index 000000000..26e4ae85e
--- /dev/null
+++ b/tests/tuples/tuple_with_nil.nim
@@ -0,0 +1,766 @@
+import macros
+from strutils import IdentStartChars
+import parseutils
+import unicode
+import math
+import fenv
+import unsigned
+import pegs
+import streams
+
+type
+  FormatError = object of Exception ## Error in the format string.
+
+  Writer = concept W
+    ## Writer to output a character `c`.
+    when (NimMajor, NimMinor, NimPatch) > (0, 10, 2):
+      write(W, 'c')
+    else:
+      block:
+        var x: W
+        write(x, char)
+
+  FmtAlign = enum ## Format alignment
+    faDefault  ## default for given format type
+    faLeft     ## left aligned
+    faRight    ## right aligned
+    faCenter   ## centered
+    faPadding  ## right aligned, fill characters after sign (numbers only)
+
+  FmtSign = enum ## Format sign
+    fsMinus    ## only unary minus, no reservered sign space for positive numbers
+    fsPlus     ## unary minus and unary plus
+    fsSpace    ## unary minus and reserved space for positive numbers
+
+  FmtType = enum ## Format type
+    ftDefault  ## default format for given parameter type
+    ftStr      ## string
+    ftChar     ## character
+    ftDec      ## decimal integer
+    ftBin      ## binary integer
+    ftOct      ## octal integer
+    ftHex      ## hexadecimal integer
+    ftFix      ## real number in fixed point notation
+    ftSci      ## real number in scientific notation
+    ftGen      ## real number in generic form (either fixed point or scientific)
+    ftPercent  ## real number multiplied by 100 and % added
+
+  Format = tuple ## Formatting information.
+    typ: FmtType     ## format type
+    precision: int    ## floating point precision
+    width: int        ## minimal width
+    fill: string      ## the fill character, UTF8
+    align: FmtAlign  ## aligment
+    sign: FmtSign    ## sign notation
+    baseprefix: bool  ## whether binary, octal, hex should be prefixed by 0b, 0x, 0o
+    upcase: bool      ## upper case letters in hex or exponential formats
+    comma: bool       ##
+    arysep: string    ## separator for array elements
+
+  PartKind = enum pkStr, pkFmt
+
+  Part = object
+    ## Information of a part of the target string.
+    case kind: PartKind ## type of the part
+    of pkStr:
+      str: string ## literal string
+    of pkFmt:
+      arg: int ## position argument
+      fmt: string ## format string
+      field: string ## field of argument to be accessed
+      index: int ## array index of argument to be accessed
+      nested: bool ## true if the argument contains nested formats
+
+const
+  DefaultPrec = 6 ## Default precision for floating point numbers.
+  DefaultFmt: Format = (ftDefault, -1, -1, nil, faDefault, fsMinus, false, false, false, nil)
+    ## Default format corresponding to the empty format string, i.e.
+    ##   `x.format("") == x.format(DefaultFmt)`.
+  round_nums = [0.5, 0.05, 0.005, 0.0005, 0.00005, 0.000005, 0.0000005, 0.00000005]
+    ## Rounding offset for floating point numbers up to precision 8.
+
+proc write(s: var string; c: char) =
+  s.add(c)
+
+proc has(c: Captures; i: range[0..pegs.MaxSubpatterns-1]): bool {.nosideeffect, inline.} =
+  ## Tests whether `c` contains a non-empty capture `i`.
+  let b = c.bounds(i)
+  result = b.first <= b.last
+
+proc get(str: string; c: Captures; i: range[0..MaxSubpatterns-1]; def: char): char {.nosideeffect, inline.} =
+  ## If capture `i` is non-empty return that portion of `str` casted
+  ## to `char`, otherwise return `def`.
+  result = if c.has(i): str[c.bounds(i).first] else: def
+
+proc get(str: string; c: Captures; i: range[0..MaxSubpatterns-1]; def: string; begoff: int = 0): string {.nosideeffect, inline.} =
+  ## If capture `i` is non-empty return that portion of `str` as
+  ## string, otherwise return `def`.
+  let b = c.bounds(i)
+  result = if c.has(i): str.substr(b.first + begoff, b.last) else: def
+
+proc get(str: string; c: Captures; i: range[0..MaxSubpatterns-1]; def: int; begoff: int = 0): int {.nosideeffect, inline.} =
+  ## If capture `i` is non-empty return that portion of `str`
+  ## converted to int, otherwise return `def`.
+  if c.has(i):
+    discard str.parseInt(result, c.bounds(i).first + begoff)
+  else:
+    result = def
+
+proc parse(fmt: string): Format {.nosideeffect.} =
+  # Converts the format string `fmt` into a `Format` structure.
+  let p =
+    sequence(capture(?sequence(anyRune(), &charSet({'<', '>', '=', '^'}))),
+             capture(?charSet({'<', '>', '=', '^'})),
+             capture(?charSet({'-', '+', ' '})),
+             capture(?charSet({'#'})),
+             capture(?(+digits())),
+             capture(?charSet({','})),
+             capture(?sequence(charSet({'.'}), +digits())),
+             capture(?charSet({'b', 'c', 'd', 'e', 'E', 'f', 'F', 'g', 'G', 'n', 'o', 's', 'x', 'X', '%'})),
+             capture(?sequence(charSet({'a'}), *pegs.any())))
+  # let p=peg"{(_&[<>=^])?}{[<>=^]?}{[-+ ]?}{[#]?}{[0-9]+?}{[,]?}{([.][0-9]+)?}{[bcdeEfFgGnosxX%]?}{(a.*)?}"
+
+  var caps: Captures
+  if fmt.rawmatch(p, 0, caps) < 0:
+    raise newException(FormatError, "Invalid format string")
+
+  result.fill = fmt.get(caps, 0, nil)
+
+  case fmt.get(caps, 1, 0.char)
+  of '<': result.align = faLeft
+  of '>': result.align = faRight
+  of '^': result.align = faCenter
+  of '=': result.align = faPadding
+  else: result.align = faDefault
+
+  case fmt.get(caps, 2, '-')
+  of '-': result.sign = fsMinus
+  of '+': result.sign = fsPlus
+  of ' ': result.sign = fsSpace
+  else: result.sign = fsMinus
+
+  result.baseprefix = caps.has(3)
+
+  result.width = fmt.get(caps, 4, -1)
+
+  if caps.has(4) and fmt[caps.bounds(4).first] == '0':
+    if result.fill != nil:
+      raise newException(FormatError, "Leading 0 in with not allowed with explicit fill character")
+    if result.align != faDefault:
+      raise newException(FormatError, "Leading 0 in with not allowed with explicit alignment")
+    result.fill = "0"
+    result.align = faPadding
+
+  result.comma = caps.has(5)
+
+  result.precision = fmt.get(caps, 6, -1, 1)
+
+  case fmt.get(caps, 7, 0.char)
+  of 's': result.typ = ftStr
+  of 'c': result.typ = ftChar
+  of 'd', 'n': result.typ = ftDec
+  of 'b': result.typ = ftBin
+  of 'o': result.typ = ftOct
+  of 'x': result.typ = ftHex
+  of 'X': result.typ = ftHex; result.upcase = true
+  of 'f', 'F': result.typ = ftFix
+  of 'e': result.typ = ftSci
+  of 'E': result.typ = ftSci; result.upcase = true
+  of 'g': result.typ = ftGen
+  of 'G': result.typ = ftGen; result.upcase = true
+  of '%': result.typ = ftPercent
+  else: result.typ = ftDefault
+
+  result.arysep = fmt.get(caps, 8, nil, 1)
+
+proc getalign(fmt: Format; defalign: FmtAlign; slen: int) : tuple[left, right:int] {.nosideeffect.} =
+  ## Returns the number of left and right padding characters for a
+  ## given format alignment and width of the object to be printed.
+  ##
+  ## `fmt`
+  ##    the format data
+  ## `default`
+  ##    if `fmt.align == faDefault`, then this alignment is used
+  ## `slen`
+  ##    the width of the object to be printed.
+  ##
+  ## The returned values `(left, right)` will be as minimal as possible
+  ## so that `left + slen + right >= fmt.width`.
+  result.left = 0
+  result.right = 0
+  if (fmt.width >= 0) and (slen < fmt.width):
+    let alg = if fmt.align == faDefault: defalign else: fmt.align
+    case alg:
+    of faLeft: result.right = fmt.width - slen
+    of faRight, faPadding: result.left = fmt.width - slen
+    of faCenter:
+      result.left = (fmt.width - slen) div 2
+      result.right = fmt.width - slen - result.left
+    else: discard
+
+proc writefill(o: var Writer; fmt: Format; n: int; signum: int = 0) =
+  ## Write characters for filling. This function also writes the sign
+  ## of a numeric format and handles the padding alignment
+  ## accordingly.
+  ##
+  ## `o`
+  ##   output object
+  ## `add`
+  ##   output function
+  ## `fmt`
+  ##   format to be used (important for padding aligment)
+  ## `n`
+  ##   the number of filling characters to be written
+  ## `signum`
+  ##   the sign of the number to be written, < 0 negative, > 0 positive, = 0 zero
+  if fmt.align == faPadding and signum != 0:
+    if signum < 0: write(o, '-')
+    elif fmt.sign == fsPlus: write(o, '+')
+    elif fmt.sign == fsSpace: write(o, ' ')
+
+  if fmt.fill == nil:
+    for i in 1..n: write(o, ' ')
+  else:
+    for i in 1..n:
+      for c in fmt.fill:
+        write(o, c)
+
+  if fmt.align != faPadding and signum != 0:
+    if signum < 0: write(o, '-')
+    elif fmt.sign == fsPlus: write(o, '+')
+    elif fmt.sign == fsSpace: write(o, ' ')
+
+proc writeformat(o: var Writer; s: string; fmt: Format) =
+  ## Write string `s` according to format `fmt` using output object
+  ## `o` and output function `add`.
+  if fmt.typ notin {ftDefault, ftStr}:
+    raise newException(FormatError, "String variable must have 's' format type")
+
+  # compute alignment
+  let len = if fmt.precision < 0: runelen(s) else: min(runelen(s), fmt.precision)
+  var alg = getalign(fmt, faLeft, len)
+  writefill(o, fmt, alg.left)
+  var pos = 0
+  for i in 0..len-1:
+    let rlen = runeLenAt(s, pos)
+    for j in pos..pos+rlen-1: write(o, s[j])
+    pos += rlen
+  writefill(o, fmt, alg.right)
+
+proc writeformat(o: var Writer; c: char; fmt: Format) =
+  ## Write character `c` according to format `fmt` using output object
+  ## `o` and output function `add`.
+  if not (fmt.typ in {ftChar, ftDefault}):
+    raise newException(FormatError, "Character variable must have 'c' format type")
+
+  # compute alignment
+  var alg = getalign(fmt, faLeft, 1)
+  writefill(o, fmt, alg.left)
+  write(o, c)
+  writefill(o, fmt, alg.right)
+
+proc writeformat(o: var Writer; c: Rune; fmt: Format) =
+  ## Write rune `c` according to format `fmt` using output object
+  ## `o` and output function `add`.
+  if not (fmt.typ in {ftChar, ftDefault}):
+    raise newException(FormatError, "Character variable must have 'c' format type")
+
+  # compute alignment
+  var alg = getalign(fmt, faLeft, 1)
+  writefill(o, fmt, alg.left)
+  let s = c.toUTF8
+  for c in s: write(o, c)
+  writefill(o, fmt, alg.right)
+
+proc abs(x: SomeUnsignedInt): SomeUnsignedInt {.inline.} = x
+  ## Return the absolute value of the unsigned int `x`.
+
+proc writeformat(o: var Writer; i: SomeInteger; fmt: Format) =
+  ## Write integer `i` according to format `fmt` using output object
+  ## `o` and output function `add`.
+  var fmt = fmt
+  if fmt.typ == ftDefault:
+    fmt.typ = ftDec
+  if not (fmt.typ in {ftBin, ftOct, ftHex, ftDec}):
+    raise newException(FormatError, "Integer variable must of one of the following types: b,o,x,X,d,n")
+
+  var base: type(i)
+  var len = 0
+  case fmt.typ:
+  of ftDec:
+    base = 10
+  of ftBin:
+    base = 2
+    if fmt.baseprefix: len += 2
+  of ftOct:
+    base = 8
+    if fmt.baseprefix: len += 2
+  of ftHex:
+    base = 16
+    if fmt.baseprefix: len += 2
+  else: assert(false)
+
+  if fmt.sign != fsMinus or i < 0: len.inc
+
+  var x: type(i) = abs(i)
+  var irev: type(i) = 0
+  var ilen = 0
+  while x > 0.SomeInteger:
+    len.inc
+    ilen.inc
+    irev = irev * base + x mod base
+    x = x div base
+  if ilen == 0:
+    ilen.inc
+    len.inc
+
+  var alg = getalign(fmt, faRight, len)
+  writefill(o, fmt, alg.left, if i >= 0.SomeInteger: 1 else: -1)
+  if fmt.baseprefix:
+    case fmt.typ
+    of ftBin:
+      write(o, '0')
+      write(o, 'b')
+    of ftOct:
+      write(o, '0')
+      write(o, 'o')
+    of ftHex:
+      write(o, '0')
+      write(o, 'x')
+    else:
+      raise newException(FormatError, "# only allowed with b, o, x or X")
+  while ilen > 0:
+    ilen.dec
+    let c = irev mod base
+    irev = irev div base
+    if c < 10:
+      write(o, ('0'.int + c.int).char)
+    elif fmt.upcase:
+      write(o, ('A'.int + c.int - 10).char)
+    else:
+      write(o, ('a'.int + c.int - 10).char)
+  writefill(o, fmt, alg.right)
+
+proc writeformat(o: var Writer; p: pointer; fmt: Format) =
+  ## Write pointer `i` according to format `fmt` using output object
+  ## `o` and output function `add`.
+  ##
+  ## Pointers are casted to unsigned int and formated as hexadecimal
+  ## with prefix unless specified otherwise.
+  var f = fmt
+  if f.typ == 0.char:
+    f.typ = 'x'
+    f.baseprefix = true
+  writeformat(o, add, cast[uint](p), f)
+
+proc writeformat(o: var Writer; x: SomeReal; fmt: Format) =
+  ## Write real number `x` according to format `fmt` using output
+  ## object `o` and output function `add`.
+  var fmt = fmt
+  # handle default format
+  if fmt.typ == ftDefault:
+    fmt.typ = ftGen
+    if fmt.precision < 0: fmt.precision = DefaultPrec
+  if not (fmt.typ in {ftFix, ftSci, ftGen, ftPercent}):
+    raise newException(FormatError, "Integer variable must of one of the following types: f,F,e,E,g,G,%")
+
+  let positive = x >= 0 and classify(x) != fcNegZero
+  var len = 0
+
+  if fmt.sign != fsMinus or not positive: len.inc
+
+  var prec = if fmt.precision < 0: DefaultPrec else: fmt.precision
+  var y = abs(x)
+  var exp = 0
+  var numstr, frstr: array[0..31, char]
+  var numlen, frbeg, frlen = 0
+
+  if fmt.typ == ftPercent: y *= 100
+
+  case classify(x):
+  of fcNan:
+    numstr[0..2] = ['n', 'a', 'n']
+    numlen = 3
+  of fcInf, fcNegInf:
+    numstr[0..2] = ['f', 'n', 'i']
+    numlen = 3
+  of fcZero, fcNegZero:
+    numstr[0] = '0'
+    numlen = 1
+  else: # a usual fractional number
+    if not (fmt.typ in {ftFix, ftPercent}): # not fixed point
+      exp = int(floor(log10(y)))
+      if fmt.typ == ftGen:
+        if prec == 0: prec = 1
+        if -4 <= exp and exp < prec:
+          prec = prec-1-exp
+          exp = 0
+        else:
+          prec = prec - 1
+          len += 4 # exponent
+      else:
+        len += 4 # exponent
+      # shift y so that 1 <= abs(y) < 2
+      if exp > 0: y /= pow(10.SomeReal, abs(exp).SomeReal)
+      elif exp < 0: y *= pow(10.SomeReal, abs(exp).SomeReal)
+    elif fmt.typ == ftPercent:
+      len += 1 # percent sign
+
+    # handle rounding by adding +0.5 * LSB
+    if prec < len(round_nums): y += round_nums[prec]
+
+    # split into integer and fractional part
+    var mult = 1'i64
+    for i in 1..prec: mult *= 10
+    var num = y.int64
+    var fr = ((y - num.SomeReal) * mult.SomeReal).int64
+    # build integer part string
+    while num != 0:
+      numstr[numlen] = ('0'.int + (num mod 10)).char
+      numlen.inc
+      num = num div 10
+    if numlen == 0:
+      numstr[0] = '0'
+      numlen.inc
+    # build fractional part string
+    while fr != 0:
+      frstr[frlen] = ('0'.int + (fr mod 10)).char
+      frlen.inc
+      fr = fr div 10
+    while frlen < prec:
+      frstr[frlen] = '0'
+      frlen.inc
+    # possible remove trailing 0
+    if fmt.typ == ftGen:
+      while frbeg < frlen and frstr[frbeg] == '0': frbeg.inc
+  # update length of string
+  len += numlen;
+  if frbeg < frlen:
+    len += 1 + frlen - frbeg # decimal point and fractional string
+
+  let alg = getalign(fmt, faRight, len)
+  writefill(o, fmt, alg.left, if positive: 1 else: -1)
+  for i in (numlen-1).countdown(0): write(o, numstr[i])
+  if frbeg < frlen:
+    write(o, '.')
+    for i in (frlen-1).countdown(frbeg): write(o, frstr[i])
+  if fmt.typ == ftSci or (fmt.typ == ftGen and exp != 0):
+    write(o, if fmt.upcase: 'E' else: 'e')
+    if exp >= 0:
+      write(o, '+')
+    else:
+      write(o, '-')
+      exp = -exp
+    if exp < 10:
+      write(o, '0')
+      write(o, ('0'.int + exp).char)
+    else:
+      var i=0
+      while exp > 0:
+        numstr[i] = ('0'.int + exp mod 10).char
+        i+=1
+        exp = exp div 10
+      while i>0:
+        i-=1
+        write(o, numstr[i])
+  if fmt.typ == ftPercent: write(o, '%')
+  writefill(o, fmt, alg.right)
+
+proc writeformat(o: var Writer; b: bool; fmt: Format) =
+  ## Write boolean value `b` according to format `fmt` using output
+  ## object `o`. A boolean may be formatted numerically or as string.
+  ## In the former case true is written as 1 and false as 0, in the
+  ## latter the strings "true" and "false" are shown, respectively.
+  ## The default is string format.
+  if fmt.typ in {ftStr, ftDefault}:
+    writeformat(o,
+                if b: "true"
+                else: "false",
+                fmt)
+  elif fmt.typ in {ftBin, ftOct, ftHex, ftDec}:
+    writeformat(o,
+                if b: 1
+                else: 0,
+                fmt)
+  else:
+    raise newException(FormatError, "Boolean values must of one of the following types: s,b,o,x,X,d,n")
+
+proc writeformat(o: var Writer; ary: openarray[any]; fmt: Format) =
+  ## Write array `ary` according to format `fmt` using output object
+  ## `o` and output function `add`.
+  if ary.len == 0: return
+
+  var sep: string
+  var nxtfmt = fmt
+  if fmt.arysep == nil:
+    sep = "\t"
+  elif fmt.arysep.len == 0:
+    sep = ""
+  else:
+    let sepch = fmt.arysep[0]
+    let nxt = 1 + skipUntil(fmt.arysep, sepch, 1)
+    if nxt >= 1:
+      nxtfmt.arysep = fmt.arysep.substr(nxt)
+      sep = fmt.arysep.substr(1, nxt-1)
+    else:
+      nxtfmt.arysep = ""
+      sep = fmt.arysep.substr(1)
+  writeformat(o, ary[0], nxtfmt)
+  for i in 1..ary.len-1:
+    for c in sep: write(o, c)
+    writeformat(o, ary[i], nxtfmt)
+
+proc addformat[T](o: var Writer; x: T; fmt: Format = DefaultFmt) {.inline.} =
+  ## Write `x` formatted with `fmt` to `o`.
+  writeformat(o, x, fmt)
+
+proc addformat[T](o: var Writer; x: T; fmt: string) {.inline.} =
+  ## The same as `addformat(o, x, parse(fmt))`.
+  addformat(o, x, fmt.parse)
+
+proc addformat(s: var string; x: string) {.inline.} =
+  ## Write `x` to `s`. This is a fast specialized version for
+  ## appending unformatted strings.
+  add(s, x)
+
+proc addformat(f: File; x: string) {.inline.} =
+  ## Write `x` to `f`. This is a fast specialized version for
+  ## writing unformatted strings to a file.
+  write(f, x)
+
+proc addformat[T](f: File; x: T; fmt: Format = DefaultFmt) {.inline.} =
+  ## Write `x` to file `f` using format `fmt`.
+  var g = f
+  writeformat(g, x, fmt)
+
+proc addformat[T](f: File; x: T; fmt: string) {.inline.} =
+  ## Write `x` to file `f` using format string `fmt`. This is the same
+  ## as `addformat(f, x, parse(fmt))`
+  addformat(f, x, parse(fmt))
+
+proc addformat(s: Stream; x: string) {.inline.} =
+  ## Write `x` to `s`. This is a fast specialized version for
+  ## writing unformatted strings to a stream.
+  write(s, x)
+
+proc addformat[T](s: Stream; x: T; fmt: Format = DefaultFmt) {.inline.} =
+  ## Write `x` to stream `s` using format `fmt`.
+  var g = s
+  writeformat(g, x, fmt)
+
+proc addformat[T](s: Stream; x: T; fmt: string) {.inline.} =
+  ## Write `x` to stream `s` using format string `fmt`. This is the same
+  ## as `addformat(s, x, parse(fmt))`
+  addformat(s, x, parse(fmt))
+
+proc format[T](x: T; fmt: Format): string =
+  ## Return `x` formatted as a string according to format `fmt`.
+  result = ""
+  addformat(result, x, fmt)
+
+proc format[T](x: T; fmt: string): string =
+  ## Return `x` formatted as a string according to format string `fmt`.
+  result = format(x, fmt.parse)
+
+proc format[T](x: T): string {.inline.} =
+  ## Return `x` formatted as a string according to the default format.
+  ## The default format corresponds to an empty format string.
+  var fmt {.global.} : Format = DefaultFmt
+  result = format(x, fmt)
+
+proc unquoted(s: string): string {.compileTime.} =
+  ## Return `s` {{ and }} by single { and }, respectively.
+  result = ""
+  var pos = 0
+  while pos < s.len:
+    let nxt = pos + skipUntil(s, {'{', '}'})
+    result.add(s.substr(pos, nxt))
+    pos = nxt + 2
+
+proc splitfmt(s: string): seq[Part] {.compiletime, nosideeffect.} =
+  ## Split format string `s` into a sequence of "parts".
+  ##
+
+  ## Each part is either a literal string or a format specification. A
+  ## format specification is a substring of the form
+  ## "{[arg][:format]}" where `arg` is either empty or a number
+  ## refering to the arg-th argument and an additional field or array
+  ## index. The format string is a string accepted by `parse`.
+  let subpeg = sequence(capture(digits()),
+                          capture(?sequence(charSet({'.'}), *pegs.identStartChars(), *identChars())),
+                          capture(?sequence(charSet({'['}), +digits(), charSet({']'}))),
+                          capture(?sequence(charSet({':'}), *pegs.any())))
+  result = @[]
+  var pos = 0
+  while true:
+    let oppos = pos + skipUntil(s, {'{', '}'}, pos)
+    # reached the end
+    if oppos >= s.len:
+      if pos < s.len:
+        result.add(Part(kind: pkStr, str: s.substr(pos).unquoted))
+      return
+    # skip double
+    if oppos + 1 < s.len and s[oppos] == s[oppos+1]:
+      result.add(Part(kind: pkStr, str: s.substr(pos, oppos)))
+      pos = oppos + 2
+      continue
+    if s[oppos] == '}':
+      error("Single '}' encountered in format string")
+    if oppos > pos:
+      result.add(Part(kind: pkStr, str: s.substr(pos, oppos-1).unquoted))
+    # find matching closing }
+    var lvl = 1
+    var nested = false
+    pos = oppos
+    while lvl > 0:
+      pos.inc
+      pos = pos + skipUntil(s, {'{', '}'}, pos)
+      if pos >= s.len:
+        error("Single '{' encountered in format string")
+      if s[pos] == '{':
+        lvl.inc
+        if lvl == 2:
+          nested = true
+        if lvl > 2:
+          error("Too many nested format levels")
+      else:
+        lvl.dec
+    let clpos = pos
+    var fmtpart = Part(kind: pkFmt, arg: -1, fmt: s.substr(oppos+1, clpos-1), field: nil, index: int.high, nested: nested)
+    if fmtpart.fmt.len > 0:
+      var m: array[0..3, string]
+      if not fmtpart.fmt.match(subpeg, m):
+        error("invalid format string")
+
+      if m[1] != nil and m[1].len > 0:
+        fmtpart.field = m[1].substr(1)
+      if m[2] != nil and m[2].len > 0:
+        discard parseInt(m[2].substr(1, m[2].len-2), fmtpart.index)
+
+      if m[0].len > 0: discard parseInt(m[0], fmtpart.arg)
+      if m[3] == nil or m[3].len == 0:
+        fmtpart.fmt = ""
+      elif m[3][0] == ':':
+        fmtpart.fmt = m[3].substr(1)
+      else:
+        fmtpart.fmt = m[3]
+    result.add(fmtpart)
+    pos = clpos + 1
+
+proc literal(s: string): NimNode {.compiletime, nosideeffect.} =
+  ## Return the nim literal of string `s`. This handles the case if
+  ## `s` is nil.
+  result = if s == nil: newNilLit() else: newLit(s)
+
+proc literal(b: bool): NimNode {.compiletime, nosideeffect.} =
+  ## Return the nim literal of boolean `b`. This is either `true`
+  ## or `false` symbol.
+  result = if b: "true".ident else: "false".ident
+
+proc literal[T](x: T): NimNode {.compiletime, nosideeffect.} =
+  ## Return the nim literal of value `x`.
+  when type(x) is enum:
+    result = ($x).ident
+  else:
+    result = newLit(x)
+
+proc generatefmt(fmtstr: string;
+                 args: var openarray[tuple[arg:NimNode, cnt:int]];
+                 arg: var int;): seq[tuple[val, fmt:NimNode]] {.compiletime.} =
+  ## fmtstr
+  ##   the format string
+  ## args
+  ##   array of expressions for the arguments
+  ## arg
+  ##   the number of the next argument for automatic parsing
+  ##
+  ## If arg is < 0 then the functions assumes that explicit numbering
+  ## must be used, otherwise automatic numbering is used starting at
+  ## `arg`. The value of arg is updated according to the number of
+  ## arguments being used. If arg == 0 then automatic and manual
+  ## numbering is not decided (because no explicit manual numbering is
+  ## fixed und no automatically numbered argument has been used so
+  ## far).
+  ##
+  ## The function returns a list of pairs `(val, fmt)` where `val` is
+  ## an expression to be formatted and `fmt` is the format string (or
+  ## Format). Therefore, the resulting string can be generated by
+  ## concatenating expressions `val.format(fmt)`. If `fmt` is `nil`
+  ## then `val` is a (literal) string expression.
+  try:
+    result = @[]
+    for part in splitfmt(fmtstr):
+      case part.kind
+      of pkStr: result.add((newLit(part.str), nil))
+      of pkFmt:
+        # first compute the argument expression
+        # start with the correct index
+        var argexpr : NimNode
+        if part.arg >= 0:
+          if arg > 0:
+            error("Cannot switch from automatic field numbering to manual field specification")
+          if part.arg >= args.len:
+            error("Invalid explicit argument index: " & $part.arg)
+          argexpr = args[part.arg].arg
+          args[part.arg].cnt = args[part.arg].cnt + 1
+          arg = -1
+        else:
+          if arg < 0:
+            error("Cannot switch from manual field specification to automatic field numbering")
+          if arg >= args.len:
+            error("Too few arguments for format string")
+          argexpr = args[arg].arg
+          args[arg].cnt = args[arg].cnt + 1
+          arg.inc
+        # possible field access
+        if part.field != nil and part.field.len > 0:
+          argexpr = newDotExpr(argexpr, part.field.ident)
+        # possible array access
+        if part.index < int.high:
+          argexpr = newNimNode(nnkBracketExpr).add(argexpr, newLit(part.index))
+        # now the expression for the format data
+        var fmtexpr: NimNode
+        if part.nested:
+          # nested format string. Compute the format string by
+          # concatenating the parts of the substring.
+          for e in generatefmt(part.fmt, args, arg):
+            var newexpr = if part.fmt == nil: e.val else: newCall(bindsym"format", e.val, e.fmt)
+            if fmtexpr != nil and fmtexpr.kind != nnkNilLit:
+              fmtexpr = infix(fmtexpr, "&", newexpr)
+            else:
+              fmtexpr = newexpr
+        else:
+          # literal format string, precompute the format data
+          fmtexpr = newNimNode(nnkPar)
+          for field, val in part.fmt.parse.fieldPairs:
+            fmtexpr.add(newNimNode(nnkExprColonExpr).add(field.ident, literal(val)))
+        # add argument
+        result.add((argexpr, fmtexpr))
+  finally:
+    discard
+
+proc addfmtfmt(fmtstr: string; args: NimNode; retvar: NimNode): NimNode {.compileTime.} =
+  var argexprs = newseq[tuple[arg:NimNode; cnt:int]](args.len)
+  result = newNimNode(nnkStmtListExpr)
+  # generate let bindings for arguments
+  for i in 0..args.len-1:
+    let argsym = gensym(nskLet, "arg" & $i)
+    result.add(newLetStmt(argsym, args[i]))
+    argexprs[i].arg = argsym
+  # add result values
+  var arg = 0
+  for e in generatefmt(fmtstr, argexprs, arg):
+    if e.fmt == nil or e.fmt.kind == nnkNilLit:
+      result.add(newCall(bindsym"addformat", retvar, e.val))
+    else:
+      result.add(newCall(bindsym"addformat", retvar, e.val, e.fmt))
+  for i, arg in argexprs:
+    if arg.cnt == 0:
+      warning("Argument " & $(i+1) & " `" & args[i].repr & "` is not used in format string")
+
+macro addfmt(s: var string, fmtstr: string{lit}, args: varargs[expr]): expr =
+  ## The same as `s.add(fmtstr.fmt(args...))` but faster.
+  result = addfmtfmt($fmtstr, args, s)
+
+var s: string = ""
+s.addfmt("a:{}", 42)
diff --git a/tests/typerel/tregionptrs2.nim b/tests/typerel/tregionptrs2.nim
new file mode 100644
index 000000000..3b32ff93d
--- /dev/null
+++ b/tests/typerel/tregionptrs2.nim
@@ -0,0 +1,23 @@
+
+# bug #2039
+
+type
+    RegionTy = object
+    ThingyPtr = RegionTy ptr Thingy
+    Thingy = object
+        next: ThingyPtr
+        name: string
+
+proc iname(t: ThingyPtr) = 
+    var x = t
+
+    while not x.isNil:
+        echo x.name
+        x = x.next
+
+proc go() = 
+    var athing : ThingyPtr
+
+    iname(athing)
+
+go()
diff --git a/tests/typerel/tsymchoice_for_expr.nim b/tests/typerel/tsymchoice_for_expr.nim
new file mode 100644
index 000000000..4c1f52bef
--- /dev/null
+++ b/tests/typerel/tsymchoice_for_expr.nim
@@ -0,0 +1,15 @@
+# bug #1988
+
+template t(e: expr) = discard
+
+proc positive(x: int): int = +x
+proc negative(x: int): int = -x
+proc negative(x: float): float = -x
+
+proc p1 = t(negative)
+proc p2[X] = t(positive)
+proc p3[X] = t(negative)
+
+p1()      # This compiles.
+p2[int]() # This compiles.
+p3[int]() # This raises an error.
diff --git a/tests/typerel/typedescs.nim b/tests/typerel/typedescs.nim
new file mode 100644
index 000000000..23b9ce64f
--- /dev/null
+++ b/tests/typerel/typedescs.nim
@@ -0,0 +1,7 @@
+# bug #1774
+proc p(T: typedesc) = discard
+
+p(type((5, 6)))       # Compiles
+(type((5, 6))).p      # Doesn't compile (SIGSEGV: Illegal storage access.)
+type T = type((5, 6)) # Doesn't compile (SIGSEGV: Illegal storage access.)
+
diff --git a/tests/types/tauto_canbe_void.nim b/tests/types/tauto_canbe_void.nim
new file mode 100644
index 000000000..60e83c510
--- /dev/null
+++ b/tests/types/tauto_canbe_void.nim
@@ -0,0 +1,9 @@
+
+import future
+
+template tempo(s: expr) =
+  s("arg")
+
+tempo((s: string)->auto => echo(s))
+tempo((s: string) => echo(s))
+
diff --git a/tests/types/temptyseqs.nim b/tests/types/temptyseqs.nim
index f8d22bdb8..834f63729 100644
--- a/tests/types/temptyseqs.nim
+++ b/tests/types/temptyseqs.nim
@@ -1,11 +1,19 @@
 discard """
-  output: "1"
+  output: '''1
+foo
+bar
+baz
+foo
+bar
+baz
+yes
+no'''
 """
 
 # bug #1708
 let foo = {
   "1" : (bar: @["1"]),
-  "2" : (baz: @[])
+  "2" : (bar: @[])
 }
 
 # bug #871
@@ -24,3 +32,59 @@ when true:
 const foo2: seq[string] = @[]
 
 echo foo[0][0][0]
+
+proc takeEmpty(x: openArray[string] = []) = discard
+takeEmpty()
+takeEmpty([])
+
+proc takeEmpty2(x: openArray[string] = @[]) = discard
+takeEmpty2()
+takeEmpty2([])
+takeEmpty2(@[])
+
+#takeEmpty2([nil])
+
+#rawMessage(errExecutionOfProgramFailed, [])
+
+# bug #2470
+const
+  stuff: seq[string] = @[]
+
+for str in stuff:
+  echo "str=", str
+
+# bug #1354
+proc foo4[T](more: seq[T] = @[]) =
+  var more2 = more
+
+foo4[int]()
+
+proc maino: int =
+  var wd: cstring = nil
+  inc result
+
+discard maino()
+
+proc varargso(a: varargs[string]) =
+  for x in a:
+    echo x
+
+varargso(["foo", "bar", "baz"])
+varargso("foo", "bar", "baz")
+
+
+type
+  Flago = enum
+    tfNeedsInit, tfNotNil
+
+var s: set[Flago] = {tfNeedsInit}
+
+if {tfNeedsInit, tfNotNil} * s != {}:
+  echo "yes"
+else:
+  echo "no"
+
+if {tfNeedsInit, tfNotNil} * s <= {tfNotNil}:
+  echo "yes"
+else:
+  echo "no"
diff --git a/tests/types/tforwty2.nim b/tests/types/tforwty2.nim
index d103314c5..52af1c7dd 100644
--- a/tests/types/tforwty2.nim
+++ b/tests/types/tforwty2.nim
@@ -1,5 +1,5 @@
 # Test for a hard to fix internal error

-# occured in the SDL library

+# occurred in the SDL library

 

 {.push dynlib: "SDL.dll", callconv: cdecl.}

 

diff --git a/tests/types/tinfiniterecursion.nim b/tests/types/tinfiniterecursion.nim
new file mode 100644
index 000000000..52eaaa93b
--- /dev/null
+++ b/tests/types/tinfiniterecursion.nim
@@ -0,0 +1,8 @@
+discard """
+  errormsg: "illegal recursion in type 'XIM'"
+  line: 8
+"""
+
+type
+  XIM* = ptr XIM
+  XIMProc* = proc (a2: XIM)
diff --git a/tests/types/tisopr.nim b/tests/types/tisopr.nim
index 3c2b9ee5e..b9acfa5fb 100644
--- a/tests/types/tisopr.nim
+++ b/tests/types/tisopr.nim
@@ -1,5 +1,11 @@
 discard """
-  output: '''true true false yes'''
+  output: '''true true false yes
+false
+false
+false
+true
+true
+no'''
 """
 
 proc IsVoid[T](): string =
@@ -28,9 +34,57 @@ no  s.items is iterator: float
 yes s.items is iterator: TNumber
 no  s.items is iterator: object
 
-type 
+type
   Iter[T] = iterator: T
 
 yes s.items is Iter[TNumber]
 no  s.items is Iter[float]
 
+type
+  Foo[N: static[int], T] = object
+    field: array[1..N, T]
+
+  Bar[T] = Foo[4, T]
+  Baz[N: static[int]] = Foo[N, float]
+
+no Foo[2, float] is Foo[3, float]
+no Foo[2, float] is Foo[2, int]
+
+yes Foo[4, string] is Foo[4, string]
+yes Bar[int] is Foo[4, int]
+yes Foo[4, int] is Bar[int]
+
+no Foo[4, int] is Baz[4]
+yes Foo[4, float] is Baz[4]
+
+
+# bug #2505
+
+echo(8'i8 is int32)
+
+# bug #1853
+type SeqOrSet[E] = seq[E] or set[E]
+type SeqOfInt = seq[int]
+type SeqOrSetOfInt = SeqOrSet[int]
+
+# This prints "false", which seems less correct that (1) printing "true" or (2)
+# raising a compiler error.
+echo seq is SeqOrSet
+
+# This prints "false", as expected.
+echo seq is SeqOrSetOfInt
+
+# This prints "true", as expected.
+echo SeqOfInt is SeqOrSet
+
+# This causes an internal error (filename: compiler/semtypes.nim, line: 685).
+echo SeqOfInt is SeqOrSetOfInt
+
+# bug #2522
+proc test[T](x: T) =
+  when T is typedesc:
+    echo "yes"
+  else:
+    echo "no"
+
+test(7)
diff --git a/tests/usingstmt/tusingstatement.nim b/tests/usingstmt/tusingstatement.nim
index b58478d74..0d76b2423 100644
--- a/tests/usingstmt/tusingstatement.nim
+++ b/tests/usingstmt/tusingstatement.nim
@@ -3,13 +3,13 @@ discard """
   output: "Using test.Closing test."
 """
 
-import 
+import
   macros
 
 # This macro mimics the using statement from C#
 #
 # It's kept only as a test for the macro system
-# Nim's destructors offer a mechanism for automatic 
+# Nim's destructors offer a mechanism for automatic
 # disposal of resources.
 #
 macro autoClose(e: expr): stmt {.immediate.} =
@@ -20,19 +20,19 @@ macro autoClose(e: expr): stmt {.immediate.} =
 
   var args = e
   var body = e[2]
-  
-  var 
-    variables : seq[PNimrodNode]
-    closingCalls : seq[PNimrodNode]
+
+  var
+    variables : seq[NimNode]
+    closingCalls : seq[NimNode]
 
   newSeq(variables, 0)
   newSeq(closingCalls, 0)
-  
+
   for i in countup(1, args.len-2):
     if args[i].kind == nnkExprEqExpr:
       var varName = args[i][0]
       var varValue = args[i][1]
- 
+
       var varAssignment = newNimNode(nnkIdentDefs)
       varAssignment.add(varName)
       varAssignment.add(newNimNode(nnkEmpty)) # empty means no type
@@ -43,7 +43,7 @@ macro autoClose(e: expr): stmt {.immediate.} =
     else:
       error "Using statement: Unexpected expression. Got " &
         $args[i].kind & " instead of assignment."
-  
+
   var varSection = newNimNode(nnkVarSection)
   varSection.add(variables)
 
@@ -67,10 +67,10 @@ macro autoClose(e: expr): stmt {.immediate.} =
   targetAst[0][1][0] = varSection
   targetAst[0][1][1][0] = body
   targetAst[0][1][1][1][0] = finallyBlock
-  
+
   result = targetAst
 
-type 
+type
   TResource* = object
     field*: string
 
diff --git a/tests/vm/tconsteval.nim b/tests/vm/tconsteval.nim
index 96a1bafe8..4459931c5 100644
--- a/tests/vm/tconsteval.nim
+++ b/tests/vm/tconsteval.nim
@@ -24,7 +24,7 @@ Possible Commands:
   csource [options]        builds the C sources for installation
   zip                      builds the installation ZIP package
   inno                     builds the Inno Setup installer
-""" % [NimVersion & repeatChar(44-len(NimVersion)), 
+""" % [NimVersion & spaces(44-len(NimVersion)), 
        CompileDate, CompileTime]
 
 echo HelpText
diff --git a/tests/vm/tconsttable.nim b/tests/vm/tconsttable.nim
new file mode 100644
index 000000000..64a74a59d
--- /dev/null
+++ b/tests/vm/tconsttable.nim
@@ -0,0 +1,19 @@
+discard """
+  output: '''is
+finally
+nice!'''
+"""
+
+import tables
+
+const
+  foo = {"ah": "finally", "this": "is", "possible.": "nice!"}.toTable()
+
+# protect against overly smart compiler:
+var x = "this"
+
+echo foo[x]
+x = "ah"
+echo foo[x]
+x = "possible."
+echo foo[x]
diff --git a/tests/vm/tldconst.nim b/tests/vm/tldconst.nim
new file mode 100644
index 000000000..9eabb7525
--- /dev/null
+++ b/tests/vm/tldconst.nim
@@ -0,0 +1,14 @@
+# Passes if it compiles
+# From issue #1946
+
+type
+  Part = object
+    index: int ## array index of argument to be accessed
+
+proc foobar(): int =
+    var x: Part
+    if x.index < high(int):
+        discard
+    0
+
+const x = foobar()
\ No newline at end of file
diff --git a/tests/vm/tstringnil.nim b/tests/vm/tstringnil.nim
index 61ce60ee5..bb546b698 100644
--- a/tests/vm/tstringnil.nim
+++ b/tests/vm/tstringnil.nim
@@ -8,9 +8,9 @@ type
     suiteDesc: string
     testName: string
     testDesc: string
-    testBlock: PNimrodNode
+    testBlock: NimNode
 
-proc buildSuiteContents(suiteName, suiteDesc, suiteBloc: PNimrodNode): tuple[tests: seq[SuiteTest]]  {.compileTime.} =
+proc buildSuiteContents(suiteName, suiteDesc, suiteBloc: NimNode): tuple[tests: seq[SuiteTest]]  {.compileTime.} =
   var
     tests:seq[SuiteTest] = @[]
 
@@ -40,7 +40,7 @@ proc buildSuiteContents(suiteName, suiteDesc, suiteBloc: PNimrodNode): tuple[tes
       discard
 
   return (tests: tests)
- 
+
 macro suite(suiteName, suiteDesc: expr, suiteBloc: stmt): stmt {.immediate.} =
   let contents = buildSuiteContents(suiteName, suiteDesc, suiteBloc)