Skip to content

Commit

Permalink
GD-468: Fix prameterized test argument parsing
Browse files Browse the repository at this point in the history
# Why
See #468

# What
We first trim the input by removing edges and surrounding brackets and then iterate over possible parameters
  • Loading branch information
MikeSchulze committed May 28, 2024
1 parent e5dfb7c commit 966e7e7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion addons/gdUnit4/src/core/parse/GdFunctionArgument.gd
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func _parse_parameter_set(input :String) -> PackedStringArray:
return []

input = _cleanup_leading_spaces.sub(input, "", true)
input = input.replace("\n", "").trim_prefix("[").trim_suffix("]").trim_prefix(" ")
input = input.replace("\n", "").strip_edges().trim_prefix("[").trim_suffix("]").trim_prefix("]")
var single_quote := false
var double_quote := false
var array_end := 0
Expand Down
16 changes: 16 additions & 0 deletions addons/gdUnit4/test/core/parse/GdFunctionArgumentTest.gd
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,22 @@ func test__parse_argument_as_array_bad_formatted() -> void:
)


func test_parse_argument_as_array_ends_with_additional_comma() -> void:
var test_parameters := """
[
[true, 'bool'],
[42, 'int'],
['foo', 'String'],
]"""
var fa := GdFunctionArgument.new(GdFunctionArgument.ARG_PARAMETERIZED_TEST, TYPE_STRING, test_parameters)
assert_array(fa.parameter_sets()).contains_exactly([
"""[true, 'bool']""",
"""[42, 'int']""",
"""['foo', 'String']"""
]
)


func test__parse_argument_as_reference() -> void:
var test_parameters := "_test_args()"

Expand Down

0 comments on commit 966e7e7

Please sign in to comment.