def matchOK(self, pat, exp, expected): subst = matchAgainst(pExp(pat), pExp(exp)) if subst: subst_l = list(subst.iteritems()) subst_l.sort() subst = "".join(["%s->%s;" % (vname, e) for (vname, e) in subst_l]) self.assertEqual(expected, subst)
def loopBack(self, beta, alpha): subst = matchAgainst(alpha.exp, beta.exp) bindings = list(subst.items()) bindings.sort() letExp = Let(alpha.exp, bindings) self.tree.replaceSubtree(beta, letExp)
def matchNone(self, pat, exp): subst = matchAgainst(pExp(pat), pExp(exp)) self.assertEqual(None, subst)