Commits

Pierre Carbonnelle committed f14744e

fix issue with in-line equality

Comments (0)

Files changed (2)

pyDatalog/examples/test.py

     
     """ In-line queries using create_atoms                    """
     
-    pyDatalog.create_atoms('p', 'Y')
+    pyDatalog.create_atoms('p', 'Y, eq, Z')
     +p('a')
     
     p(Y)
         assert (X._value() == ['a',])
         assert (p2(X) == [('a',)])
     test2()
+
+    eq(X,Y) <= (X==Z) & (Z==Y)
+    
+    assert (eq(3, Z)) == [(3,)]
+    assert(eq(X, 3)) == [] # because X==Z is undefined
+    assert(eq(2, 3)) == []
+    assert(eq(3, 3)) == [()]
     
     print("Test completed successfully.")
 

pyDatalog/pyParser.py

         return Body() # by default, there is no precalculation needed to evaluate an expression
     
     def __eq__(self, other):
-        if self._pyD_type == 'variable' and not isinstance(other, Symbol):
+        if self._pyD_type == 'variable' and not isinstance(other, VarSymbol):
             return Literal.make_for_comparison(self, '==', other)
         else:
             return Literal.make("=", (self, other))