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
|
raise (ref Defect)() # a memoryOutput cannot have an IOError
|
||||||
|
|
||||||
# TODO Nim cannot make sense of this initialization by var param?
|
# 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.}
|
{.warning[ProveInit]: off.}
|
||||||
mixin readValue
|
mixin readValue
|
||||||
result = default(T)
|
result = default(T)
|
||||||
|
|
|
@ -377,7 +377,7 @@ proc genCustomSerializationForField(Format, field,
|
||||||
type ReaderType = Reader(`Format`)
|
type ReaderType = Reader(`Format`)
|
||||||
proc readFieldIMPL*(F: type FieldTag[`RecordType`, `fieldName`],
|
proc readFieldIMPL*(F: type FieldTag[`RecordType`, `fieldName`],
|
||||||
`readerSym`: var ReaderType): `FieldType`
|
`readerSym`: var ReaderType): `FieldType`
|
||||||
{.raises: [IOError, SerializationError, Defect], gcsafe.} =
|
{.raises: [IOError, SerializationError], gcsafe.} =
|
||||||
`readBody`
|
`readBody`
|
||||||
|
|
||||||
if writeBody != nil:
|
if writeBody != nil:
|
||||||
|
@ -387,7 +387,7 @@ proc genCustomSerializationForField(Format, field,
|
||||||
F: type FieldTag[`RecordType`, `fieldName`],
|
F: type FieldTag[`RecordType`, `fieldName`],
|
||||||
`valueSym`: auto,
|
`valueSym`: auto,
|
||||||
`holderSym`: `RecordType`)
|
`holderSym`: `RecordType`)
|
||||||
{.raises: [IOError, Defect], gcsafe.} =
|
{.raises: [IOError], gcsafe.} =
|
||||||
`writeBody`
|
`writeBody`
|
||||||
|
|
||||||
proc genCustomSerializationForType(Format, typ: NimNode,
|
proc genCustomSerializationForType(Format, typ: NimNode,
|
||||||
|
@ -398,7 +398,7 @@ proc genCustomSerializationForType(Format, typ: NimNode,
|
||||||
result.add quote do:
|
result.add quote do:
|
||||||
type ReaderType = Reader(`Format`)
|
type ReaderType = Reader(`Format`)
|
||||||
proc readValue*(`readerSym`: var ReaderType, T: type `typ`): `typ`
|
proc readValue*(`readerSym`: var ReaderType, T: type `typ`): `typ`
|
||||||
{.raises: [IOError, SerializationError, Defect], gcsafe.} =
|
{.raises: [IOError, SerializationError], gcsafe.} =
|
||||||
`readBody`
|
`readBody`
|
||||||
|
|
||||||
if writeBody != nil:
|
if writeBody != nil:
|
||||||
|
|
|
@ -136,6 +136,14 @@ func caseObjectEquals(a, b: CaseObject): bool =
|
||||||
func `==`*(a, b: CaseObject): bool =
|
func `==`*(a, b: CaseObject): bool =
|
||||||
caseObjectEquals(a, b)
|
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 =
|
template maybeDefer(x: auto): auto =
|
||||||
when type(x) is ref:
|
when type(x) is ref:
|
||||||
x[]
|
x[]
|
||||||
|
@ -151,6 +159,9 @@ template roundtripChecks*(Format: type, value: auto, expectedResult: auto) =
|
||||||
check serialized == expectedResult
|
check serialized == expectedResult
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
const typeName = typetraits.name(type(origValue))
|
||||||
|
{.warning: "WWW: " & typeName.}
|
||||||
|
|
||||||
let decoded = Format.decode(serialized, type(origValue))
|
let decoded = Format.decode(serialized, type(origValue))
|
||||||
checkpoint "(decoded value): " & repr(decoded)
|
checkpoint "(decoded value): " & repr(decoded)
|
||||||
let success = maybeDefer(decoded) == maybeDefer(origValue)
|
let success = maybeDefer(decoded) == maybeDefer(origValue)
|
||||||
|
|
Loading…
Reference in New Issue