summaryrefslogtreecommitdiff
path: root/monkey/monkey.py
diff options
context:
space:
mode:
Diffstat (limited to 'monkey/monkey.py')
-rwxr-xr-xmonkey/monkey.py11
1 files changed, 10 insertions, 1 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).