From d15788d00a4007a80de4427f84129abe47fa4f11 Mon Sep 17 00:00:00 2001 From: Araq Date: Wed, 26 Mar 2014 01:00:34 +0100 Subject: added #903 to the test suite --- tests/vm/tcompiletimetable.nim | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/vm/tcompiletimetable.nim b/tests/vm/tcompiletimetable.nim index 3b40add07..f1d3ecd4e 100644 --- a/tests/vm/tcompiletimetable.nim +++ b/tests/vm/tcompiletimetable.nim @@ -12,13 +12,13 @@ import macros, tables var ZOOT{.compileTime.} = initTable[int, int](2) var iii {.compiletime.} = 1 -macro x:stmt= +macro zoo:stmt= zoot[iii] = iii*2 inc iii echo iii -x -x +zoo +zoo macro tupleUnpack: stmt = @@ -27,3 +27,24 @@ macro tupleUnpack: stmt = tupleUnpack +# bug #903 + +import strtabs + +var x {.compileTime.}: PStringTable + +macro addStuff(stuff, body: expr): stmt {.immediate.} = + result = newNimNode(nnkStmtList) + + if x.isNil: + x = newStringTable(modeStyleInsensitive) + x[$stuff] = "" + +macro dump(): stmt = + result = newNimNode(nnkStmtList) + for y in x.keys: echo "Got ", y + +addStuff("Hey"): echo "Hey" +addStuff("Hi"): echo "Hi" +dump() + -- cgit 1.4.1-2-gfad0