summaryrefslogtreecommitdiff
path: root/prolog/problems/clp_fd
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@fri.uni-lj.si>2015-12-23 16:23:43 +0100
committerTimotej Lazar <timotej.lazar@fri.uni-lj.si>2015-12-23 16:23:43 +0100
commitc1bb0d56b2c0482c766d094c65fdf0fd9d1aa0ba (patch)
treeb23a943e337fc81ad3bc898450229c3974f8388c /prolog/problems/clp_fd
parent766e2ba30413850ab43842de0aa3e9a80c5e7236 (diff)
Simplify Prolog test function
Diffstat (limited to 'prolog/problems/clp_fd')
-rw-r--r--prolog/problems/clp_fd/gcd_3/common.py7
-rw-r--r--prolog/problems/clp_fd/magic_1/common.py7
-rw-r--r--prolog/problems/clp_fd/puzzle_abc_3/common.py7
-rw-r--r--prolog/problems/clp_fd/puzzle_beth_1/common.py7
-rw-r--r--prolog/problems/clp_fd/puzzle_momson_2/common.py7
-rw-r--r--prolog/problems/clp_fd/puzzle_ratio_2/common.py7
-rw-r--r--prolog/problems/clp_fd/tobase_3/common.py7
7 files changed, 14 insertions, 35 deletions
diff --git a/prolog/problems/clp_fd/gcd_3/common.py b/prolog/problems/clp_fd/gcd_3/common.py
index 6e62e3b..f24e0bb 100644
--- a/prolog/problems/clp_fd/gcd_3/common.py
+++ b/prolog/problems/clp_fd/gcd_3/common.py
@@ -35,14 +35,11 @@ test_cases = [
[{'X': '6'}]),
]
-def test(program, solved_problems):
- code = (program + '\n' +
- server.problems.solutions_for_problems('prolog', solved_problems))
-
+def test(code, aux_code):
n_correct = 0
engine_id = None
try:
- engine_id, output = prolog.engine.create(code=code, timeout=1.0)
+ engine_id, output = prolog.engine.create(code=code+aux_code, timeout=1.0)
if engine_id is not None and 'error' not in map(itemgetter(0), output):
# Engine successfully created, and no syntax error in program.
for query, answers in test_cases:
diff --git a/prolog/problems/clp_fd/magic_1/common.py b/prolog/problems/clp_fd/magic_1/common.py
index b897cb3..3ffe72f 100644
--- a/prolog/problems/clp_fd/magic_1/common.py
+++ b/prolog/problems/clp_fd/magic_1/common.py
@@ -33,14 +33,11 @@ test_cases = [
[8, 1, 6, 3, 5, 7, 4, 9, 2], [8, 3, 4, 1, 5, 9, 6, 7, 2]]'}]),
]
-def test(program, solved_problems):
- code = (program + '\n' +
- server.problems.solutions_for_problems('prolog', solved_problems))
-
+def test(code, aux_code):
n_correct = 0
engine_id = None
try:
- engine_id, output = prolog.engine.create(code=code, timeout=1.0)
+ engine_id, output = prolog.engine.create(code=code+aux_code, timeout=1.0)
if engine_id is not None and 'error' not in map(itemgetter(0), output):
# Engine successfully created, and no syntax error in program.
for query, answers in test_cases:
diff --git a/prolog/problems/clp_fd/puzzle_abc_3/common.py b/prolog/problems/clp_fd/puzzle_abc_3/common.py
index 34ad409..ffce416 100644
--- a/prolog/problems/clp_fd/puzzle_abc_3/common.py
+++ b/prolog/problems/clp_fd/puzzle_abc_3/common.py
@@ -25,14 +25,11 @@ test_cases = [
[{'X': '[12/10/5]'}]),
]
-def test(program, solved_problems):
- code = (program + '\n' +
- server.problems.solutions_for_problems('prolog', solved_problems))
-
+def test(code, aux_code):
n_correct = 0
engine_id = None
try:
- engine_id, output = prolog.engine.create(code=code, timeout=1.0)
+ engine_id, output = prolog.engine.create(code=code+aux_code, timeout=1.0)
if engine_id is not None and 'error' not in map(itemgetter(0), output):
# Engine successfully created, and no syntax error in program.
for query, answers in test_cases:
diff --git a/prolog/problems/clp_fd/puzzle_beth_1/common.py b/prolog/problems/clp_fd/puzzle_beth_1/common.py
index 8a975ee..fb00516 100644
--- a/prolog/problems/clp_fd/puzzle_beth_1/common.py
+++ b/prolog/problems/clp_fd/puzzle_beth_1/common.py
@@ -20,14 +20,11 @@ test_cases = [
[{'X': '[12]'}]),
]
-def test(program, solved_problems):
- code = (program + '\n' +
- server.problems.solutions_for_problems('prolog', solved_problems))
-
+def test(code, aux_code):
n_correct = 0
engine_id = None
try:
- engine_id, output = prolog.engine.create(code=code, timeout=1.0)
+ engine_id, output = prolog.engine.create(code=code+aux_code, timeout=1.0)
if engine_id is not None and 'error' not in map(itemgetter(0), output):
# Engine successfully created, and no syntax error in program.
for query, answers in test_cases:
diff --git a/prolog/problems/clp_fd/puzzle_momson_2/common.py b/prolog/problems/clp_fd/puzzle_momson_2/common.py
index 0f9e0a8..906bd15 100644
--- a/prolog/problems/clp_fd/puzzle_momson_2/common.py
+++ b/prolog/problems/clp_fd/puzzle_momson_2/common.py
@@ -27,14 +27,11 @@ test_cases = [
[{'X': '[42/24, 51/15]'}]),
]
-def test(program, solved_problems):
- code = (program + '\n' +
- server.problems.solutions_for_problems('prolog', solved_problems))
-
+def test(code, aux_code):
n_correct = 0
engine_id = None
try:
- engine_id, output = prolog.engine.create(code=code, timeout=1.0)
+ engine_id, output = prolog.engine.create(code=code+aux_code, timeout=1.0)
if engine_id is not None and 'error' not in map(itemgetter(0), output):
# Engine successfully created, and no syntax error in program.
for query, answers in test_cases:
diff --git a/prolog/problems/clp_fd/puzzle_ratio_2/common.py b/prolog/problems/clp_fd/puzzle_ratio_2/common.py
index eca7f62..736cd2e 100644
--- a/prolog/problems/clp_fd/puzzle_ratio_2/common.py
+++ b/prolog/problems/clp_fd/puzzle_ratio_2/common.py
@@ -28,14 +28,11 @@ test_cases = [
[{'X': '[30/24]'}]),
]
-def test(program, solved_problems):
- code = (program + '\n' +
- server.problems.solutions_for_problems('prolog', solved_problems))
-
+def test(code, aux_code):
n_correct = 0
engine_id = None
try:
- engine_id, output = prolog.engine.create(code=code, timeout=1.0)
+ engine_id, output = prolog.engine.create(code=code+aux_code, timeout=1.0)
if engine_id is not None and 'error' not in map(itemgetter(0), output):
# Engine successfully created, and no syntax error in program.
for query, answers in test_cases:
diff --git a/prolog/problems/clp_fd/tobase_3/common.py b/prolog/problems/clp_fd/tobase_3/common.py
index 5e3a783..3783396 100644
--- a/prolog/problems/clp_fd/tobase_3/common.py
+++ b/prolog/problems/clp_fd/tobase_3/common.py
@@ -36,14 +36,11 @@ test_cases = [
[{'X': '[2/1111011, 3/11120, 4/1323, 5/443, 6/323, 7/234, 8/173, 9/146, 10/123]'}]),
]
-def test(program, solved_problems):
- code = (program + '\n' +
- server.problems.solutions_for_problems('prolog', solved_problems))
-
+def test(code, aux_code):
n_correct = 0
engine_id = None
try:
- engine_id, output = prolog.engine.create(code=code, timeout=1.0)
+ engine_id, output = prolog.engine.create(code=code+aux_code, timeout=1.0)
if engine_id is not None and 'error' not in map(itemgetter(0), output):
# Engine successfully created, and no syntax error in program.
for query, answers in test_cases: