summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorhlaaftana <10591326+hlaaftana@users.noreply.github.com>2021-11-24 18:34:42 +0300
committerGitHub <noreply@github.com>2021-11-24 16:34:42 +0100
commitf91867aa31f3ae2c4f28d24547d62603daaa6d0c (patch)
treebd1b3a86fadcb4094c686ff452254df7ce4a43a8 /tests
parenta59ad2006291eafcd6790f3011b5cd355b219a5b (diff)
downloadNim-f91867aa31f3ae2c4f28d24547d62603daaa6d0c.tar.gz
accept object type node from macros (#19179)
Diffstat (limited to 'tests')
-rw-r--r--tests/macros/ttypenodes.nim16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/macros/ttypenodes.nim b/tests/macros/ttypenodes.nim
new file mode 100644
index 000000000..233ea9780
--- /dev/null
+++ b/tests/macros/ttypenodes.nim
@@ -0,0 +1,16 @@
+import macros
+
+macro makeEnum(): untyped =
+  newTree(nnkEnumTy, newEmptyNode(), ident"a", ident"b", ident"c")
+
+macro makeObject(): untyped =
+  newTree(nnkObjectTy, newEmptyNode(), newEmptyNode(), newTree(nnkRecList,
+    newTree(nnkIdentDefs, ident"x", ident"y", ident"int", newEmptyNode())))
+
+type
+  Foo = makeEnum()
+  Bar = makeObject()
+
+doAssert {a, b, c} is set[Foo]
+let bar = Bar(x: 3, y: 4)
+doAssert (bar.x, bar.y) == (3, 4)