Create initial subfield macro and tests

This commit is contained in:
Joey Payne 2016-06-21 10:02:17 -06:00
commit ec45c02f72
5 changed files with 231 additions and 0 deletions

63
tests/test_subfield.nim Normal file
View file

@ -0,0 +1,63 @@
import einheit
import subfield
testSuite SubFieldTests:
method testOneLevel() =
type
C = object
x: int
B = object
c: C
A = object
b: B
var c = C(x: 20)
var b = B(c: c)
var a = A(b: b)
self.check compiles(a.x)
self.check a.x == 20
method testTwoLevels() =
type
D = object
y: int
C = object
d: D
B = object
c: C
A = object
b: B
var d = D(y: 200)
var c = C(d: d)
var b = B(c: c)
var a = A(b: b)
self.check compiles(a.y)
self.check a.y == 200
method testBranch() =
type
D = object
y: int
C = object
x: int
B = object
c: C
d: D
A = object
b: B
var d = D(y: 200)
var c = C(x: 19)
var b = B(c: c, d: d)
var a = A(b: b)
self.check compiles(a.y)
self.check a.y == 200
self.check compiles(a.x)
self.check a.x == 19