summary refs log tree commit diff stats
path: root/tests/macros/texpectIdent1.nim
diff options
context:
space:
mode:
authorArne Döring <arne.doering@gmx.net>2020-03-11 08:27:31 +0100
committerGitHub <noreply@github.com>2020-03-11 08:27:31 +0100
commitf95eef99a97dc813cf2f819a6bbaa3b3ead67267 (patch)
tree6ae6783b2c82374025f34c1ccba680fad5b931a6 /tests/macros/texpectIdent1.nim
parent8e3a349561fb0af7f5bc77a4d436abb3ced75d9e (diff)
downloadNim-f95eef99a97dc813cf2f819a6bbaa3b3ead67267.tar.gz
add expectIdent to macros (#12778)
* add expectIdent to macros

* apply feedback

* Update lib/core/macros.nim

Co-Authored-By: Clyybber <darkmine956@gmail.com>

* Update texpectIdent2.nim

* Update texpectIdent1.nim

Co-authored-by: Clyybber <darkmine956@gmail.com>
Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Diffstat (limited to 'tests/macros/texpectIdent1.nim')
-rw-r--r--tests/macros/texpectIdent1.nim18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/macros/texpectIdent1.nim b/tests/macros/texpectIdent1.nim
new file mode 100644
index 000000000..26e52afb5
--- /dev/null
+++ b/tests/macros/texpectIdent1.nim
@@ -0,0 +1,18 @@
+discard """
+errormsg: "Expected identifier to be `foo` here"
+line: 18
+"""
+
+import macros
+
+macro testUntyped(arg: untyped): void =
+  arg.expectKind nnkStmtList
+  arg.expectLen 2
+  arg[0].expectKind nnkCall
+  arg[0][0].expectIdent "foo"  # must pass
+  arg[1].expectKind nnkCall
+  arg[1][0].expectIdent "foo"  # must fail
+
+testUntyped:
+  foo(123)
+  bar(321)