Fix a compilation issue in the roundtripTest when used with case objects

This commit is contained in:
Zahary Karadjov 2019-08-01 17:13:27 +03:00
parent 99daa96284
commit e26985dec3
No known key found for this signature in database
GPG Key ID: C8936F8A3073D609
1 changed files with 4 additions and 1 deletions

View File

@ -32,6 +32,8 @@ type
proc default(T: typedesc): T = discard
template roundtripTest*(Format: type, value: auto, expectedResult: auto) =
mixin `==`
test Format.name & " " & value.type.name & " roundtrip":
let v = value
let serialized = Format.encode(v)
@ -43,7 +45,8 @@ template roundtripTest*(Format: type, value: auto, expectedResult: auto) =
try:
let decoded = Format.decode(serialized, v.type)
checkpoint "(decoded value): " & repr(decoded)
check decoded == v
let decodedValueMatchesOriginal = decoded == v
check decodedValueMatchesOriginal
except SerializationError as err:
checkpoint "(serialization error): " & err.formatMsg("(encoded value)")
fail()