コード例 #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
ファイル: testoptimize.py プロジェクト: hermetique/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)
コード例 #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
ファイル: testcpsconvert.py プロジェクト: chaosim/dao
 def test_unify3(self):
   x = il.Var('x')
   result = cps(unify(x, 2))
   expect = 1
   eq_(result, expect)
コード例 #11
0
ファイル: testcpsconvert.py プロジェクト: hermetique/dao
 def test_unify2(self):
     x = LogicVar('x')
     result = cps(unify(x, 2))
     expect = 1
     eq_(result, expect)
コード例 #12
0
ファイル: testgencode.py プロジェクト: hermetique/dao
 def test_unify(self):
     eq_(compile(unify(1, 2)), 'solver.fail_cont(True)')
     eq_(compile(unify(1, 1)), 'True')
コード例 #13
0
ファイル: testcpsconvert.py プロジェクト: chaosim/dao
 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
ファイル: testcpsconvert.py プロジェクト: chaosim/dao
 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
ファイル: testcpsconvert.py プロジェクト: hermetique/dao
 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
ファイル: testcpsconvert.py プロジェクト: hermetique/dao
 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
ファイル: testoptimize.py プロジェクト: hermetique/dao
 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
ファイル: testgencode.py プロジェクト: hermetique/dao
 def test_unify2(self):
     x = il.LogicVar('x')
     result = compile(unify(x, 2))
     expect = 'solver.fail_cont(True)'
     eq_(result, expect)