コード例 #1
0
ファイル: testeval.py プロジェクト: hermetique/dao
 def test_findall_or_p(self):
     x, y = Var('x'), Var('y')
     eq_(
         eval(
             findall(
                 macrorules([[x, y], x], [[x, y], y])(prin(1), prin(2)))),
         None)
コード例 #2
0
ファイル: testeval.py プロジェクト: hermetique/dao
 def testLoopUntil(self):
     eq_(
         eval(
             tag_loop_label(
                 let([(i, 3)],
                     LoopUntilForm((set(i, sub(i, 1)), prin(i)),
                                   eq(i, 0))))), None)
コード例 #3
0
ファイル: testeval.py プロジェクト: chaosim/dao
 def test_unwind_protect_loop(self):
   from util import a, i
   eq_(eval(let([(i,3)], 
                block(a, assign(i, sub(i, 1)), 
                         if_(eq(i, 0), 
                           exit_block(a, 1),
                           unwind_protect(continue_block(a), prin(i)))), i)), 0)
コード例 #4
0
ファイル: testeval.py プロジェクト: hermetique/dao
 def testLoopWhen(self):
     eq_(
         eval(
             tag_loop_label(
                 let([(i, 3)],
                     LoopWhenForm((set(i, sub(i, 1)), prin(i)),
                                  gt(i, 0))))), None)
コード例 #5
0
ファイル: testeval.py プロジェクト: hermetique/dao
 def testLoopTimes(self):
     eq_(
         eval(
             tag_loop_label(
                 let([(i, 3)],
                     LoopTimesForm(3, (set(i, sub(i, 1)), prin(i)))))),
         None)
コード例 #6
0
ファイル: testeval.py プロジェクト: hermetique/dao
 def test_unwind_protect_loop(self):
     from util import a, i
     eq_(
         eval(
             let([(i, 3)],
                 block(
                     a, assign(i, sub(i, 1)),
                     if_(eq(i, 0), exit_block(a, 1),
                         unwind_protect(continue_block(a), prin(i)))), i)),
         0)
コード例 #7
0
ファイル: testbuiltin.py プロジェクト: chaosim/dao
 def test_findall_first_p(self):
   eq_(eval(findall(first_p(prin(1), prin(2)))), None)
コード例 #8
0
ファイル: testeval.py プロジェクト: hermetique/dao
 def test_closure1(self):
     x, f = Const('x'), Const('f')
     eq_(eval(let([(f, macrorules([[x], prin(x)])), (x, 1)], f(add(x, x)))),
         None)
コード例 #9
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)
コード例 #10
0
ファイル: testeval.py プロジェクト: hermetique/dao
 def test4(self):
     x = Var('x')
     eq_(eval(macrorules([[x], prin(x)])(add(1, 1))), None)
コード例 #11
0
ファイル: testeval.py プロジェクト: hermetique/dao
 def test_reverse(self):
     x, y = Var('x'), Var('y')
     eq_(eval(macrorules([[x, y], y, x])(prin(1), prin(2))), None)
コード例 #12
0
ファイル: testeval.py プロジェクト: hermetique/dao
 def test_macro5(self):
     x, y, f = Const('x'), Const('y'), MacroVar('f')
     eq_(eval(let([(f, macro((x, y), y, x, 1))], f(println(1), prin(2)))),
         1)
コード例 #13
0
ファイル: testeval.py プロジェクト: chaosim/dao
 def test_macro5(self):
   x, y, f = Const('x'), Const('y'), MacroVar('f')
   eq_(eval(let([(f, macro((x, y), y, x, 1))], f(println(1), prin(2)))), 1)
コード例 #14
0
ファイル: testeval.py プロジェクト: chaosim/dao
 def testEachForm(self):
   eq_(eval(tag_loop_label(EachForm(i, range(3), [prin(i)]))), None)
コード例 #15
0
ファイル: testeval.py プロジェクト: hermetique/dao
 def test_unwind_protect2(self):
     foo = Var('foo')
     eq_(
         eval(
             block(foo, unwind_protect(exit_block(foo, 1), prin(2),
                                       prin(3)))), 1)
コード例 #16
0
ファイル: testeval.py プロジェクト: chaosim/dao
 def testLoopWhen(self):
   eq_(eval(tag_loop_label(let([(i,3)], LoopWhenForm((set(i, sub(i, 1)), prin(i)), 
                                    gt(i,0))))), None)
コード例 #17
0
ファイル: testeval.py プロジェクト: chaosim/dao
 def testLoopUntil(self):
   eq_(eval(tag_loop_label(let([(i,3)], LoopUntilForm((set(i, sub(i, 1)), prin(i)), 
                                    eq(i,0))))), None)
コード例 #18
0
ファイル: testeval.py プロジェクト: chaosim/dao
 def testLoopTimes(self):
   eq_(eval(tag_loop_label(let([(i,3)], LoopTimesForm(3, (set(i, sub(i, 1)), prin(i)))))), None)
コード例 #19
0
ファイル: testeval.py プロジェクト: chaosim/dao
 def test_unwind_protect2(self):
   foo = Var('foo')
   eq_(eval(block(foo, unwind_protect(exit_block(foo, 1), 
                           prin(2), prin(3)))), 1)
コード例 #20
0
 def test_and2(self):
     eq_(eval(and_(prin(1), prin(2))), None)
コード例 #21
0
ファイル: testbuiltin.py プロジェクト: chaosim/dao
 def test_cut_or2(self):
   assert_raises(NoSolution, eval, or_(begin(prin(1), cut_or, fail), 
                                       prin(2)))
コード例 #22
0
 def test_cut_or2(self):
     assert_raises(NoSolution, eval,
                   or_(begin(prin(1), cut_or, fail), prin(2)))
コード例 #23
0
 def test_findall_or_once(self):
     eq_(eval(findall(once(or_(prin(1), prin(2))))), None)
コード例 #24
0
 def test_cut_or(self):
     eq_(eval(or_(begin(prin(1), fail), prin(2))), None)
コード例 #25
0
ファイル: testeval.py プロジェクト: chaosim/dao
 def testEachForm2(self):
   eq_(eval(tag_loop_label(EachForm((i, j), zip(range(3), range(3)), [prin(i, j)]))), None)
コード例 #26
0
ファイル: testeval.py プロジェクト: chaosim/dao
 def test_macro3(self):
   x, y = Const('x'), Const('y')
   eq_(eval(macro((x, y), y, x, 1)(println(1), prin(2))), 1)
コード例 #27
0
ファイル: testeval.py プロジェクト: hermetique/dao
 def testEachForm(self):
     eq_(eval(tag_loop_label(EachForm(i, range(3), [prin(i)]))), None)
コード例 #28
0
ファイル: testeval.py プロジェクト: hermetique/dao
 def test1(self):
     eq_(eval(macrorules([[], prin(1)])()), None)
コード例 #29
0
ファイル: testeval.py プロジェクト: chaosim/dao
 def test1(self):
   eq_(eval(macrorules([[], prin(1)])()), None) 
コード例 #30
0
 def test_findall_first_p(self):
     eq_(eval(findall(first_p(prin(1), prin(2)))), None)
コード例 #31
0
ファイル: testeval.py プロジェクト: hermetique/dao
 def testEachForm2(self):
     eq_(
         eval(
             tag_loop_label(
                 EachForm((i, j), zip(range(3), range(3)), [prin(i, j)]))),
         None)
コード例 #32
0
ファイル: testeval.py プロジェクト: chaosim/dao
 def test2(self):
   x = Var('x')
   eq_(eval(macrorules([[x], x])(prin(1))), None) 
コード例 #33
0
ファイル: testeval.py プロジェクト: hermetique/dao
 def test2(self):
     x = Var('x')
     eq_(eval(macrorules([[x], x])(prin(1))), None)
コード例 #34
0
ファイル: testeval.py プロジェクト: chaosim/dao
 def test4(self):
   x = Var('x')
   eq_(eval(macrorules([[x], prin(x)])(add(1, 1))), None) 
コード例 #35
0
ファイル: testeval.py プロジェクト: hermetique/dao
 def test5(self):
     x = Var('x')
     y = Var('y')
     eq_(eval(let([(y, 1)], macrorules([[x], prin(x)])(add(y, 1)))), None)
コード例 #36
0
ファイル: testeval.py プロジェクト: chaosim/dao
 def test5(self):
   x = Var('x')
   y = Var('y')
   eq_(eval(let([(y, 1)], macrorules([[x], prin(x)])(add(y, 1)))), None) 
コード例 #37
0
ファイル: testeval.py プロジェクト: chaosim/dao
 def test_reverse(self):
   x, y = Var('x'), Var('y')
   eq_(eval(macrorules([[x, y], y, x])(prin(1), prin(2))), None) 
コード例 #38
0
ファイル: testeval.py プロジェクト: chaosim/dao
 def test_findall_or_p(self):
   x, y = Var('x'), Var('y')
   eq_(eval(findall(macrorules([[x, y], x],
                  [[x, y], y])(prin(1), prin(2)))), None) 
コード例 #39
0
ファイル: testeval.py プロジェクト: hermetique/dao
 def test_closure3(self):
     x, y, f = Const('x'), Const('y'), Const('f')
     eq_(
         eval(
             let([(f, macrorules([[x, y], begin(x, y)])), (x, 1)],
                 f(prin(x), prin(add(x, x))))), None)
コード例 #40
0
ファイル: testeval.py プロジェクト: chaosim/dao
 def test_closure1(self):
   x, f = Const('x'), Const('f')
   eq_(eval(let([(f, macrorules([[x], prin(x)])),
                 (x, 1)],
            f(add(x,x)))), None) 
コード例 #41
0
ファイル: testbuiltin.py プロジェクト: chaosim/dao
 def test_findall_or_once(self):
   eq_(eval(findall(once(or_(prin(1), prin(2))))), None)
コード例 #42
0
ファイル: testeval.py プロジェクト: chaosim/dao
 def test_closure3(self):
   x, y, f = Const('x'), Const('y'), Const('f')
   eq_(eval(let([(f, macrorules([[x, y], begin(x, y)])),
                 (x, 1)],
            f(prin(x), prin(add(x,x))))), None) 
コード例 #43
0
ファイル: testbuiltin.py プロジェクト: chaosim/dao
 def test_cut_or(self):
   eq_(eval(or_(begin(prin(1), fail), prin(2))), None)
コード例 #44
0
ファイル: testeval.py プロジェクト: hermetique/dao
 def test_macro3(self):
     x, y = Const('x'), Const('y')
     eq_(eval(macro((x, y), y, x, 1)(println(1), prin(2))), 1)
コード例 #45
0
ファイル: testbuiltin.py プロジェクト: chaosim/dao
 def test_and2(self):
   eq_(eval(and_(prin(1), prin(2))), None)
コード例 #46
0
 def testcall(self):
     eq_(eval(call(unify(x, 1))), True)
     eq_(eval(is_(x, quote(prin(1))) & call(x)), None)