summaryrefslogtreecommitdiff
path: root/monkey
diff options
context:
space:
mode:
Diffstat (limited to 'monkey')
-rwxr-xr-xmonkey/monkey.py11
-rwxr-xr-xmonkey/test.py3
2 files changed, 11 insertions, 3 deletions
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