From 95bb19a57938b75a58169f816856be0cad4474b9 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Mon, 30 May 2016 15:07:19 +0200 Subject: moved random procs from math to its own module (breaking change) --- tests/stdlib/tunittest.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/stdlib/tunittest.nim') diff --git a/tests/stdlib/tunittest.nim b/tests/stdlib/tunittest.nim index 4b210c23b..73113ac68 100644 --- a/tests/stdlib/tunittest.nim +++ b/tests/stdlib/tunittest.nim @@ -26,7 +26,7 @@ test "unittest multiple requires": require(true) -import math +import math, random from strutils import parseInt proc defectiveRobot() = randomize() -- cgit 1.4.1-2-gfad0 From fc0bb828027d0893435613668fa9bb12e47dd169 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Fri, 22 Jul 2016 12:29:05 +0200 Subject: fixes #4494 --- lib/pure/unittest.nim | 53 ++++++++++++++++++++++++---------------------- tests/stdlib/tunittest.nim | 6 ++++++ 2 files changed, 34 insertions(+), 25 deletions(-) (limited to 'tests/stdlib/tunittest.nim') diff --git a/lib/pure/unittest.nim b/lib/pure/unittest.nim index e8a23f27e..7e3983a0d 100644 --- a/lib/pure/unittest.nim +++ b/lib/pure/unittest.nim @@ -259,31 +259,34 @@ macro check*(conditions: stmt): stmt {.immediate.} = proc inspectArgs(exp: NimNode): NimNode = result = copyNimTree(exp) - for i in countup(1, exp.len - 1): - if exp[i].kind notin nnkLiterals: - inc counter - var arg = newIdentNode(":p" & $counter) - var argStr = exp[i].toStrLit - var paramAst = exp[i] - if exp[i].kind == nnkIdent: - argsPrintOuts.add getAst(print(argStr, paramAst)) - if exp[i].kind in nnkCallKinds: - var callVar = newIdentNode(":c" & $counter) - argsAsgns.add getAst(asgn(callVar, paramAst)) - result[i] = callVar - argsPrintOuts.add getAst(print(argStr, callVar)) - if exp[i].kind == nnkExprEqExpr: - # ExprEqExpr - # Ident !"v" - # IntLit 2 - result[i] = exp[i][1] - if exp[i].typekind notin {ntyTypeDesc}: - argsAsgns.add getAst(asgn(arg, paramAst)) - argsPrintOuts.add getAst(print(argStr, arg)) - if exp[i].kind != nnkExprEqExpr: - result[i] = arg - else: - result[i][1] = arg + if exp[0].kind == nnkIdent and + $exp[0] in ["and", "or", "not", "in", "notin", "==", "<=", + ">=", "<", ">", "!=", "is", "isnot"]: + for i in countup(1, exp.len - 1): + if exp[i].kind notin nnkLiterals: + inc counter + var arg = newIdentNode(":p" & $counter) + var argStr = exp[i].toStrLit + var paramAst = exp[i] + if exp[i].kind == nnkIdent: + argsPrintOuts.add getAst(print(argStr, paramAst)) + if exp[i].kind in nnkCallKinds: + var callVar = newIdentNode(":c" & $counter) + argsAsgns.add getAst(asgn(callVar, paramAst)) + result[i] = callVar + argsPrintOuts.add getAst(print(argStr, callVar)) + if exp[i].kind == nnkExprEqExpr: + # ExprEqExpr + # Ident !"v" + # IntLit 2 + result[i] = exp[i][1] + if exp[i].typekind notin {ntyTypeDesc}: + argsAsgns.add getAst(asgn(arg, paramAst)) + argsPrintOuts.add getAst(print(argStr, arg)) + if exp[i].kind != nnkExprEqExpr: + result[i] = arg + else: + result[i][1] = arg case checked.kind of nnkCallKinds: diff --git a/tests/stdlib/tunittest.nim b/tests/stdlib/tunittest.nim index 73113ac68..e87cd3508 100644 --- a/tests/stdlib/tunittest.nim +++ b/tests/stdlib/tunittest.nim @@ -83,3 +83,9 @@ suite "suite with both": test "unittest with both 2": check c == 2 + +suite "bug #4494": + test "Uniqueness check": + var tags = @[1, 2, 3, 4, 5] + check: + allIt(0..3, tags[it] != tags[it + 1]) -- cgit 1.4.1-2-gfad0