Skip to content

Commit

Permalink
updated oracle and problem statements tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BrentBlanckaert committed Nov 15, 2024
1 parent e28fdd1 commit 82ca93e
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 11 deletions.
1 change: 0 additions & 1 deletion tested/languages/typescript/linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
def run_eslint(
config: DodonaConfig, remaining: float
) -> tuple[list[Message], list[AnnotateCode]]:

"""
Calls eslint to annotate submitted source code and adds resulting score and
annotations to tab.
Expand Down
12 changes: 9 additions & 3 deletions tests/test_functionality.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ def test_generic_exception_wrong_error(
assert updates.find_status_enum() == ["wrong"]


@pytest.mark.parametrize("lang", ["python", "java", "kotlin", "csharp", "typescript", "javascript"])
@pytest.mark.parametrize(
"lang", ["python", "java", "kotlin", "csharp", "typescript", "javascript"]
)
def test_assignment_and_use_in_expression(
lang: str, tmp_path: Path, pytestconfig: pytest.Config
):
Expand Down Expand Up @@ -156,7 +158,9 @@ def test_assignment_and_use_in_expression_list(
assert len(updates.find_all("start-test")) == 1


@pytest.mark.parametrize("lang", ["python", "java", "kotlin", "csharp", "typescript", "javascript"])
@pytest.mark.parametrize(
"lang", ["python", "java", "kotlin", "csharp", "typescript", "javascript"]
)
def test_crashing_assignment_with_before(
lang: str, tmp_path: Path, pytestconfig: pytest.Config
):
Expand Down Expand Up @@ -237,6 +241,7 @@ def test_missing_key_types_detected_js_dictionary(
assert len(updates.find_all("start-testcase")) == 1
assert updates.find_status_enum() == ["correct"]


def test_missing_key_types_detected_ts_object(
tmp_path: Path, pytestconfig: pytest.Config
):
Expand Down Expand Up @@ -356,7 +361,8 @@ def test_batch_compilation_no_fallback_runtime(


@pytest.mark.parametrize(
"lang", ["python", "java", "c", "javascript", "typescript", "kotlin", "bash", "csharp"]
"lang",
["python", "java", "c", "javascript", "typescript", "kotlin", "bash", "csharp"],
)
def test_program_params(lang: str, tmp_path: Path, pytestconfig: pytest.Config):
conf = configuration(pytestconfig, "sum", lang, tmp_path, "short.tson", "correct")
Expand Down
19 changes: 14 additions & 5 deletions tests/test_language_quircks.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def test_javascript_vanilla_object(tmp_path: Path, pytestconfig: pytest.Config):
updates = assert_valid_output(result, pytestconfig)
assert updates.find_status_enum() == ["correct"]


def test_typescript_vanilla_object(tmp_path: Path, pytestconfig: pytest.Config):
conf = configuration(
pytestconfig,
Expand All @@ -49,6 +50,7 @@ def test_typescript_vanilla_object(tmp_path: Path, pytestconfig: pytest.Config):
updates = assert_valid_output(result, pytestconfig)
assert updates.find_status_enum() == ["correct"]


def test_python_input_prompt_is_ignored(tmp_path: Path, pytestconfig: pytest.Config):
conf = configuration(
pytestconfig,
Expand Down Expand Up @@ -89,7 +91,9 @@ def test_haskell_function_arguments_without_brackets(


@pytest.mark.parametrize("lang", ["javascript", "typescript"])
def test_js_ts_exception_correct(lang:str, tmp_path: Path, pytestconfig: pytest.Config):
def test_js_ts_exception_correct(
lang: str, tmp_path: Path, pytestconfig: pytest.Config
):
conf = configuration(
pytestconfig,
"js-ts-exceptions",
Expand All @@ -105,7 +109,9 @@ def test_js_ts_exception_correct(lang:str, tmp_path: Path, pytestconfig: pytest.


@pytest.mark.parametrize("lang", ["javascript", "typescript"])
def test_js_ts_exception_correct_temp(lang:str, tmp_path: Path, pytestconfig: pytest.Config):
def test_js_ts_exception_correct_temp(
lang: str, tmp_path: Path, pytestconfig: pytest.Config
):
conf = configuration(
pytestconfig,
"js-ts-exceptions",
Expand All @@ -121,7 +127,7 @@ def test_js_ts_exception_correct_temp(lang:str, tmp_path: Path, pytestconfig: py


@pytest.mark.parametrize("lang", ["javascript", "typescript"])
def test_js_ts_exception_wrong(lang:str, tmp_path: Path, pytestconfig: pytest.Config):
def test_js_ts_exception_wrong(lang: str, tmp_path: Path, pytestconfig: pytest.Config):
conf = configuration(
pytestconfig,
"js-ts-exceptions",
Expand All @@ -137,7 +143,9 @@ def test_js_ts_exception_wrong(lang:str, tmp_path: Path, pytestconfig: pytest.Co


@pytest.mark.parametrize("lang", ["javascript", "typescript"])
def test_js_ts_exception_wrong_null(lang:str, tmp_path: Path, pytestconfig: pytest.Config):
def test_js_ts_exception_wrong_null(
lang: str, tmp_path: Path, pytestconfig: pytest.Config
):
conf = configuration(
pytestconfig,
"js-ts-exceptions",
Expand All @@ -154,7 +162,7 @@ def test_js_ts_exception_wrong_null(lang:str, tmp_path: Path, pytestconfig: pyte

@pytest.mark.parametrize("lang", ["javascript", "typescript"])
def test_js_ts_exception_missing_message(
lang:str, tmp_path: Path, pytestconfig: pytest.Config
lang: str, tmp_path: Path, pytestconfig: pytest.Config
):
conf = configuration(
pytestconfig,
Expand All @@ -181,6 +189,7 @@ def test_javascript_async(exercise: str, tmp_path: Path, pytestconfig: pytest.Co
updates = assert_valid_output(result, pytestconfig)
assert updates.find_status_enum() == ["correct"]


@pytest.mark.parametrize("exercise", ["echo-function-file-input", "echo-function"])
def test_typescript_async(exercise: str, tmp_path: Path, pytestconfig: pytest.Config):
conf = configuration(
Expand Down
1 change: 1 addition & 0 deletions tests/test_linters.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def test_eslint(tmp_path: Path, config: dict, pytestconfig: pytest.Config):
updates = assert_valid_output(result, pytestconfig)
assert len(updates.find_all("annotate-code")) > 0


@pytest.mark.parametrize("config", _get_config_options("typescript"))
def test_eslint_typescript(tmp_path: Path, config: dict, pytestconfig: pytest.Config):
conf = configuration(
Expand Down
8 changes: 6 additions & 2 deletions tests/test_oracles_programmed.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ def test_missing_custom_check_function(tmp_path: Path, pytestconfig: pytest.Conf
assert len(updates.find_all("append-message")) == 4


@pytest.mark.parametrize("lang", ["python", "java", "kotlin", "javascript", "csharp"])
@pytest.mark.parametrize(
"lang", ["python", "java", "kotlin", "javascript", "typescript", "csharp"]
)
def test_custom_check_function_lotto_correct(
lang: str, tmp_path: Path, pytestconfig: pytest.Config
):
Expand All @@ -118,7 +120,9 @@ def test_custom_check_function_lotto_correct(
assert updates.find_status_enum() == ["correct"]


@pytest.mark.parametrize("lang", ["python", "java", "kotlin", "javascript", "csharp"])
@pytest.mark.parametrize(
"lang", ["python", "java", "kotlin", "javascript", "typescript", "csharp"]
)
def test_custom_check_function_lotto_wrong(
lang: str, tmp_path: Path, pytestconfig: pytest.Config
):
Expand Down
15 changes: 15 additions & 0 deletions tests/test_problem_statements.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def test_small_descriptions(language: str):
("c", "this_is_a_function_name"),
("kotlin", "thisIsAFunctionName"),
("javascript", "thisIsAFunctionName"),
("typescript", "thisIsAFunctionName"),
("haskell", "thisIsAFunctionName"),
("runhaskell", "thisIsAFunctionName"),
],
Expand Down Expand Up @@ -71,6 +72,11 @@ def test_template_function_name(lang: str, expected: str):
("javascript", "'text'", "string"),
("javascript", '"sequence", "integer"', "array<number>"),
("javascript", '"array", ("set", ("integer", ))', "array<set<number>>"),
("typescript", "'integer'", "number"),
("typescript", "'real'", "number"),
("typescript", "'text'", "string"),
("typescript", '"sequence", "integer"', "array<number>"),
("typescript", '"array", ("set", ("integer", ))', "array<set<number>>"),
("haskell", "'integer'", "Int"),
("haskell", "'real'", "Double"),
("haskell", "'text'", "String"),
Expand Down Expand Up @@ -99,6 +105,8 @@ def test_template_type_name(lang: str, tested_type: Any, expected: str):
("kotlin", "'map'", "map"),
("javascript", "'sequence'", "sequence"),
("javascript", "'map'", "map"),
("typescript", "'sequence'", "sequence"),
("typescript", "'map'", "map"),
("haskell", "'sequence'", "sequence"),
("haskell", "'list'", "list"),
],
Expand All @@ -120,6 +128,8 @@ def test_template_natural_type_name(lang: str, tested_type: Any, expected: str):
("kotlin", "'map'", "afbeelding"),
("javascript", "'sequence'", "sequentie"),
("javascript", "'map'", "afbeelding"),
("typescript", "'sequence'", "sequentie"),
("typescript", "'map'", "afbeelding"),
("haskell", "'sequence'", "sequentie"),
("haskell", "'list'", "lijst"),
],
Expand Down Expand Up @@ -149,6 +159,10 @@ def test_template_natural_type_name_nl(lang: str, tested_type: Any, expected: st
"javascript",
"let random = new Random()\nrandom.newSequence(10, 10)\n[10, 5, 2, 8, 7, 1, 3, 4, 9, 6]",
),
(
"typescript",
"let random = new Random()\nrandom.newSequence(10, 10)\n[10, 5, 2, 8, 7, 1, 3, 4, 9, 6]",
),
],
)
def test_template_statement_expression(lang: str, expected: str):
Expand All @@ -167,6 +181,7 @@ def test_template_statement_expression(lang: str, expected: str):
"c",
"kotlin",
"javascript",
"typescript",
"haskell",
],
)
Expand Down

0 comments on commit 82ca93e

Please sign in to comment.