From f95eef99a97dc813cf2f819a6bbaa3b3ead67267 Mon Sep 17 00:00:00 2001 From: Arne Döring Date: Wed, 11 Mar 2020 08:27:31 +0100 Subject: add expectIdent to macros (#12778) * add expectIdent to macros * apply feedback * Update lib/core/macros.nim Co-Authored-By: Clyybber * Update texpectIdent2.nim * Update texpectIdent1.nim Co-authored-by: Clyybber Co-authored-by: Andreas Rumpf --- tests/macros/texpectIdent1.nim | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tests/macros/texpectIdent1.nim (limited to 'tests/macros/texpectIdent1.nim') 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) -- cgit 1.4.1-2-gfad0