summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/nimrod.cfg1
-rw-r--r--compiler/nimrod.nim6
-rw-r--r--compiler/sigmatch.nim17
-rw-r--r--compiler/testability.nim5
-rw-r--r--lib/pure/unittest.nim8
5 files changed, 31 insertions, 6 deletions
diff --git a/compiler/nimrod.cfg b/compiler/nimrod.cfg
index ac8f732f1..9fa1b8cba 100644
--- a/compiler/nimrod.cfg
+++ b/compiler/nimrod.cfg
@@ -11,4 +11,5 @@ path:"$projectPath/.."
 path:"$lib/packages/docutils"
 
 define:booting
+import:testability
 
diff --git a/compiler/nimrod.nim b/compiler/nimrod.nim
index 3fa80cebb..2f10e32e3 100644
--- a/compiler/nimrod.nim
+++ b/compiler/nimrod.nim
@@ -76,5 +76,7 @@ when compileOption("gc", "v2") or compileOption("gc", "refc"):
   # the new correct mark&sweet collector is too slow :-/
   GC_disableMarkAndSweep()
 condsyms.InitDefines()
-HandleCmdLine()
-quit(int8(msgs.gErrorCounter > 0))
+
+when not defined(selftest):
+  HandleCmdLine()
+  quit(int8(msgs.gErrorCounter > 0))
diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim
index 00f3b2b10..12a5708b6 100644
--- a/compiler/sigmatch.nim
+++ b/compiler/sigmatch.nim
@@ -1130,7 +1130,7 @@ proc matches*(c: PContext, n, nOrig: PNode, m: var TCandidate) =
   var f = 1
   while f < sonsLen(m.callee.n):
     var formal = m.callee.n.sons[f].sym
-    if not ContainsOrIncl(marker, formal.position): 
+    if not ContainsOrIncl(marker, formal.position):
       if formal.ast == nil:
         if formal.typ.kind == tyVarargs:
           var container = newNodeIT(nkBracket, n.info, arrayConstr(c, n.info))
@@ -1145,7 +1145,7 @@ proc matches*(c: PContext, n, nOrig: PNode, m: var TCandidate) =
         setSon(m.call, formal.position + 1, copyTree(formal.ast))
     inc(f)
 
-proc argtypeMatches*(c: PContext, f, a: PType): bool = 
+proc argtypeMatches*(c: PContext, f, a: PType): bool =
   var m: TCandidate
   initCandidate(m, f)
   let res = paramTypesMatch(c, m, f, a, ast.emptyNode, nil)
@@ -1155,3 +1155,16 @@ proc argtypeMatches*(c: PContext, f, a: PType): bool =
   result = res != nil
 
 include suggest
+
+
+
+tests:
+  suite "typerel":
+    test "ordinals":
+      # var owner = newSym(skModule, getIdent("dummy"), nil, UnknownLineInfo())
+      var m: TCandidate
+      InitCandidate(m, f)
+
+      # let f = newType(tyOrdinal, owner)
+      # let a = getSysType(tyInt)
+      # check typerel(m, f, a) == isGeneric
diff --git a/compiler/testability.nim b/compiler/testability.nim
new file mode 100644
index 000000000..ceefd0a5e
--- /dev/null
+++ b/compiler/testability.nim
@@ -0,0 +1,5 @@
+template tests*(body: stmt) {.immediate.} =
+  when defined(selftest):
+    when not defined(unittest): import unittest
+    body
+
diff --git a/lib/pure/unittest.nim b/lib/pure/unittest.nim
index 71f4d498b..20f5c610e 100644
--- a/lib/pure/unittest.nim
+++ b/lib/pure/unittest.nim
@@ -98,8 +98,12 @@ template fail* =
 
   when not defined(ECMAScript):
     if AbortOnError: quit(1)
-  
-  TestStatusIMPL = FAILED
+ 
+  when defined(TestStatusIMPL):
+    TestStatusIMPL = FAILED
+  else:
+    program_result += 1
+
   checkpoints = @[]
 
 macro check*(conditions: stmt): stmt {.immediate.} =