Skip to content

Commit 6dd182c

Browse files
committed
added tests for evlauation_functoin()
1 parent 4789c62 commit 6dd182c

3 files changed

Lines changed: 43 additions & 9 deletions

File tree

config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"EvaluationFunctionName": ""
2+
"EvaluationFunctionName": "evaluatePropositionalLogic"
33
}

evaluation_function/evaluation.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
from typing import Any
22
from lf_toolkit.evaluation import Result, Params
33

4+
from evaluation_function.domain.evaluators import *
45
from evaluation_function.domain.formula import *
5-
from parsing.tokenizer import *
6-
from parsing.tree_builder import *
6+
from evaluation_function.parsing.tokenizer import *
7+
from evaluation_function.parsing.tree_builder import *
78

89

910
# def parse_response(response: str) -> tuple[bool, Formula | str]:
@@ -138,7 +139,7 @@ def evaluation_function(
138139
if not isinstance(response, str):
139140
return Result(
140141
is_correct=False,
141-
feedback="Please enter a string/text."
142+
feedback_items=[("incorrect input", "resposne must be type String")]
142143
)
143144

144145

@@ -163,7 +164,7 @@ def evaluation_function(
163164
except ValueError as e:
164165
return Result(
165166
is_correct=False,
166-
feedback=str(e)
167+
feedback_items=[(ValueError, str(e))]
167168
)
168169

169170

@@ -175,7 +176,7 @@ def evaluation_function(
175176
except BuildError as e:
176177
return Result(
177178
is_correct=False,
178-
feedback=str(e)
179+
feedback_items=[(BuildError, str(e))]
179180
)
180181

181182
#swtich on action

evaluation_function/evaluation_test.py

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,43 @@ class TestEvaluationFunction(unittest.TestCase):
2121
as it should.
2222
"""
2323

24-
def test_evaluation(self):
24+
def test_evaluation_default(self):
2525
response, answer, params = "Hello, World", "Hello, World", Params()
2626

2727
result = evaluation_function(response, answer, params).to_dict()
2828

29-
self.assertEqual(result.get("is_correct"), True)
30-
self.assertFalse(result.get("feedback", False))
29+
self.assertEqual(result.get("is_correct"), False)
30+
self.assertFalse(len(result.get("feedback", [])) == 0)
31+
32+
def test_check_tautology(self):
33+
34+
response, answer, params = "p ∨ ¬p", "", {"action": "tautology"}
35+
36+
result = evaluation_function(response, answer, params).to_dict()
37+
38+
self.assertTrue(result.get("is_correct"))
39+
40+
def test_check_tautology_fail(self):
41+
42+
response, answer, params = "p ∧ ¬p", "", {"action": "tautology"}
43+
44+
result = evaluation_function(response, answer, params).to_dict()
45+
46+
self.assertFalse(result.get("is_correct"))
47+
48+
49+
def test_check_satisfiability(self):
50+
51+
response, answer, params = "p ∧ q", "", {"action": "satisfiability"}
52+
53+
result = evaluation_function(response, answer, params).to_dict()
54+
55+
self.assertTrue(result.get("is_correct"))
56+
57+
def test_check_satisfiability_fail(self):
58+
59+
response, answer, params = "p ∧ ¬p", "", {"action": "satisfiability"}
60+
61+
result = evaluation_function(response, answer, params).to_dict()
62+
63+
self.assertFalse(result.get("is_correct"))

0 commit comments

Comments
 (0)