fix #6736: templates in unittest now show actual value (#13354)

This commit is contained in:
Miran 2020-02-07 22:04:08 +01:00 • committed by GitHub
commit f3117d350e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 1 deletions

View file

@ -631,7 +631,7 @@ macro check*(conditions: untyped): untyped =
var counter = 0 var counter = 0
if exp[0].kind == nnkIdent and if exp[0].kind in {nnkIdent, nnkOpenSymChoice, nnkClosedSymChoice, nnkSym} and
$exp[0] in ["not", "in", "notin", "==", "<=", $exp[0] in ["not", "in", "notin", "==", "<=",
">=", "<", ">", "!=", "is", "isnot"]: ">=", "<", ">", "!=", "is", "isnot"]:

View file

@ -0,0 +1,25 @@
discard """
exitcode: 1
outputsub: '''
tunittesttemplate.nim(20, 12): Check failed: a.b ==
2
a.b was 0
[FAILED] 1
'''
"""
# bug #6736
import unittest
type
A = object
b: int
template t: untyped =
check(a.b == 2)
suite "1":
test "1":
var a = A(b: 0)
t()