Skip to content

Commit 1b236f5

Browse files
committed
fix
1 parent b7abc86 commit 1b236f5

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

tests/tunittest.nim

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,24 @@ suite "bug #5784":
184184
var obj: Obj
185185
check obj.isNil or obj.field == 0
186186

187+
suite "PR #65":
188+
test "no $ defined compiles":
189+
type Foo = distinct int
190+
proc `==`(a, b: Foo): bool {.borrow.}
191+
192+
var v = Foo(1)
193+
check:
194+
v == Foo(1)
195+
196+
test "$ return non-string compiles":
197+
type Foo = distinct int
198+
proc `==`(a, b: Foo): bool {.borrow.}
199+
proc `$`(x: Foo): Foo = x
200+
201+
var v = Foo(1)
202+
check:
203+
v == Foo(1)
204+
187205
type
188206
SomeType = object
189207
value: int

unittest2.nim

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,8 +1249,9 @@ macro check*(conditions: untyped): untyped =
12491249
{.warning[Deprecated]:on.}
12501250

12511251
template print(name: untyped, value: typed) =
1252-
when compiles($value) and typeof($value) is string:
1253-
checkpoint(name & " was " & $value)
1252+
when compiles($value):
1253+
when typeof($value) is string:
1254+
checkpoint(name & " was " & $value)
12541255

12551256
proc inspectArgs(exp: NimNode): tuple[frame, inner, check, printOuts: NimNode] =
12561257
result.check = copyNimTree(exp)

0 commit comments

Comments
 (0)