def test_evaluate_bounded_projection_function(): yp = YP() yp.assert_fact(yp.atom('cat'), [yp.atom('tom')]) V1 = yp.variable() q = yp.query('cat', [V1]) r = yp.evaluate_bounded(q, (lambda x: V1.get_value())) assert r == [yp.atom('tom')]
def test_run_infinite_script(get_compiled_file): yp = YP() yp.load_script_from_file(get_compiled_file('monkey.prolog')) # canget(state(atdoor,onfloor,atwindow,hasnot)) q = yp.query('canget', [ yp.functor('state', [ yp.atom('atdoor'), yp.atom('onfloor'), yp.atom('atwindow'), yp.atom('hasnot') ]) ]) # this query has infinitely many solutions, just get the first one recursion_limit = sys.getrecursionlimit() r = yp.evaluate_bounded(q, lambda x: x) assert sys.getrecursionlimit() == recursion_limit assert len(r) >= 1