summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAdam Strzelecki <ono@java.pl>2015-06-10 00:17:48 +0200
committerAdam Strzelecki <ono@java.pl>2015-06-10 18:07:21 +0200
commitb49c75c82a5588ea6a3f14c9cb966ad87d99637e (patch)
tree727731da81b3a20050a2d5d9b4f9efc80ddfd3e2
parent6ecce2941e3c05822dffb8ea80715225f9053855 (diff)
downloadNim-b49c75c82a5588ea6a3f14c9cb966ad87d99637e.tar.gz
macros: Add test for node comparsion
-rw-r--r--tests/macros/tnodecompare.nim39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/macros/tnodecompare.nim b/tests/macros/tnodecompare.nim
new file mode 100644
index 000000000..ef25ae370
--- /dev/null
+++ b/tests/macros/tnodecompare.nim
@@ -0,0 +1,39 @@
+discard """
+output: '''1
+0
+1
+0
+1
+0
+1
+0'''
+"""
+
+import macros
+
+macro test(a: typed, b: typed): expr =
+  newLit(a == b)
+
+echo test(1, 1)
+echo test(1, 2)
+
+type
+  Obj = object of RootObj
+  Other = object of RootObj
+
+echo test(Obj, Obj)
+echo test(Obj, Other)
+
+var a, b: int
+
+echo test(a, a)
+echo test(a, b)
+
+macro test2: expr =
+  newLit(bindSym"Obj" == bindSym"Obj")
+
+macro test3: expr =
+  newLit(bindSym"Obj" == bindSym"Other")
+
+echo test2()
+echo test3()