summary refs log tree commit diff stats
path: root/tests/macros/tprochelpers.nim
diff options
context:
space:
mode:
authorTanguy <tanguy@status.im>2022-02-25 12:57:58 +0100
committerGitHub <noreply@github.com>2022-02-25 12:57:58 +0100
commitef3f343ec2979d22a5d4e51f4328e4a4c21d68dc (patch)
tree079ebdb1a1dd6ce5ea4d0a64995d41bbf50621f6 /tests/macros/tprochelpers.nim
parentfe791c67b4c028d2e439e6f74e0a4225ba6cc2f1 (diff)
downloadNim-ef3f343ec2979d22a5d4e51f4328e4a4c21d68dc.tar.gz
Allow std/macros.params to work with nnkProcTy (#19563)
* Allow std/macros.params to work with nnkProcTy

* Add tests for proc params & pragma
Diffstat (limited to 'tests/macros/tprochelpers.nim')
-rw-r--r--tests/macros/tprochelpers.nim22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/macros/tprochelpers.nim b/tests/macros/tprochelpers.nim
new file mode 100644
index 000000000..d95a2ced8
--- /dev/null
+++ b/tests/macros/tprochelpers.nim
@@ -0,0 +1,22 @@
+import std/macros
+import stdtest/testutils
+
+macro test1(prc: untyped): untyped =
+  assertAll:
+    prc.params.len == 2
+    prc.params[1].len == 4
+    prc.pragma.len == 2
+
+  prc.params = nnkFormalParams.newTree(
+    ident("int")
+  )
+  prc.pragma = newEmptyNode()
+
+  assertAll:
+    prc.params.len == 1
+    prc.pragma.len == 0
+  prc
+
+proc test(a, b: int): int {.gcsafe, raises: [], test1.} = 5
+
+type hello = proc(a, b: int): int {.gcsafe, raises: [], test1.}