Пример #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 test_findall2(self):
   cut_or_cont = il.Var('cut_or_cont')
   x, y = Var('x'), Var('y')
   findall_result = il.Var('findall_result')
   result = cps(findall(or_(1, 2), x, y))
   expect = 1
   eq_(result, expect)
Пример #3
0
 def test_findall2(self):
     cut_or_cont = il.Var('cut_or_cont')
     x, y = Var('x'), Var('y')
     findall_result = il.Var('findall_result')
     result = cps(findall(or_(1, 2), x, y))
     expect = 1
     eq_(result, expect)
Пример #4
0
 def test_findall_template_func(self):
     x, y, z = LogicVar('x'), LogicVar('y'), LogicVar('z')
     f = Var('f')
     eq_(
         eval(
             let([(f, rules(((), 2), ((), 3)))], findall(is_(x, f()), x, y),
                 getvalue(y))), [2, 3])
Пример #5
0
 def test_findall_template_or(self):
   x, y, z = LogicVar('x'), LogicVar('y'), LogicVar('z')
   f = Var('f')
   eq_(eval(begin(findall(or_(is_(x, 1), is_(x, 2)), x, y), getvalue(y))), [1, 2])
Пример #6
0
 def test_findall_first_p(self):
   eq_(eval(findall(first_p(prin(1), prin(2)))), None)
Пример #7
0
 def test_findall_or_once(self):
   eq_(eval(findall(once(or_(prin(1), prin(2))))), None)
Пример #8
0
 def test_between3(self):
   x = LogicVar('x')
   y = LogicVar('y')
   eq_(eval(begin(findall(between(1, 3, x), x, y), getvalue(y))), [1, 2, 3])
Пример #9
0
 def test_findall(self):
     cut_or_cont = il.Var('cut_or_cont')
     result = cps(findall(or_(1, 2)))
     expect = 1
     eq_(result, expect)
Пример #10
0
 def test_findall_or_once(self):
     eq_(eval(findall(once(or_(prin(1), prin(2))))), None)
Пример #11
0
 def test_sub_string2(self):
   eq_(eval(begin(findall(subsequence('ab', x, y, z, k), k, z), z)), 
            ['a', 'ab', 'b'])
Пример #12
0
 def test_findall_template_func(self):
   x, y, z = LogicVar('x'), LogicVar('y'), LogicVar('z')
   f = Var('f')
   eq_(eval(let([(f, rules(((), 2), ((), 3)))], 
              findall(is_(x, f()), x, y), getvalue(y))), [2, 3])
Пример #13
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) 
Пример #14
0
 def test_findall_string_concat2(self):
     eq_(eval(begin(findall(concat(x, y, "abc"), L(x, y), z), z)),
         [L("a", "bc"), L("ab", "c")])
Пример #15
0
 def test_sub_string2(self):
     eq_(eval(begin(findall(subsequence('ab', x, y, z, k), k, z), z)),
         ['a', 'ab', 'b'])
Пример #16
0
 def test_sub_string(self):
     eq_(eval(begin(findall(subsequence('ab', 0, y, 2, "ab"), y, z), z)),
         [2])
Пример #17
0
 def test_findall_template_or(self):
     x, y, z = LogicVar('x'), LogicVar('y'), LogicVar('z')
     f = Var('f')
     eq_(eval(begin(findall(or_(is_(x, 1), is_(x, 2)), x, y), getvalue(y))),
         [1, 2])
Пример #18
0
 def test_findall_first_p(self):
     eq_(eval(findall(first_p(prin(1), prin(2)))), None)
Пример #19
0
 def test_sub_string(self):
   eq_(eval(begin(findall(subsequence('ab', 0, y, 2, "ab"), y, z), z)), 
            [2])
Пример #20
0
 def test_findall(self):
   cut_or_cont = il.Var('cut_or_cont')
   result = cps(findall(or_(1, 2)))
   expect = 1
   eq_(result, expect)
Пример #21
0
 def test_findall_string_concat2(self):
   eq_(eval(begin(findall(concat(x, y, "abc"), L(x, y), z), z)), 
            [L("a", "bc"), L("ab", "c")])    
Пример #22
0
 def test_between3(self):
     x = LogicVar('x')
     y = LogicVar('y')
     eq_(eval(begin(findall(between(1, 3, x), x, y), getvalue(y))),
         [1, 2, 3])