Пример #1
0
 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
 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
 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
 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
 def testLoopTimes(self):
     eq_(
         eval(
             tag_loop_label(
                 let([(i, 3)],
                     LoopTimesForm(3, (set(i, sub(i, 1)), prin(i)))))),
         None)
Пример #6
0
 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
 def test_findall_first_p(self):
   eq_(eval(findall(first_p(prin(1), prin(2)))), None)
Пример #8
0
 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
 def testcall(self):
   eq_(eval(call(unify(x, 1))), True)
   eq_(eval(is_(x, quote(prin(1)))&call(x)), None)
Пример #10
0
 def test4(self):
     x = Var('x')
     eq_(eval(macrorules([[x], prin(x)])(add(1, 1))), None)
Пример #11
0
 def test_reverse(self):
     x, y = Var('x'), Var('y')
     eq_(eval(macrorules([[x, y], y, x])(prin(1), prin(2))), None)
Пример #12
0
 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
 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
 def testEachForm(self):
   eq_(eval(tag_loop_label(EachForm(i, range(3), [prin(i)]))), None)
Пример #15
0
 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
 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
 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
 def testLoopTimes(self):
   eq_(eval(tag_loop_label(let([(i,3)], LoopTimesForm(3, (set(i, sub(i, 1)), prin(i)))))), None)
Пример #19
0
 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
 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
 def testEachForm2(self):
   eq_(eval(tag_loop_label(EachForm((i, j), zip(range(3), range(3)), [prin(i, j)]))), None)
Пример #26
0
 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
 def testEachForm(self):
     eq_(eval(tag_loop_label(EachForm(i, range(3), [prin(i)]))), None)
Пример #28
0
 def test1(self):
     eq_(eval(macrorules([[], prin(1)])()), None)
Пример #29
0
 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
 def testEachForm2(self):
     eq_(
         eval(
             tag_loop_label(
                 EachForm((i, j), zip(range(3), range(3)), [prin(i, j)]))),
         None)
Пример #32
0
 def test2(self):
   x = Var('x')
   eq_(eval(macrorules([[x], x])(prin(1))), None) 
Пример #33
0
 def test2(self):
     x = Var('x')
     eq_(eval(macrorules([[x], x])(prin(1))), None)
Пример #34
0
 def test4(self):
   x = Var('x')
   eq_(eval(macrorules([[x], prin(x)])(add(1, 1))), None) 
Пример #35
0
 def test5(self):
     x = Var('x')
     y = Var('y')
     eq_(eval(let([(y, 1)], macrorules([[x], prin(x)])(add(y, 1)))), None)
Пример #36
0
 def test5(self):
   x = Var('x')
   y = Var('y')
   eq_(eval(let([(y, 1)], macrorules([[x], prin(x)])(add(y, 1)))), None) 
Пример #37
0
 def test_reverse(self):
   x, y = Var('x'), Var('y')
   eq_(eval(macrorules([[x, y], y, x])(prin(1), prin(2))), None) 
Пример #38
0
 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
 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
 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
 def test_findall_or_once(self):
   eq_(eval(findall(once(or_(prin(1), prin(2))))), None)
Пример #42
0
 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
 def test_cut_or(self):
   eq_(eval(or_(begin(prin(1), fail), prin(2))), None)
Пример #44
0
 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
 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)