Skip to content

Commit

Permalink
fix #6736: templates in unittest now show actual value (#13354)
Browse files Browse the repository at this point in the history
  • Loading branch information
narimiran authored Feb 7, 2020
1 parent 78b15de commit f3117d3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/pure/unittest.nim
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ macro check*(conditions: untyped): untyped =

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", "==", "<=",
">=", "<", ">", "!=", "is", "isnot"]:

Expand Down
25 changes: 25 additions & 0 deletions tests/stdlib/tunittesttemplate.nim
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit f3117d3

Please sign in to comment.