Exemplo n.º 1
0
    def test_same(self):
        """Test whether the SAME computation is correct."""
        def assertIsNotNone(x):
            self.assertTrue(x is not None)

        def assertIsNone(x):
            self.assertTrue(x is None)

        assertIsNotNone(unify.same(str2form('p(x)'), str2form('p(y)')))
        assertIsNotNone(unify.same(str2form('p(x)'), str2form('p(x)')))
        assertIsNotNone(unify.same(str2form('p(x,y)'), str2form('p(x,y)')))
        assertIsNotNone(unify.same(str2form('p(x,y)'), str2form('p(y,x)')))
        assertIsNone(unify.same(str2form('p(x,x)'), str2form('p(x,y)')))
        assertIsNone(unify.same(str2form('p(x,y)'), str2form('p(x,x)')))
        assertIsNotNone(unify.same(str2form('p(x,x)'), str2form('p(y,y)')))
        assertIsNotNone(unify.same(str2form('p(x,y,x)'), str2form('p(y,x,y)')))
        assertIsNone(unify.same(str2form('p(x,y,z)'), str2form('p(x,y,1)')))
Exemplo n.º 2
0
def datalog_same(actual_code, correct_code, msg=None):
    return datalog_equal(
        actual_code, correct_code, msg=msg,
        equal=lambda x, y: unify.same(x, y) is not None)
Exemplo n.º 3
0
 def check_same(self, actual_code, correct_code, msg=None):
     """Checks if ACTUAL_CODE is a variable-renaming of CORRECT_CODE."""
     return self.check_equal(
         actual_code, correct_code, msg=msg,
         equal=lambda x, y: unify.same(x, y) is not None)