From 368bb943b548e9b3f338b4a73379608221388bf8 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Wed, 6 May 2015 16:26:57 +0200 Subject: Remove app-specific code from prolog.engine --- monkey/monkey.py | 11 ++++++++++- monkey/test.py | 3 +-- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'monkey') diff --git a/monkey/monkey.py b/monkey/monkey.py index fd11868..f64a142 100755 --- a/monkey/monkey.py +++ b/monkey/monkey.py @@ -3,11 +3,20 @@ import math import time +import prolog.engine from .edits import classify_edits -from prolog.engine import test from prolog.util import Token, annotate, compose, map_vars, normalized, rename_vars, stringify from .util import PQueue +# Check whether all tests for problem [name] succeed. +def test(name, code): + try: + reply = prolog.engine.create_and_ask( + code=code, query='run_tests({})'.format(name)) + return reply.get('event') == 'success' + except Exception as ex: + return False + # Starting from [code], find a sequence of edits that transforms it into a # correct predicate for [name]. Append [aux_code] when testing (available facts # and predicates). diff --git a/monkey/test.py b/monkey/test.py index 1909f8d..6887a2c 100755 --- a/monkey/test.py +++ b/monkey/test.py @@ -9,8 +9,7 @@ from termcolor import colored from .edits import classify_edits, trace_graph from .graph import graphviz -from .monkey import fix, fix_hints -from prolog.engine import test +from .monkey import fix, fix_hints, test from prolog.util import annotate, compose, stringify from .util import indent -- cgit v1.2.1