summaryrefslogtreecommitdiff
path: root/prolog/problems/sorting
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/sorting
parent766e2ba30413850ab43842de0aa3e9a80c5e7236 (diff)
Simplify Prolog test function
Diffstat (limited to 'prolog/problems/sorting')
-rw-r--r--prolog/problems/sorting/is_sorted_1/common.py7
-rw-r--r--prolog/problems/sorting/isort_2/common.py7
-rw-r--r--prolog/problems/sorting/pivoting_4/common.py7
-rw-r--r--prolog/problems/sorting/quick_sort_2/common.py7
-rw-r--r--prolog/problems/sorting/sins_3/common.py7
-rw-r--r--prolog/problems/sorting/slowest_sort_ever_2/common.py7
6 files changed, 12 insertions, 30 deletions
diff --git a/prolog/problems/sorting/is_sorted_1/common.py b/prolog/problems/sorting/is_sorted_1/common.py
index 9213ddc..db5c3cc 100644
--- a/prolog/problems/sorting/is_sorted_1/common.py
+++ b/prolog/problems/sorting/is_sorted_1/common.py
@@ -34,14 +34,11 @@ test_cases = [
[{}]),
]
-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/sorting/isort_2/common.py b/prolog/problems/sorting/isort_2/common.py
index 6041b35..1669a4a 100644
--- a/prolog/problems/sorting/isort_2/common.py
+++ b/prolog/problems/sorting/isort_2/common.py
@@ -33,14 +33,11 @@ test_cases = [
[{'X': '[1, 2, 3, 4, 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/sorting/pivoting_4/common.py b/prolog/problems/sorting/pivoting_4/common.py
index 0e9afaa..3a3a906 100644
--- a/prolog/problems/sorting/pivoting_4/common.py
+++ b/prolog/problems/sorting/pivoting_4/common.py
@@ -30,14 +30,11 @@ test_cases = [
[{'A': '[1, 0, 3, -2]', 'B': '[22, 8, 5, 7]'}]),
]
-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/sorting/quick_sort_2/common.py b/prolog/problems/sorting/quick_sort_2/common.py
index b1449f1..d46c185 100644
--- a/prolog/problems/sorting/quick_sort_2/common.py
+++ b/prolog/problems/sorting/quick_sort_2/common.py
@@ -39,14 +39,11 @@ test_cases = [
[{'X': '[1, 2, 3, 4, 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/sorting/sins_3/common.py b/prolog/problems/sorting/sins_3/common.py
index 4c707ca..efc544e 100644
--- a/prolog/problems/sorting/sins_3/common.py
+++ b/prolog/problems/sorting/sins_3/common.py
@@ -31,14 +31,11 @@ test_cases = [
[{'X': '[2, 2, 3, 4, 5, 6, 7]'}]),
]
-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/sorting/slowest_sort_ever_2/common.py b/prolog/problems/sorting/slowest_sort_ever_2/common.py
index 72e25e2..5d0f566 100644
--- a/prolog/problems/sorting/slowest_sort_ever_2/common.py
+++ b/prolog/problems/sorting/slowest_sort_ever_2/common.py
@@ -40,14 +40,11 @@ test_cases = [
[{'X': '[2, 3, 4, 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: