コード例 #1
0
 def setUp(self):
     text = '''
     b(X) :-
         Y = (write(X), X),
         call(Y).
     a(1).
     a(2).'''.lstrip()
     self.engine = core.Engine()
     self.engine._consult(text)
コード例 #2
0
 def setUp(self):
     theory = """
     twice(!) :- write('C ').
     twice(true) :- write('Moss ').
     goal((twice(_), !)).
     goal(write('Three ')).
     """.lstrip()
     self.engine = core.Engine()
     self.engine._consult(theory)
コード例 #3
0
 def setUp(self):
     theory = '''
     foo(X) :- Y is X * 2, throw(test(Y)).
     bar(X) :- X = Y, throw(Y).
     coo(X) :- throw(X).
     car(X) :- X = 1, throw(X).
     g :- catch(p, B, write(h2)), coo(c).
     p.
     p :- throw(B).
     '''.lstrip()
     self.engine = core.Engine()
     self.engine._consult(theory)
コード例 #4
0
 def test_true(self):
     engine = core.Engine()
     self.assertTrue(engine.solve('true.'))
コード例 #5
0
 def setUp(self):
     self.engine = core.Engine()
コード例 #6
0
 def test_fail(self):
     engine = core.Engine()
     self.assertFalse(engine.solve('fail.'))