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