From c1bb0d56b2c0482c766d094c65fdf0fd9d1aa0ba Mon Sep 17 00:00:00 2001
From: Timotej Lazar <timotej.lazar@fri.uni-lj.si>
Date: Wed, 23 Dec 2015 16:23:43 +0100
Subject: Simplify Prolog test function

---
 prolog/problems/sorting/is_sorted_1/common.py         | 7 ++-----
 prolog/problems/sorting/isort_2/common.py             | 7 ++-----
 prolog/problems/sorting/pivoting_4/common.py          | 7 ++-----
 prolog/problems/sorting/quick_sort_2/common.py        | 7 ++-----
 prolog/problems/sorting/sins_3/common.py              | 7 ++-----
 prolog/problems/sorting/slowest_sort_ever_2/common.py | 7 ++-----
 6 files changed, 12 insertions(+), 30 deletions(-)

(limited to 'prolog/problems/sorting')

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:
-- 
cgit v1.2.1