mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-03 03:32:32 +00:00
Merge pull request #2817 from flaviut/fix-unittest
Fix unittest problems
This commit is contained in:
@@ -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:
|
||||
|
||||
21
tests/stdlib/tunittest.nim
Normal file
21
tests/stdlib/tunittest.nim
Normal file
@@ -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))
|
||||
Reference in New Issue
Block a user