def test_structural_unequal(self): """ Check if unequal is detected """ t1 = Tree('MOV', Tree('ADD', Tree('reg'), Tree('reg')), Tree('reg')) t2 = Tree('MOV2', Tree('ADD', Tree('reg'), Tree('reg')), Tree('reg')) t3 = Tree('MOV', Tree('ADD', Tree('reg'), Tree('reg'))) self.assertFalse(t1.structural_equal(t2)) self.assertFalse(t1.structural_equal(t3))
def test_structural_equal(self): """ Check for equalness of trees """ t1 = Tree('MOV', Tree('ADD', Tree('reg'), Tree('reg')), Tree('reg')) t2 = Tree('MOV', Tree('ADD', Tree('reg'), Tree('reg')), Tree('reg')) self.assertTrue(t1.structural_equal(t2)) self.assertTrue(t2.structural_equal(t1))