From c9616897f0e0d932c75b61ed96124d8cbac35076 Mon Sep 17 00:00:00 2001 From: Flaviu Tamas Date: Tue, 26 May 2015 18:29:44 -0400 Subject: [PATCH 1/2] Don't inspect typedescs --- lib/pure/unittest.nim | 13 +++++++------ tests/stdlib/tunittest.nim | 5 +++++ 2 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 tests/stdlib/tunittest.nim diff --git a/lib/pure/unittest.nim b/lib/pure/unittest.nim index 3bf4724b90..092b1fba26 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 0000000000..3726eaa9ec --- /dev/null +++ b/tests/stdlib/tunittest.nim @@ -0,0 +1,5 @@ +import unittest +import options +test "unittest typedescs": + check(none(int) == none(int)) + check(none(int) != some(1)) From 3daef85d6ee73c7ef3c89c5ca0738698bcdbfbfa Mon Sep 17 00:00:00 2001 From: Flaviu Tamas Date: Tue, 26 May 2015 18:32:10 -0400 Subject: [PATCH 2/2] Fix #964, fix #1384 Doesn't actually fix those bugs, but they can no longer be reproduced. Test cases have been added. --- tests/stdlib/tunittest.nim | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/stdlib/tunittest.nim b/tests/stdlib/tunittest.nim index 3726eaa9ec..b23b3cdab5 100644 --- a/tests/stdlib/tunittest.nim +++ b/tests/stdlib/tunittest.nim @@ -1,4 +1,20 @@ 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))