summary refs log tree commit diff stats
path: root/tests/macros/tmacro1.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/macros/tmacro1.nim')
-rw-r--r--tests/macros/tmacro1.nim44
1 files changed, 41 insertions, 3 deletions
diff --git a/tests/macros/tmacro1.nim b/tests/macros/tmacro1.nim
index ac2bf9094..18bbeb53d 100644
--- a/tests/macros/tmacro1.nim
+++ b/tests/macros/tmacro1.nim
@@ -1,7 +1,5 @@
 import  macros
 
-from uri import `/`
-
 macro test*(a: untyped): untyped =
   var nodes: tuple[a, b: int]
   nodes.a = 4
@@ -22,7 +20,6 @@ macro test*(a: untyped): untyped =
 test:
   "hi"
 
-import strutils
 
 template assertNot(arg: untyped): untyped =
   assert(not(arg))
@@ -79,3 +76,44 @@ static:
   assert fooSym.kind in {nnkOpenSymChoice, nnkClosedSymChoice}
   assert    fooSym.eqIdent("fOO")
   assertNot fooSym.eqIdent("bar")
+
+  # eqIdent on exported and backtick quoted identifiers
+  let procName = ident("proc")
+  let quoted = nnkAccQuoted.newTree(procName)
+  let exported = nnkPostfix.newTree(ident"*", procName)
+  let exportedQuoted = nnkPostfix.newTree(ident"*", quoted)
+
+  let nodes = @[procName, quoted, exported, exportedQuoted]
+
+  for i in 0 ..< nodes.len:
+    for j in 0 ..< nodes.len:
+      doAssert eqIdent(nodes[i], nodes[j])
+
+  for node in nodes:
+    doAssert eqIdent(node, "proc")
+
+
+  var empty: NimNode
+  var myLit = newLit("str")
+
+  assert( (empty or myLit) == myLit )
+
+  empty = newEmptyNode()
+
+  assert( (empty or myLit) == myLit )
+
+  proc bottom(): NimNode =
+    quit("may not be evaluated")
+
+  assert( (myLit or bottom()) == myLit )
+
+type
+  Fruit = enum
+    apple
+    banana
+    orange
+
+macro foo(x: typed) =
+  doAssert Fruit(x.intVal) == banana
+
+foo(banana)