Skip to content

Commit

Permalink
fixed some of the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BrentBlanckaert committed Dec 10, 2024
1 parent a791d6a commit 387f42f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions tested/languages/typescript/generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
VariableAssignment,
VariableType,
as_basic_type,
_get_type_for,
)
from tested.testsuite import MainInput

Expand Down Expand Up @@ -136,7 +135,7 @@ def convert_function_call(call: FunctionCall, internal=False) -> str:

def convert_declaration(statement: Statement, tp: AllTypes | VariableType) -> str:
if isinstance(tp, VariableType):
return tp.data
return f"{tp.data}"
elif tp == AdvancedStringTypes.CHAR:
return "string"

Check warning on line 140 in tested/languages/typescript/generators.py

View check run for this annotation

Codecov / codecov/patch

tested/languages/typescript/generators.py#L140

Added line #L140 was not covered by tests
elif isinstance(tp, AdvancedNumericTypes):
Expand Down Expand Up @@ -222,11 +221,13 @@ def convert_statement(statement: Statement, internal=False, full=False) -> str:
)
elif isinstance(statement, VariableAssignment):
if full:
prefix = "let "
else:
prefix = ""
return (
f"let {statement.variable} : {convert_declaration(statement, statement.type)} = "
f"{convert_statement(statement.expression, True)}"
)

return (
f"{prefix}{statement.variable} : {convert_declaration(statement, statement.type)} = "
f"{statement.variable} = "
f"{convert_statement(statement.expression, True)}"
)
raise AssertionError(f"Unknown statement: {statement!r}")
Expand Down
2 changes: 1 addition & 1 deletion tests/test_problem_statements.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def test_template_natural_type_name_nl(lang: str, tested_type: Any, expected: st
),
(
"typescript",
"let random = new Random()\nrandom.newSequence(10, 10)\n[10, 5, 2, 8, 7, 1, 3, 4, 9, 6]",
"let random : Random = new Random()\nrandom.newSequence(10, 10)\n[10, 5, 2, 8, 7, 1, 3, 4, 9, 6]",
),
],
)
Expand Down

0 comments on commit 387f42f

Please sign in to comment.