diff options
author | Dmitrii Maganov <vonagam@gmail.com> | 2022-12-22 22:43:36 +0200 |
---|---|---|
committer | Dmitrii Maganov <vonagam@gmail.com> | 2023-01-06 01:10:04 +0200 |
commit | a1d06749f18c3f47c6443ece2ec625d8ee5f1761 (patch) | |
tree | 542a407dd9c60c76c3f2acf1a76f06cf44b1dfde /modules/gdscript/tests/scripts | |
parent | 1d14c054a12dacdc193b589e4afb0ef319ee2aae (diff) |
Unify typing of variables, constants and parameters in GDScript
Diffstat (limited to 'modules/gdscript/tests/scripts')
10 files changed, 57 insertions, 4 deletions
diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_class_var_init_with_wrong_enum_type.out b/modules/gdscript/tests/scripts/analyzer/errors/enum_class_var_init_with_wrong_enum_type.out index b1710c798d..6fa2682d0a 100644 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_class_var_init_with_wrong_enum_type.out +++ b/modules/gdscript/tests/scripts/analyzer/errors/enum_class_var_init_with_wrong_enum_type.out @@ -1,2 +1,2 @@ GDTEST_ANALYZER_ERROR -Value of type "MyOtherEnum (enum)" cannot be assigned to a variable of type "MyEnum (enum)". +Cannot assign a value of type MyOtherEnum (enum) to variable "class_var" with specified type MyEnum (enum). diff --git a/modules/gdscript/tests/scripts/analyzer/errors/enum_local_var_init_with_wrong_enum_type.out b/modules/gdscript/tests/scripts/analyzer/errors/enum_local_var_init_with_wrong_enum_type.out index b1710c798d..07fb19f1ff 100644 --- a/modules/gdscript/tests/scripts/analyzer/errors/enum_local_var_init_with_wrong_enum_type.out +++ b/modules/gdscript/tests/scripts/analyzer/errors/enum_local_var_init_with_wrong_enum_type.out @@ -1,2 +1,2 @@ GDTEST_ANALYZER_ERROR -Value of type "MyOtherEnum (enum)" cannot be assigned to a variable of type "MyEnum (enum)". +Cannot assign a value of type MyOtherEnum (enum) to variable "local_var" with specified type MyEnum (enum). diff --git a/modules/gdscript/tests/scripts/analyzer/errors/setter_parameter_uses_property_type.out b/modules/gdscript/tests/scripts/analyzer/errors/setter_parameter_uses_property_type.out index 9eb2a42ccd..2857cd53c8 100644 --- a/modules/gdscript/tests/scripts/analyzer/errors/setter_parameter_uses_property_type.out +++ b/modules/gdscript/tests/scripts/analyzer/errors/setter_parameter_uses_property_type.out @@ -1,2 +1,2 @@ GDTEST_ANALYZER_ERROR -Value of type "int" cannot be assigned to a variable of type "String". +Cannot assign a value of type int to variable "x" with specified type String. diff --git a/modules/gdscript/tests/scripts/analyzer/features/default_arg_convertable.gd b/modules/gdscript/tests/scripts/analyzer/features/default_arg_convertable.gd new file mode 100644 index 0000000000..d0d04897e0 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/default_arg_convertable.gd @@ -0,0 +1,6 @@ +func check(arg: float = 3): + return typeof(arg) == typeof(3.0) + +func test(): + if check(): + print('ok') diff --git a/modules/gdscript/tests/scripts/analyzer/features/default_arg_convertable.out b/modules/gdscript/tests/scripts/analyzer/features/default_arg_convertable.out new file mode 100644 index 0000000000..1b47ed10dc --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/default_arg_convertable.out @@ -0,0 +1,2 @@ +GDTEST_OK +ok diff --git a/modules/gdscript/tests/scripts/analyzer/features/null_initializer.gd b/modules/gdscript/tests/scripts/analyzer/features/null_initializer.gd new file mode 100644 index 0000000000..5a413e2015 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/null_initializer.gd @@ -0,0 +1,32 @@ +func check(input: int) -> bool: + return input == 1 + +var recur = null +var prop = null + +func check_arg(arg = null) -> void: + if arg != null: + print(check(arg)) + +func check_recur() -> void: + if recur != null: + print(check(recur)) + else: + recur = 1 + check_recur() + +func test() -> void: + check_arg(1) + + check_recur() + + if prop == null: + set('prop', 1) + print(check(prop)) + set('prop', null) + + var loop = null + while loop != 2: + if loop != null: + print(check(loop)) + loop = 1 if loop == null else 2 diff --git a/modules/gdscript/tests/scripts/analyzer/features/null_initializer.out b/modules/gdscript/tests/scripts/analyzer/features/null_initializer.out new file mode 100644 index 0000000000..f9783e4362 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/null_initializer.out @@ -0,0 +1,5 @@ +GDTEST_OK +true +true +true +true diff --git a/modules/gdscript/tests/scripts/analyzer/features/weak_initializer.gd b/modules/gdscript/tests/scripts/analyzer/features/weak_initializer.gd new file mode 100644 index 0000000000..c5f3ccc59e --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/weak_initializer.gd @@ -0,0 +1,5 @@ +func test(): + var bar = 1 + var foo: float = bar + print(typeof(foo)) + print(foo is float) diff --git a/modules/gdscript/tests/scripts/analyzer/features/weak_initializer.out b/modules/gdscript/tests/scripts/analyzer/features/weak_initializer.out new file mode 100644 index 0000000000..5d798c1f24 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/weak_initializer.out @@ -0,0 +1,3 @@ +GDTEST_OK +3 +true diff --git a/modules/gdscript/tests/scripts/analyzer/typed_array_assignment.out b/modules/gdscript/tests/scripts/analyzer/typed_array_assignment.out index 26b6e13d4f..ad2e6558d7 100644 --- a/modules/gdscript/tests/scripts/analyzer/typed_array_assignment.out +++ b/modules/gdscript/tests/scripts/analyzer/typed_array_assignment.out @@ -1,2 +1,2 @@ GDTEST_ANALYZER_ERROR -Assigned value for constant "arr" has type Array[String] which is not compatible with defined type Array[int]. +Cannot assign a value of type Array[String] to constant "arr" with specified type Array[int]. |