Create initial subfield macro and tests
This commit is contained in:
parent
f2e46d61a7
commit
ec45c02f72
5 changed files with 231 additions and 0 deletions
2
tests/nim.cfg
Normal file
2
tests/nim.cfg
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
--path:"../"
|
||||
--path:"./"
|
||||
63
tests/test_subfield.nim
Normal file
63
tests/test_subfield.nim
Normal 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
|
||||
|
||||
4
tests/tests.nim
Normal file
4
tests/tests.nim
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
import einheit
|
||||
import test_subfield
|
||||
|
||||
runTests()
|
||||
Loading…
Add table
Add a link
Reference in a new issue