diff options
author | Araq <rumpf_a@web.de> | 2014-12-17 23:21:15 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2014-12-17 23:21:15 +0100 |
commit | bd88e526cf115eff00a27976c14ad868a974a548 (patch) | |
tree | 2e90dd390ad8eee298630fa304721e6c66f5bf66 /tests | |
parent | 73dda8a81de81d94adda004e1c346fcc7b040cb2 (diff) | |
download | Nim-bd88e526cf115eff00a27976c14ad868a974a548.tar.gz |
fixes #1744
Diffstat (limited to 'tests')
-rw-r--r-- | tests/vm/tstringnil.nim | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/vm/tstringnil.nim b/tests/vm/tstringnil.nim new file mode 100644 index 000000000..5070dd6b7 --- /dev/null +++ b/tests/vm/tstringnil.nim @@ -0,0 +1,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 |