Skip to content

Commit f3117d3

Browse files
authored
fix #6736: templates in unittest now show actual value (#13354)
1 parent 78b15de commit f3117d3

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

lib/pure/unittest.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ macro check*(conditions: untyped): untyped =
631631

632632
var counter = 0
633633

634-
if exp[0].kind == nnkIdent and
634+
if exp[0].kind in {nnkIdent, nnkOpenSymChoice, nnkClosedSymChoice, nnkSym} and
635635
$exp[0] in ["not", "in", "notin", "==", "<=",
636636
">=", "<", ">", "!=", "is", "isnot"]:
637637

tests/stdlib/tunittesttemplate.nim

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
discard """
2+
exitcode: 1
3+
outputsub: '''
4+
tunittesttemplate.nim(20, 12): Check failed: a.b ==
5+
2
6+
a.b was 0
7+
[FAILED] 1
8+
'''
9+
"""
10+
11+
# bug #6736
12+
13+
import unittest
14+
15+
type
16+
A = object
17+
b: int
18+
19+
template t: untyped =
20+
check(a.b == 2)
21+
22+
suite "1":
23+
test "1":
24+
var a = A(b: 0)
25+
t()

0 commit comments

Comments
 (0)