summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2015-05-27 01:26:55 +0200
committerAndreas Rumpf <rumpf_a@web.de>2015-05-27 01:26:55 +0200
commit860eca32a526eb6ae2a990954f1b43d9986367b5 (patch)
tree139e376762cc0b792f2e41d609483f14a0f5e7cc
parent4fc9dabd58295cb4df27d2246c7f19661c878367 (diff)
parent3daef85d6ee73c7ef3c89c5ca0738698bcdbfbfa (diff)
downloadNim-860eca32a526eb6ae2a990954f1b43d9986367b5.tar.gz
Merge pull request #2817 from flaviut/fix-unittest
Fix unittest problems
-rw-r--r--lib/pure/unittest.nim13
-rw-r--r--tests/stdlib/tunittest.nim21
2 files changed, 28 insertions, 6 deletions
diff --git a/lib/pure/unittest.nim b/lib/pure/unittest.nim
index 3bf4724b9..092b1fba2 100644
--- a/lib/pure/unittest.nim
+++ b/lib/pure/unittest.nim
@@ -157,12 +157,13 @@ macro check*(conditions: stmt): stmt {.immediate.} =
           #   Ident !"v"
           #   IntLit 2
           paramAst = exp[i][1]
-        argsAsgns.add getAst(asgn(arg, paramAst))
-        argsPrintOuts.add getAst(print(argStr, arg))
-        if exp[i].kind != nnkExprEqExpr:
-          exp[i] = arg
-        else:
-          exp[i][1] = arg
+        if exp[i].typekind notin {ntyTypeDesc}:
+          argsAsgns.add getAst(asgn(arg, paramAst))
+          argsPrintOuts.add getAst(print(argStr, arg))
+          if exp[i].kind != nnkExprEqExpr:
+            exp[i] = arg
+          else:
+            exp[i][1] = arg
 
   case checked.kind
   of nnkCallKinds:
diff --git a/tests/stdlib/tunittest.nim b/tests/stdlib/tunittest.nim
new file mode 100644
index 000000000..b23b3cdab
--- /dev/null
+++ b/tests/stdlib/tunittest.nim
@@ -0,0 +1,21 @@
+import unittest
+
+
+proc doThings(spuds: var int): int =
+  spuds = 24
+  return 99
+test "#964":
+  var spuds = 0
+  check doThings(spuds) == 99
+  check spuds == 24
+
+
+from strutils import toUpper
+test "#1384":
+  check(@["hello", "world"].map(toUpper) == @["HELLO", "WORLD"])
+
+
+import options
+test "unittest typedescs":
+  check(none(int) == none(int))
+  check(none(int) != some(1))