def test_kleene1(self): f, item, kleene = Var('f'), Var('item'), Var('kleene') fun = macro(((item,), letr([(f,macro(((), eval_(item), f()), ((), nullword)))], f()))) eq_(eval(let([(kleene,fun)], set_text('aa'), kleene(char('a')))), True)
def test_kleene2(self): f, pred, kleene = Var('f'), Var('pred'), Var('kleene') fun = macro(((pred,), letr([(f,macro( ((x,), pred(x), f(x)), ((x,), nullword)))], f(x)))) eq_(eval(let([(kleene,fun)], set_text('ab'), kleene(char))), True)
def test_kleene1(self): f, item, kleene = Var('f'), Var('item'), Var('kleene') fun = macro(((item, ), letr([(f, macro(((), eval_(item), f()), ((), nullword)))], f()))) eq_(eval(let([(kleene, fun)], set_text('aa'), kleene(char('a')))), True)
def test_kleene2(self): f, pred, kleene = Var('f'), Var('pred'), Var('kleene') fun = macro(((pred, ), letr([(f, macro(((x, ), pred(x), f(x)), ((x, ), nullword)))], f(x)))) eq_(eval(let([(kleene, fun)], set_text('ab'), kleene(char))), True)
def test_closure4(self): eq_(eval(let([(f, macro([[x], x])), (x, 1)], f(x+x))), 2)
def test4(self): eq_(eval(macro([[x], x])(prin(1))), None)
def test_closure2(self): eq_(eval(let([(f, macro([[x], prin(x)])), (x, 1)], f(x+x))), None)
def test_or_p(self): eq_(eval(macro([[x, y], x], [[x, y],y])(prin(1), prin(2))), None)
def test_eval(self): eq_(eval(macro([[x, y], eval_(x)], [[x, y],eval_(y)])(prin(1), prin(2))), None)
def test1(self): eq_(eval(macro([[], prin(1)])()), None)
def testembedvar2(self): e, e2, f, g, h = Var('e'), Var('e2'), Var('f'), Var('g'), Var('h') eq_(eval(letr([(f, macro([[cons(1, e2)], g(e2)])), (g, function([[e], h(e)])), (h, function([[1], True]))], f(e), e)), cons(1, 1))