summary refs log tree commit diff stats
path: root/tests/vm/tcompiletimetable.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/vm/tcompiletimetable.nim')
-rw-r--r--tests/vm/tcompiletimetable.nim25
1 files changed, 19 insertions, 6 deletions
diff --git a/tests/vm/tcompiletimetable.nim b/tests/vm/tcompiletimetable.nim
index df6ead56f..1db490f1a 100644
--- a/tests/vm/tcompiletimetable.nim
+++ b/tests/vm/tcompiletimetable.nim
@@ -1,9 +1,16 @@
 discard """
-  msg: '''2
+  nimout: '''
+2
 3
 4:2
 Got Hi
-Got Hey'''
+Got Hey
+'''
+  output:'''
+a
+b
+c
+'''
 """
 
 # bug #404
@@ -13,7 +20,7 @@ import macros, tables, strtabs
 var ZOOT{.compileTime.} = initTable[int, int](2)
 var iii {.compiletime.} = 1
 
-macro zoo:stmt=
+macro zoo: untyped =
   ZOOT[iii] = iii*2
   inc iii
   echo iii
@@ -22,7 +29,7 @@ zoo
 zoo
 
 
-macro tupleUnpack: stmt =
+macro tupleUnpack: untyped =
   var (y,z) = (4, 2)
   echo y, ":", z
 
@@ -32,14 +39,14 @@ tupleUnpack
 
 var x {.compileTime.}: StringTableRef
 
-macro addStuff(stuff, body: expr): stmt {.immediate.} =
+macro addStuff(stuff, body: untyped): untyped =
   result = newNimNode(nnkStmtList)
 
   if x.isNil:
     x = newStringTable(modeStyleInsensitive)
   x[$stuff] = ""
 
-macro dump(): stmt =
+macro dump(): untyped =
   result = newNimNode(nnkStmtList)
   for y in x.keys: echo "Got ", y
 
@@ -47,3 +54,9 @@ addStuff("Hey"): echo "Hey"
 addStuff("Hi"): echo "Hi"
 dump()
 
+# ensure .compileTime vars can be used at runtime:
+import macros
+
+var xzzzz {.compileTime.}: array[3, string] = ["a", "b", "c"]
+
+for i in 0..high(xzzzz): echo xzzzz[i]