示例#1
0
 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)
示例#2
0
 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)
示例#3
0
 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)
示例#4
0
 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)
示例#5
0
 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)
示例#6
0
 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)
示例#7
0
 def test_getvalue(self):
   x = LogicVar('x')
   x1 = DaoLogicVar('x')
   eq_(eval(getvalue(x)), x1)
   eq_(eval(begin(unify(x, 1), getvalue(x))), 1)
示例#8
0
 def test1(self):
   x = LogicVar('x')
   eq_(eval(unify(x, 1)), True)
示例#9
0
 def test_unify(self):
   eq_(compile_optimize(unify(1, 2)), il.failcont(True))    
   eq_(compile_optimize(unify(1, 1)), True) 
示例#10
0
 def test_unify3(self):
   x = il.Var('x')
   result = cps(unify(x, 2))
   expect = 1
   eq_(result, expect)
示例#11
0
 def test_unify2(self):
     x = LogicVar('x')
     result = cps(unify(x, 2))
     expect = 1
     eq_(result, expect)
示例#12
0
 def test_unify(self):
     eq_(compile(unify(1, 2)), 'solver.fail_cont(True)')
     eq_(compile(unify(1, 1)), 'True')
示例#13
0
 def test_unify(self):
   eq_(cps(unify(1, 2)), il.failcont(True))    
   eq_(cps(unify(1, 1)), done()(True))
示例#14
0
 def test8(self):
     x = LogicVar('x')
     eq_(eval(unify(L(L(1, x)), L(L(1, x)))), True)
示例#15
0
 def test_unify2(self):
   x = il.LogicVar('x')
   result = compile(unify(x, 2))
   expect = 'solver.fail_cont(True)'
   eq_(result, expect)
示例#16
0
 def test6(self):
     eq_(eval(unify(L(1), L(1))), True)
示例#17
0
 def test7(self):
     x = LogicVar('x')
     eq_(eval(unify(L(x), L(1))), True)
示例#18
0
 def test5(self):
     x = Var('x')
     Lx = LogicVar('x')
     assert_raises(NoSolution, eval, begin(unify(Lx, 1), unify(Lx, 2)))
示例#19
0
 def test4(self):
     x = Var('x')
     Lx = LogicVar('x')
     eq_(eval(begin(unify(Lx, 1), unify(Lx, 1))), True)
示例#20
0
 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))
示例#21
0
 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)))
示例#22
0
 def testcall(self):
     eq_(eval(call(unify(x, 1))), True)
     eq_(eval(is_(x, quote(prin(1))) & call(x)), None)
示例#23
0
 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)
示例#24
0
 def test_getvalue(self):
     x = LogicVar('x')
     x1 = DaoLogicVar('x')
     eq_(eval(getvalue(x)), x1)
     eq_(eval(begin(unify(x, 1), getvalue(x))), 1)
示例#25
0
 def test_or_2(self):
     eq_(eval(or_(unify(1, 1), unify(1, 2))), True)
示例#26
0
 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))
示例#27
0
 def test_unify2(self):
   x = LogicVar('x')
   result = cps(unify(x, 2))
   expect = 1
   eq_(result, expect)
示例#28
0
 def test5(self):
   x = Var('x')
   Lx = LogicVar('x')
   assert_raises(NoSolution, eval, begin(unify(Lx, 1), unify(Lx,2)))
示例#29
0
 def test_unify(self):
     eq_(cps(unify(1, 2)), il.failcont(True))
     eq_(cps(unify(1, 1)), done()(True))
示例#30
0
 def test7(self):
   x = LogicVar('x')
   eq_(eval(unify(L(x), L(1))), True)
示例#31
0
 def test_unify3(self):
     x = il.Var('x')
     result = cps(unify(x, 2))
     expect = 1
     eq_(result, expect)
示例#32
0
 def test_unify(self):
   eq_(compile(unify(1, 2)), 'solver.fail_cont(True)')    
   eq_(compile(unify(1, 1)), 'True') 
示例#33
0
 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)
示例#34
0
 def test1(self):
     x = LogicVar('x')
     eq_(eval(unify(x, 1)), True)
示例#35
0
 def test4(self):
   x = Var('x')
   Lx = LogicVar('x')
   eq_(eval(begin(unify(Lx, 1), unify(Lx,1))), True)
示例#36
0
 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)))
示例#37
0
 def test6(self):
   eq_(eval(unify(L(1), L(1))), True)
示例#38
0
 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)
示例#39
0
 def test8(self):
   x = LogicVar('x')
   eq_(eval(unify(L(L(1, x)), L(L(1, x)))), True)
示例#40
0
 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)
示例#41
0
 def testcall(self):
   eq_(eval(call(unify(x, 1))), True)
   eq_(eval(is_(x, quote(prin(1)))&call(x)), None)
示例#42
0
 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)
示例#43
0
 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)
示例#44
0
 def test_unify(self):
     eq_(compile_optimize(unify(1, 2)), il.failcont(True))
     eq_(compile_optimize(unify(1, 1)), True)
示例#45
0
 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)
示例#46
0
文件: testeval.py 项目: chaosim/dao
 def test_or_2(self):
   eq_(eval(or_(unify(1,1), unify(1,2))), True)
示例#47
0
 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) 
示例#48
0
 def test_unify2(self):
     x = il.LogicVar('x')
     result = compile(unify(x, 2))
     expect = 'solver.fail_cont(True)'
     eq_(result, expect)