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.nim50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/vm/tcompiletimetable.nim b/tests/vm/tcompiletimetable.nim
new file mode 100644
index 000000000..f1d3ecd4e
--- /dev/null
+++ b/tests/vm/tcompiletimetable.nim
@@ -0,0 +1,50 @@
+discard """
+  msg: '''2
+3
+4:2
+  '''
+"""
+
+# bug #404
+
+import macros, tables
+
+var ZOOT{.compileTime.} = initTable[int, int](2)
+var iii {.compiletime.} = 1
+
+macro zoo:stmt=
+  zoot[iii] = iii*2
+  inc iii
+  echo iii
+
+zoo
+zoo
+
+
+macro tupleUnpack: stmt =
+  var (y,z) = (4, 2)
+  echo y, ":", z
+
+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()
+