diff options
-rw-r--r-- | lib/pure/unittest.nim | 3 | ||||
-rw-r--r-- | tests/stdlib/tunittestpass.nim | 19 |
2 files changed, 21 insertions, 1 deletions
diff --git a/lib/pure/unittest.nim b/lib/pure/unittest.nim index ab45f78dc..18b09e4c0 100644 --- a/lib/pure/unittest.nim +++ b/lib/pure/unittest.nim @@ -669,7 +669,8 @@ macro check*(conditions: untyped): untyped = let paramAst = exp[i] if exp[i].kind == nnkIdent: result.printOuts.add getAst(print(argStr, paramAst)) - if exp[i].kind in nnkCallKinds + {nnkDotExpr, nnkBracketExpr, nnkPar}: + if exp[i].kind in nnkCallKinds + {nnkDotExpr, nnkBracketExpr, nnkPar} and + (exp[i].typeKind notin {ntyTypeDesc} or $exp[0] notin ["is", "isnot"]): let callVar = newIdentNode(":c" & $counter) result.assigns.add getAst(asgn(callVar, paramAst)) result.check[i] = callVar diff --git a/tests/stdlib/tunittestpass.nim b/tests/stdlib/tunittestpass.nim new file mode 100644 index 000000000..cff37a3b7 --- /dev/null +++ b/tests/stdlib/tunittestpass.nim @@ -0,0 +1,19 @@ +discard """ + targets: "c js" +""" + + +import unittest + +block: + check (type(1.0)) is float + check type(1.0) is float + check (typeof(1)) isnot float + check typeof(1) isnot float + + check 1.0 is float + check 1 isnot float + + type T = type(0.1) + check T is float + check T isnot int |