More fix to exception tracking and generic_suite
This fixes required by nim-json-serialization to pass test with nim devel since we drop support for nim 1.2 and 1.4
This commit is contained in:
parent
09b131c919
commit
9f56a0738c
|
@ -23,7 +23,7 @@ template encode*(Format: type, value: auto, params: varargs[untyped]): auto =
|
|||
raise (ref Defect)() # a memoryOutput cannot have an IOError
|
||||
|
||||
# TODO Nim cannot make sense of this initialization by var param?
|
||||
proc readValue*(reader: var auto, T: type): T =
|
||||
proc readValue*(reader: var auto, T: type): T {.gcsafe, raises: [SerializationError, IOError].} =
|
||||
{.warning[ProveInit]: off.}
|
||||
mixin readValue
|
||||
result = default(T)
|
||||
|
|
|
@ -377,7 +377,7 @@ proc genCustomSerializationForField(Format, field,
|
|||
type ReaderType = Reader(`Format`)
|
||||
proc readFieldIMPL*(F: type FieldTag[`RecordType`, `fieldName`],
|
||||
`readerSym`: var ReaderType): `FieldType`
|
||||
{.raises: [IOError, SerializationError, Defect], gcsafe.} =
|
||||
{.raises: [IOError, SerializationError], gcsafe.} =
|
||||
`readBody`
|
||||
|
||||
if writeBody != nil:
|
||||
|
@ -387,7 +387,7 @@ proc genCustomSerializationForField(Format, field,
|
|||
F: type FieldTag[`RecordType`, `fieldName`],
|
||||
`valueSym`: auto,
|
||||
`holderSym`: `RecordType`)
|
||||
{.raises: [IOError, Defect], gcsafe.} =
|
||||
{.raises: [IOError], gcsafe.} =
|
||||
`writeBody`
|
||||
|
||||
proc genCustomSerializationForType(Format, typ: NimNode,
|
||||
|
@ -398,7 +398,7 @@ proc genCustomSerializationForType(Format, typ: NimNode,
|
|||
result.add quote do:
|
||||
type ReaderType = Reader(`Format`)
|
||||
proc readValue*(`readerSym`: var ReaderType, T: type `typ`): `typ`
|
||||
{.raises: [IOError, SerializationError, Defect], gcsafe.} =
|
||||
{.raises: [IOError, SerializationError], gcsafe.} =
|
||||
`readBody`
|
||||
|
||||
if writeBody != nil:
|
||||
|
|
|
@ -136,6 +136,14 @@ func caseObjectEquals(a, b: CaseObject): bool =
|
|||
func `==`*(a, b: CaseObject): bool =
|
||||
caseObjectEquals(a, b)
|
||||
|
||||
func `==`*(a, b: ListOfLists): bool =
|
||||
if a.lists.len != b.lists.len:
|
||||
return false
|
||||
for i in 0..<a.lists.len:
|
||||
if a.lists[i] != b.lists[i]:
|
||||
return false
|
||||
true
|
||||
|
||||
template maybeDefer(x: auto): auto =
|
||||
when type(x) is ref:
|
||||
x[]
|
||||
|
@ -151,6 +159,9 @@ template roundtripChecks*(Format: type, value: auto, expectedResult: auto) =
|
|||
check serialized == expectedResult
|
||||
|
||||
try:
|
||||
const typeName = typetraits.name(type(origValue))
|
||||
{.warning: "WWW: " & typeName.}
|
||||
|
||||
let decoded = Format.decode(serialized, type(origValue))
|
||||
checkpoint "(decoded value): " & repr(decoded)
|
||||
let success = maybeDefer(decoded) == maybeDefer(origValue)
|
||||
|
|
Loading…
Reference in New Issue