Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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])
Exemple #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])
Exemple #6
0
 def test_findall_first_p(self):
   eq_(eval(findall(first_p(prin(1), prin(2)))), None)
Exemple #7
0
 def test_findall_or_once(self):
   eq_(eval(findall(once(or_(prin(1), prin(2))))), None)
Exemple #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])
Exemple #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)
Exemple #10
0
 def test_findall_or_once(self):
     eq_(eval(findall(once(or_(prin(1), prin(2))))), None)
Exemple #11
0
 def test_sub_string2(self):
   eq_(eval(begin(findall(subsequence('ab', x, y, z, k), k, z), z)), 
            ['a', 'ab', 'b'])
Exemple #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])
Exemple #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) 
Exemple #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")])
Exemple #15
0
 def test_sub_string2(self):
     eq_(eval(begin(findall(subsequence('ab', x, y, z, k), k, z), z)),
         ['a', 'ab', 'b'])
Exemple #16
0
 def test_sub_string(self):
     eq_(eval(begin(findall(subsequence('ab', 0, y, 2, "ab"), y, z), z)),
         [2])
Exemple #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])
Exemple #18
0
 def test_findall_first_p(self):
     eq_(eval(findall(first_p(prin(1), prin(2)))), None)
Exemple #19
0
 def test_sub_string(self):
   eq_(eval(begin(findall(subsequence('ab', 0, y, 2, "ab"), y, z), z)), 
            [2])
Exemple #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)
Exemple #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")])    
Exemple #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])