Add roundtrip tests using inheritance

This commit is contained in:
Zahary Karadjov 2020-05-26 19:38:03 +03:00
parent 8a25451fce
commit 2baaccd50e
No known key found for this signature in database
GPG Key ID: C8936F8A3073D609
1 changed files with 16 additions and 4 deletions

View File

@ -19,11 +19,19 @@ type
sender*: string
receiver*: string
DerivedFromRoot* = object of RootObj
BaseType* = object of RootObj
a*: string
b*: int
DerivedFromRootRef = ref DerivedFromRoot
BaseTypeRef* = ref BaseType
DerivedType* = object of BaseType
c*: int
d*: string
DerivedRefType* = ref object of BaseType
c*: int
d*: string
RefTypeDerivedFromRoot* = ref object of RootObj
a*: int
@ -235,13 +243,17 @@ proc executeRoundtripTests*(Format: type) =
block:
let
a = DerivedFromRoot(a: "test", b: -1000)
b = DerivedFromRootRef(a: "another test", b: 2000)
a = BaseType(a: "test", b: -1000)
b = BaseTypeRef(a: "another test", b: 2000)
c = RefTypeDerivedFromRoot(a: high(int), b: "")
d = DerivedType(a: "a field", b: 1000, c: 10, d: "d field")
e = DerivedRefType(a: "a field", b: -1000, c: 10, d: "")
roundtrip a
roundtrip b
roundtrip c
roundtrip d
roundtrip e
test "case objects":
var