summary refs log tree commit diff stats
path: root/tests/macros/tdebugstmt.nim
diff options
context:
space:
mode:
authorMiran <narimiran@users.noreply.github.com>2018-10-14 17:08:42 +0200
committerAndreas Rumpf <rumpf_a@web.de>2018-10-14 17:08:42 +0200
commita30ba8cc370736b8b737292a8c2b46adadc6f8be (patch)
treeccded85b9aec0f61daa8f39b8d8cc8e344e9388d /tests/macros/tdebugstmt.nim
parent8955470644972e2d1f2b029650c04505ebacca23 (diff)
downloadNim-a30ba8cc370736b8b737292a8c2b46adadc6f8be.tar.gz
merge macros tests (#9367)
Diffstat (limited to 'tests/macros/tdebugstmt.nim')
-rw-r--r--tests/macros/tdebugstmt.nim29
1 files changed, 0 insertions, 29 deletions
diff --git a/tests/macros/tdebugstmt.nim b/tests/macros/tdebugstmt.nim
deleted file mode 100644
index 69e610075..000000000
--- a/tests/macros/tdebugstmt.nim
+++ /dev/null
@@ -1,29 +0,0 @@
-discard """
-  output: '''a[0]: 42
-a[1]: 45
-x: some string'''
-"""
-
-import macros
-
-macro debug(n: varargs[untyped]): untyped =
-  # `n` is a Nim AST that contains the whole macro invocation
-  # this macro returns a list of statements:
-  result = newNimNode(nnkStmtList, n)
-  # iterate over any argument that is passed to this macro:
-  for i in 0..n.len-1:
-    # add a call to the statement list that writes the expression;
-    # `toStrLit` converts an AST to its string representation:
-    add(result, newCall("write", newIdentNode("stdout"), toStrLit(n[i])))
-    # add a call to the statement list that writes ": "
-    add(result, newCall("write", newIdentNode("stdout"), newStrLitNode(": ")))
-    # add a call to the statement list that writes the expressions value:
-    add(result, newCall("writeLine", newIdentNode("stdout"), n[i]))
-
-var
-  a: array[0..10, int]
-  x = "some string"
-a[0] = 42
-a[1] = 45
-
-debug(a[0], a[1], x)