def test10(self): x = LogicVar('x') x1 = Const('x') y1 = Const('y') eq_(eval(begin(assign(x1, L(L(1, x))), assign(y1, L(L(1, x))), unify(x1, y1))), True)
def test10(self): x = LogicVar('x') x1 = Const('x') y1 = Const('y') eq_( eval( begin(assign(x1, L(L(1, x))), assign(y1, L(L(1, x))), unify(x1, y1))), True)
def test_unify2(self): x = LogicVar('x') result = compile_optimize(unify(x, 2)) x1 = il.LogicVar('x') x2 = il.ConstLocalVar('x') expect = il.begin(il.Assign(x2, il.Deref(LogicVar(x1))), il.If(il.IsLogicVar(x2), il.begin(il.SetBinding(x2, il.Integer(2)), il.TRUE), il.If(il.Eq(x2, il.Integer(2)), il.TRUE, il.failcont(il.TRUE)))) eq_(result, expect)
def test2(self): x = Var('x') Lx = LogicVar('x') eq_(eval(unify(1, 1)), True) eq_(eval(begin(unify(1, 1), unify(2, 2))), True) eq_(eval(begin(unify(Lx, 1), unify(Lx, 1))), True) eq_(eval(let([(x, 1)], unify(x, 1))), True)
def test2(self): x = Var('x') Lx = LogicVar('x') eq_(eval(unify(1, 1)), True) eq_(eval(begin(unify(1, 1), unify(2, 2))), True) eq_(eval(begin(unify(Lx, 1), unify(Lx,1))), True) eq_(eval(let([(x,1)], unify(x,1))), True)
def test_unify2(self): x = LogicVar('x') result = compile_optimize(unify(x, 2)) x1 = il.LogicVar('x') x2 = il.ConstLocalVar('x') expect = il.begin( il.Assign(x2, il.Deref(LogicVar(x1))), il.If( il.IsLogicVar(x2), il.begin(il.SetBinding(x2, il.Integer(2)), il.TRUE), il.If(il.Eq(x2, il.Integer(2)), il.TRUE, il.failcont(il.TRUE)))) eq_(result, expect)
def test_getvalue(self): x = LogicVar('x') x1 = DaoLogicVar('x') eq_(eval(getvalue(x)), x1) eq_(eval(begin(unify(x, 1), getvalue(x))), 1)
def test1(self): x = LogicVar('x') eq_(eval(unify(x, 1)), True)
def test_unify(self): eq_(compile_optimize(unify(1, 2)), il.failcont(True)) eq_(compile_optimize(unify(1, 1)), True)
def test_unify3(self): x = il.Var('x') result = cps(unify(x, 2)) expect = 1 eq_(result, expect)
def test_unify2(self): x = LogicVar('x') result = cps(unify(x, 2)) expect = 1 eq_(result, expect)
def test_unify(self): eq_(compile(unify(1, 2)), 'solver.fail_cont(True)') eq_(compile(unify(1, 1)), 'True')
def test_unify(self): eq_(cps(unify(1, 2)), il.failcont(True)) eq_(cps(unify(1, 1)), done()(True))
def test8(self): x = LogicVar('x') eq_(eval(unify(L(L(1, x)), L(L(1, x)))), True)
def test_unify2(self): x = il.LogicVar('x') result = compile(unify(x, 2)) expect = 'solver.fail_cont(True)' eq_(result, expect)
def test6(self): eq_(eval(unify(L(1), L(1))), True)
def test7(self): x = LogicVar('x') eq_(eval(unify(L(x), L(1))), True)
def test5(self): x = Var('x') Lx = LogicVar('x') assert_raises(NoSolution, eval, begin(unify(Lx, 1), unify(Lx, 2)))
def test4(self): x = Var('x') Lx = LogicVar('x') eq_(eval(begin(unify(Lx, 1), unify(Lx, 1))), True)
def test3(self): assert_raises(NoSolution, eval, begin(unify(1, 1), unify(1, 2))) assert_raises(NoSolution, eval, begin(unify(2, 1), unify(1, 1))) assert_raises(NoSolution, eval, unify(1, 2))
def test_cut_or3(self): x = LogicVar('x') assert_raises(NoSolution, eval, or_(begin(unify(x, 1), cut_or, unify(x, 2)), unify(x, 2)))
def testcall(self): eq_(eval(call(unify(x, 1))), True) eq_(eval(is_(x, quote(prin(1))) & call(x)), None)
def test_repeat(self): #return # the code below loops for ever, after modifie the behaviour of solver.parse_state and terminals. x = LogicVar('x') eq_(eval(and_(set_text('123'), repeat, char(x), unify(x, '3'))), True)
def test_or_2(self): eq_(eval(or_(unify(1, 1), unify(1, 2))), True)
def test5(self): x = Var('x') Lx = LogicVar('x') assert_raises(NoSolution, eval, begin(unify(Lx, 1), unify(Lx,2)))
def test_getvalue_default(self): x = LogicVar('x') eq_(eval(getvalue_default(x)), None) eq_(eval(getvalue_default(x, 1)), 1) eq_(eval(begin(unify(x, 2), getvalue(x))), 2)
def test4(self): x = Var('x') Lx = LogicVar('x') eq_(eval(begin(unify(Lx, 1), unify(Lx,1))), True)
def test_cut_or3(self): x = LogicVar('x') assert_raises( NoSolution, eval, or_(begin(unify(x, 1), cut_or, unify(x, 2)), unify(x, 2)))
def test_cut_or4(self): x = LogicVar('x') eq_( eval( or_(or_(begin(unify(x, 1), cut_or, unify(x, 2)), unify(x, 2)), unify(x, 2))), True)
def testcall(self): eq_(eval(call(unify(x, 1))), True) eq_(eval(is_(x, quote(prin(1)))&call(x)), None)
def test_repeat2(self): #return # the code below loops for ever. x = LogicVar('x') eq_(eval(and_(set_text('123'), repeat, char(x), unify(x, '4'))), True)
def test_cut_or4(self): x = LogicVar('x') eq_(eval(or_(or_(begin(unify(x, 1), cut_or, unify(x, 2)), unify(x, 2)), unify(x, 2))), True)
def test_or_2(self): eq_(eval(or_(unify(1,1), unify(1,2))), True)