blob: 5070dd6b705848f5e715063f42298f70263d62f6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# bug #1744
import macros
type
SuiteTest = object
suiteName: string
suiteDesc: string
testName: string
testDesc: string
testBlock: PNimrodNode
proc buildSuiteContents(suiteName, suiteDesc, suiteBloc: PNimrodNode): tuple[tests: seq[SuiteTest]] {.compileTime.} =
var
tests:seq[SuiteTest] = @[]
for child in suiteBloc.children():
case $child[0].ident:
of "test":
var testObj = SuiteTest()
if suiteName.kind == nnkNilLit:
testObj.suiteName = nil
else:
testObj.suiteName = $suiteName
if suiteDesc.kind == nnkNilLit:
testObj.suiteDesc = nil
else:
testObj.suiteDesc = suiteDesc.strVal
testObj.testName = $child[1] # should not ever be nil
if child[2].kind == nnkNilLit:
testObj.testDesc = nil
else:
testObj.testDesc = child[2].strVal
testObj.testBlock = child[3][6]
tests.add(testObj)
else:
discard
return (tests: tests)
macro suite(suiteName, suiteDesc: expr, suiteBloc: stmt): stmt {.immediate.} =
let contents = buildSuiteContents(suiteName, suiteDesc, suiteBloc)
# Test above
suite basics, "Description of such":
test(t5, nil):
assert false
|