예제 #1
0
파일: testbuiltin.py 프로젝트: chaosim/dao
 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
파일: testoptimize.py 프로젝트: chaosim/dao
 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
파일: testbuiltin.py 프로젝트: chaosim/dao
 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
파일: testbuiltin.py 프로젝트: chaosim/dao
 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
파일: testbuiltin.py 프로젝트: chaosim/dao
 def test1(self):
   x = LogicVar('x')
   eq_(eval(unify(x, 1)), True)
예제 #9
0
파일: testoptimize.py 프로젝트: chaosim/dao
 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
파일: testgencode.py 프로젝트: chaosim/dao
 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
파일: testbuiltin.py 프로젝트: chaosim/dao
 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
파일: testbuiltin.py 프로젝트: chaosim/dao
 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
파일: testeval.py 프로젝트: hermetique/dao
 def test_or_2(self):
     eq_(eval(or_(unify(1, 1), unify(1, 2))), True)
예제 #26
0
파일: testbuiltin.py 프로젝트: chaosim/dao
 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
파일: testbuiltin.py 프로젝트: chaosim/dao
 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
파일: testbuiltin.py 프로젝트: chaosim/dao
 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
파일: testgencode.py 프로젝트: chaosim/dao
 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
파일: testbuiltin.py 프로젝트: chaosim/dao
 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
파일: testbuiltin.py 프로젝트: chaosim/dao
 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
파일: testbuiltin.py 프로젝트: chaosim/dao
 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
파일: testbuiltin.py 프로젝트: chaosim/dao
 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
파일: testbuiltin.py 프로젝트: chaosim/dao
 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
파일: testbuiltin.py 프로젝트: chaosim/dao
 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
파일: testbuiltin.py 프로젝트: chaosim/dao
 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)