Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GD-579: Part1: Minimize unsafe_call_argument warnings #580

Merged
merged 14 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Bug Report
description: Report a GdUnit4 bug
title: 'GD-XXX: Describe the issue briefly'
labels: ['bug']
projects: ['projects/5']
projects: ['GdUnit4']
assignees:
- MikeSchulze

Expand All @@ -20,8 +20,9 @@ body:
label: The used GdUnit4 version
description: Which GdUnit4 version are you using?
options:
- 4.4.0 (Pre Release/Master branch)
- 4.3.4 (Latest Release)
- 4.4.1 (Pre Release/Master branch)
- 4.4.0 (Latest Release)
- 4.3.4
- 4.3.3
- 4.3.2
- 4.3.1
Expand Down Expand Up @@ -92,7 +93,7 @@ body:

If the issue involves code, please include relevant snippets below:

```gdscript
```gd
# Sample code demonstrating the issue
func reproduce_issue():
# Your code here
Expand Down
5 changes: 3 additions & 2 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement
title: 'GD-XXX: Describe the feature briefly'
labels: ['enhancement']
projects: ['GdUnit4']
assignees: MikeSchulze

---
Expand Down
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/refactoring.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
---
name: Refactoring
about: Create a refactoring issue to improve code base of GdUnit4
title: ''
labels: refactoring
title: 'GD-XXX: Describe the refactoring briefly'
labels: ['refactoring']
projects: ['GdUnit4']
assignees: MikeSchulze

---
Expand All @@ -13,6 +14,5 @@ assignees: MikeSchulze
**Describe Why**
<!-- A clear and concise description why the refactoring is need.-->


**Dev hints**
<!-- Add some dev nodes here.-->
3 changes: 2 additions & 1 deletion .github/ISSUE_TEMPLATE/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
name: Task
about: A small task to implement
title: ''
labels: ''
labels: ['task']
projects: ['GdUnit4']
assignees: MikeSchulze

---
Expand Down
2 changes: 1 addition & 1 deletion addons/gdUnit4/plugin.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
name="gdUnit4"
description="Unit Testing Framework for Godot Scripts"
author="Mike Schulze"
version="4.4.0"
version="4.4.1"
script="plugin.gd"
4 changes: 2 additions & 2 deletions addons/gdUnit4/src/GdUnitAssert.gd
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ func is_not_null():
## Verifies that the current value is equal to expected one.
@warning_ignore("unused_parameter")
@warning_ignore("untyped_declaration")
func is_equal(expected):
func is_equal(expected: Variant):
return self


## Verifies that the current value is not equal to expected one.
@warning_ignore("unused_parameter")
@warning_ignore("untyped_declaration")
func is_not_equal(expected):
func is_not_equal(expected: Variant):
return self


Expand Down
2 changes: 1 addition & 1 deletion addons/gdUnit4/src/GdUnitTestSuite.gd
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func resource_as_string(resource_path :String) -> String:

## Reads a resource by given path <resource_path> and return Variand translated by str_to_var
func resource_as_var(resource_path :String) -> Variant:
return str_to_var(__gdunit_file_access().resource_as_string(resource_path))
return str_to_var(__gdunit_file_access().resource_as_string(resource_path) as String)


## clears the debuger error list[br]
Expand Down
40 changes: 20 additions & 20 deletions addons/gdUnit4/src/asserts/GdAssertMessages.gd
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ static func _nerror(number :Variant) -> String:
static func _colored_value(value :Variant) -> String:
match typeof(value):
TYPE_STRING, TYPE_STRING_NAME:
return "'[color=%s]%s[/color]'" % [VALUE_COLOR, _colored_string_div(value)]
return "'[color=%s]%s[/color]'" % [VALUE_COLOR, _colored_string_div(str(value))]
TYPE_INT:
return "'[color=%s]%d[/color]'" % [VALUE_COLOR, value]
TYPE_FLOAT:
Expand All @@ -109,7 +109,7 @@ static func _colored_value(value :Variant) -> String:
if value == null:
return "'[color=%s]<null>[/color]'" % [VALUE_COLOR]
if value is InputEvent:
return "[color=%s]<%s>[/color]" % [VALUE_COLOR, input_event_as_text(value)]
return "[color=%s]<%s>[/color]" % [VALUE_COLOR, input_event_as_text(value as InputEvent)]
if value.has_method("_to_string"):
return "[color=%s]<%s>[/color]" % [VALUE_COLOR, str(value)]
return "[color=%s]<%s>[/color]" % [VALUE_COLOR, value.get_class()]
Expand Down Expand Up @@ -364,7 +364,7 @@ static func error_has_length(current :Variant, expected: int, compare_operator :

# - ArrayAssert specific messgaes ---------------------------------------------------

static func error_arr_contains(current :Variant, expected :Array, not_expect :Array, not_found :Array, by_reference :bool) -> String:
static func error_arr_contains(current: Variant, expected: Variant, not_expect: Variant, not_found: Variant, by_reference: bool) -> String:
var failure_message := "Expecting contains SAME elements:" if by_reference else "Expecting contains elements:"
var error := "%s\n %s\n do contains (in any order)\n %s" % [
_error(failure_message), _colored_value(current), _colored_value(expected)]
Expand All @@ -377,16 +377,16 @@ static func error_arr_contains(current :Variant, expected :Array, not_expect :Ar


static func error_arr_contains_exactly(
current :Variant,
expected :Variant,
not_expect :Variant,
not_found :Variant, compare_mode :GdObjects.COMPARE_MODE) -> String:
current: Variant,
expected: Variant,
not_expect: Variant,
not_found: Variant, compare_mode: GdObjects.COMPARE_MODE) -> String:
var failure_message := (
"Expecting contains exactly elements:" if compare_mode == GdObjects.COMPARE_MODE.PARAMETER_DEEP_TEST
else "Expecting contains SAME exactly elements:"
)
if not_expect.is_empty() and not_found.is_empty():
var diff := _find_first_diff(current, expected)
var diff := _find_first_diff(current as Array, expected as Array)
return "%s\n %s\n do contains (in same order)\n %s\n but has different order %s" % [
_error(failure_message), _colored_value(current), _colored_value(expected), diff]

Expand All @@ -401,11 +401,11 @@ static func error_arr_contains_exactly(


static func error_arr_contains_exactly_in_any_order(
current :Variant,
expected :Array,
not_expect :Array,
not_found :Array,
compare_mode :GdObjects.COMPARE_MODE) -> String:
current: Variant,
expected: Variant,
not_expect: Variant,
not_found: Variant,
compare_mode: GdObjects.COMPARE_MODE) -> String:

var failure_message := (
"Expecting contains exactly elements:" if compare_mode == GdObjects.COMPARE_MODE.PARAMETER_DEEP_TEST
Expand All @@ -421,7 +421,7 @@ static func error_arr_contains_exactly_in_any_order(
return error


static func error_arr_not_contains(current :Array, expected :Array, found :Array, compare_mode :GdObjects.COMPARE_MODE) -> String:
static func error_arr_not_contains(current: Variant, expected: Variant, found: Variant, compare_mode: GdObjects.COMPARE_MODE) -> String:
var failure_message := "Expecting:" if compare_mode == GdObjects.COMPARE_MODE.PARAMETER_DEEP_TEST else "Expecting SAME:"
var error := "%s\n %s\n do not contains\n %s" % [
_error(failure_message), _colored_value(current), _colored_value(expected)]
Expand Down Expand Up @@ -545,18 +545,18 @@ static func result_message(result :GdUnitResult) -> String:
# - Spy|Mock specific errors ----------------------------------------------------
static func error_no_more_interactions(summary :Dictionary) -> String:
var interactions := PackedStringArray()
for args :Variant in summary.keys():
for args :Array in summary.keys():
var times :int = summary[args]
interactions.append(_format_arguments(args, times))
return "%s\n%s\n%s" % [_error("Expecting no more interactions!"), _error("But found interactions on:"), "\n".join(interactions)]


static func error_validate_interactions(current_interactions :Dictionary, expected_interactions :Dictionary) -> String:
static func error_validate_interactions(current_interactions: Dictionary, expected_interactions: Dictionary) -> String:
var interactions := PackedStringArray()
for args :Variant in current_interactions.keys():
var times :int = current_interactions[args]
for args: Array in current_interactions.keys():
var times: int = current_interactions[args]
interactions.append(_format_arguments(args, times))
var expected_interaction := _format_arguments(expected_interactions.keys()[0], expected_interactions.values()[0])
var expected_interaction := _format_arguments(expected_interactions.keys()[0] as Array, expected_interactions.values()[0] as int)
return "%s\n%s\n%s\n%s" % [
_error("Expecting interaction on:"), expected_interaction, _error("But found interactions on:"), "\n".join(interactions)]

Expand All @@ -578,7 +578,7 @@ static func _to_typed_args(args :Array) -> PackedStringArray:

static func _format_arg(arg :Variant) -> String:
if arg is InputEvent:
return input_event_as_text(arg)
return input_event_as_text(arg as InputEvent)
return str(arg)


Expand Down
Loading