summary refs log tree commit diff stats
path: root/tests/macros/tmacro4.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/macros/tmacro4.nim')
-rw-r--r--tests/macros/tmacro4.nim17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/macros/tmacro4.nim b/tests/macros/tmacro4.nim
new file mode 100644
index 000000000..cb0399894
--- /dev/null
+++ b/tests/macros/tmacro4.nim
@@ -0,0 +1,17 @@
+discard """
+  output: "after"
+"""
+
+import macros
+
+macro test_macro*(s: string, n: untyped): untyped =
+  result = newNimNode(nnkStmtList)
+  var ass : NimNode = newNimNode(nnkAsgn)
+  add(ass, newIdentNode("str"))
+  add(ass, newStrLitNode("after"))
+  add(result, ass)
+when true:
+  var str: string = "before"
+  test_macro(str):
+    var i : integer = 123
+  echo str