summary refs log tree commit diff stats
path: root/tests/macros
diff options
context:
space:
mode:
authorArne Döring <arne.doering@gmx.net>2018-04-17 01:23:38 +0200
committerAndreas Rumpf <rumpf_a@web.de>2018-04-17 01:23:38 +0200
commit9d4fd1f1bbc0d8a2327699dd07283260d85a5245 (patch)
tree98059bd476176b36182213999d4c30b13d4476df /tests/macros
parentb1b517128e9ab4d1c1e8e16543008cbdecef0468 (diff)
downloadNim-9d4fd1f1bbc0d8a2327699dd07283260d85a5245.tar.gz
eqIdent new returns false on non identifier types (#7629)
Diffstat (limited to 'tests/macros')
-rw-r--r--tests/macros/tmacro1.nim17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/macros/tmacro1.nim b/tests/macros/tmacro1.nim
index 0b83345a1..ac2bf9094 100644
--- a/tests/macros/tmacro1.nim
+++ b/tests/macros/tmacro1.nim
@@ -27,11 +27,19 @@ import strutils
 template assertNot(arg: untyped): untyped =
   assert(not(arg))
 
+
+proc foo(arg: int): void =
+  discard
+
+proc foo(arg: float): void =
+  discard
+
 static:
   ## test eqIdent
   let a = "abc_def"
   let b = "abcDef"
   let c = "AbcDef"
+  let d = nnkBracketExpr.newTree() # not an identifier at all
 
   assert eqIdent(             a ,              b )
   assert eqIdent(newIdentNode(a),              b )
@@ -62,3 +70,12 @@ static:
   assertNot eqIdent(genSym(nskLet, c), newIdentNode(  b))
   assertNot eqIdent(newIdentNode(  c), genSym(nskLet, b))
   assertNot eqIdent(genSym(nskLet, c), genSym(nskLet, b))
+
+  # eqIdent on non identifier at all
+  assertNot eqIdent(a,d)
+
+  # eqIdent on sym choice
+  let fooSym = bindSym"foo"
+  assert fooSym.kind in {nnkOpenSymChoice, nnkClosedSymChoice}
+  assert    fooSym.eqIdent("fOO")
+  assertNot fooSym.eqIdent("bar")