summaryrefslogtreecommitdiff
path: root/monkey/test.py
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@araneo.org>2015-03-09 18:09:59 +0100
committerAleš Smodiš <aless@guru.si>2015-08-11 14:26:02 +0200
commit9d145715812d63390bee3f1025f0359e7f4c3614 (patch)
tree2baff1c8f99fbd20e503668280daa9001b0367d8 /monkey/test.py
parentfdcf3c85991463f8c9b9f876e52f91b9f391e30f (diff)
Move hint message generation to a new function
Diffstat (limited to 'monkey/test.py')
-rwxr-xr-xmonkey/test.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/monkey/test.py b/monkey/test.py
index 17c27fe..cf67723 100755
--- a/monkey/test.py
+++ b/monkey/test.py
@@ -9,7 +9,7 @@ from termcolor import colored
from .edits import classify_edits, trace_graph
from .graph import graphviz
-from .monkey import fix
+from .monkey import fix, fix_hints
from prolog.engine import test
from prolog.util import annotate, compose, stringify
from .util import indent
@@ -53,12 +53,15 @@ try:
except:
done = []
-def print_hint(solution, steps, fix_time, n_tested):
+def print_hint(code, solution, steps, fix_time, n_tested):
if solution:
print(colored('Hint found! Tested {} programs in {:.1f} s.'.format(n_tested, fix_time), 'green'))
print(colored(' Edits', 'blue'))
for step_type, pos, a, b in steps:
print(' {}: {} {} → {}'.format(pos, step_type, stringify(a), stringify(b)))
+ print(colored(' Hints', 'blue'))
+ for (start, end), msg in fix_hints(code, steps):
+ print(' {}-{}: {}'.format(start, end, msg))
print(colored(' Final version', 'blue'))
print(indent(compose(annotate(solution)), 2))
else:
@@ -80,7 +83,7 @@ if len(sys.argv) >= 3 and sys.argv[2] == 'test':
solution, steps, fix_time, n_tested = fix(problem.name, program, edits, aux_code=aux_code, timeout=timeout)
if solution:
done.append(program)
- print_hint(solution, steps, fix_time, n_tested)
+ print_hint(program, solution, steps, fix_time, n_tested)
print()
pickle.dump(done, open('status-'+str(problem.pk)+'.pickle', 'wb'))
@@ -172,4 +175,4 @@ else:
# Try finding a fix.
print(colored('Analyzing program…', 'yellow'))
solution, steps, fix_time, n_tested = fix(problem.name, code, edits, aux_code=aux_code, debug=True)
- print_hint(solution, steps, fix_time, n_tested)
+ print_hint(code, solution, steps, fix_time, n_tested)