summary refs log tree commit diff stats
path: root/tests/macros
diff options
context:
space:
mode:
authorArne Döring <arne.doering@gmx.net>2019-05-20 12:18:54 +0200
committerAndreas Rumpf <rumpf_a@web.de>2019-05-20 12:18:53 +0200
commitaeb6ec27dec21509eebf5aa1a78b82b184117450 (patch)
tree85928095be950b61eab50711a056ef6beec97bb3 /tests/macros
parent433ce7bea2350d62b88335d4f1cca01214172383 (diff)
downloadNim-aeb6ec27dec21509eebf5aa1a78b82b184117450.tar.gz
fix for return in macro (#9666); fixes #5874
Diffstat (limited to 'tests/macros')
-rw-r--r--tests/macros/tmacrogenerics.nim8
-rw-r--r--tests/macros/tmacros1.nim24
-rw-r--r--tests/macros/tmacros_various.nim2
3 files changed, 28 insertions, 6 deletions
diff --git a/tests/macros/tmacrogenerics.nim b/tests/macros/tmacrogenerics.nim
index bb562cacb..c31b5564c 100644
--- a/tests/macros/tmacrogenerics.nim
+++ b/tests/macros/tmacrogenerics.nim
@@ -1,8 +1,8 @@
 discard """
   nimout: '''
-instantiation 1 with None and None
-instantiation 2 with None and None
-instantiation 3 with None and None
+instantiation 1 with typeDesc[int] and typeDesc[float]
+instantiation 2 with typeDesc[float] and typeDesc[string]
+instantiation 3 with typeDesc[string] and typeDesc[string]
 counter: 3
 '''
   output: "int\nfloat\nint\nstring"
@@ -14,7 +14,7 @@ var counter {.compileTime.} = 0
 
 macro makeBar(A, B: typedesc): typedesc =
   inc counter
-  echo "instantiation ", counter, " with ", A.name, " and ", B.name
+  echo "instantiation ", counter, " with ", A.getTypeInst.repr, " and ", B.getTypeInst.repr
   result = A
 
 type
diff --git a/tests/macros/tmacros1.nim b/tests/macros/tmacros1.nim
index 80afb6641..a50465e1c 100644
--- a/tests/macros/tmacros1.nim
+++ b/tests/macros/tmacros1.nim
@@ -1,5 +1,8 @@
 discard """
-  output: "Got: 'nnkCall' hi"
+  output: '''Got: 'nnkCall' hi
+{a}
+{b}
+{a, b}'''
 """
 
 import
@@ -27,3 +30,22 @@ var str: string
 outterMacro(str):
   "hellow"
 echo str
+
+type E = enum a b
+macro enumerators1(): set[E] = newLit({a})
+
+macro enumerators2(): set[E] =
+  return newLit({b})
+
+macro enumerators3(): set[E] =
+  result = newLit({E.low .. E.high})
+
+var myEnums: set[E]
+
+
+myEnums = enumerators1()
+echo myEnums
+myEnums = enumerators2()
+echo myEnums
+myEnums = enumerators3()
+echo myEnums
diff --git a/tests/macros/tmacros_various.nim b/tests/macros/tmacros_various.nim
index 9eece00bd..b722298dc 100644
--- a/tests/macros/tmacros_various.nim
+++ b/tests/macros/tmacros_various.nim
@@ -47,7 +47,7 @@ block tgenericparams:
     let expr0 = "proc foo[T, N: static[int]]()"
     let expr1 = "proc foo[T; N: static[int]]()"
 
-    $toStrLit(parseExpr(expr0)) & "\n" & $toStrLit(parseExpr(expr1))
+    newLit($toStrLit(parseExpr(expr0)) & "\n" & $toStrLit(parseExpr(expr1)))
 
   echo test()