Skip to content

Commit 4313844

Browse files
committed
Added test for strict_syntax rejecting implicit multiplication and updated default to False
1 parent f919293 commit 4313844

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

app/evaluation_test.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,26 @@ def test_e_latex(self, response, is_latex, is_correct):
192192

193193

194194

195+
@pytest.mark.parametrize("params, is_correct", [
196+
({}, True),
197+
({"atol": 0.0, "rtol": 0.0, "strict_syntax": False, "physical_quantity": False, "elementary_functions": False}, True),
198+
({"atol": 0.0, "rtol": 0.0, "strict_syntax": False, "physical_quantity": False, "elementary_functions": True}, True),
199+
({"atol": 0.0, "rtol": 0.0, "strict_syntax": True, "physical_quantity": False, "elementary_functions": False}, False),
200+
({"atol": 0.0, "rtol": 0.0, "strict_syntax": True, "physical_quantity": False, "elementary_functions": True}, False),
201+
])
202+
def test_strict_syntax_rejects_implicit_multiplication(self, params, is_correct):
203+
response = "-2M0/3"
204+
answer = "-2M0/3"
205+
if is_correct:
206+
result = evaluation_function(response, answer, params)
207+
assert result["is_correct"] is True
208+
else:
209+
# strict_syntax=True prevents implicit multiplication, so -2M0/3 cannot be
210+
# parsed. Answer parse failures are raised as exceptions (not returned as
211+
# is_correct=False) because they indicate a task misconfiguration.
212+
with pytest.raises(Exception):
213+
evaluation_function(response, answer, params)
214+
195215
def test_mu_preview_evaluate(self):
196216
response = "10 μA"
197217
params = Params(is_latex=False, elementary_functions=False, strict_syntax=False, physical_quantity=True)

app/utility/expression_utilities.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"complexNumbers": False,
1010
"convention": "equal_precedence",
1111
"elementary_functions": False,
12-
"strict_syntax": True,
12+
"strict_syntax": False,
1313
"multiple_answers_criteria": "all",
1414
}
1515

0 commit comments

Comments
 (0)