diff options
Diffstat (limited to 'modules/gdscript/tests/scripts/runtime/features')
40 files changed, 432 insertions, 16 deletions
diff --git a/modules/gdscript/tests/scripts/runtime/features/argument_count.gd b/modules/gdscript/tests/scripts/runtime/features/argument_count.gd new file mode 100644 index 0000000000..104489cfe6 --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/argument_count.gd @@ -0,0 +1,102 @@ +extends Node + +func my_func_1(_foo, _bar): + pass + +func my_func_2(_foo, _bar, _baz): + pass + +static func my_static_func_1(_foo, _bar): + pass + +static func my_static_func_2(_foo, _bar, _baz): + pass + +@rpc +func my_rpc_func_1(_foo, _bar): + pass + +@rpc +func my_rpc_func_2(_foo, _bar, _baz): + pass + +func test(): + # Test built-in methods. + var builtin_callable_1 : Callable = add_to_group + print(builtin_callable_1.get_argument_count()) # Should print 2. + var builtin_callable_2 : Callable = find_child + print(builtin_callable_2.get_argument_count()) # Should print 3. + + # Test built-in vararg methods. + var builtin_vararg_callable_1 : Callable = call_thread_safe + print(builtin_vararg_callable_1.get_argument_count()) # Should print 1. + var builtin_vararg_callable_2 : Callable = rpc_id + print(builtin_vararg_callable_2.get_argument_count()) # Should print 2. + + # Test plain methods. + var callable_1 : Callable = my_func_1 + print(callable_1.get_argument_count()) # Should print 2. + var callable_2 : Callable = my_func_2 + print(callable_2.get_argument_count()) # Should print 3. + + # Test static methods. + var static_callable_1 : Callable = my_static_func_1 + print(static_callable_1.get_argument_count()) # Should print 2. + var static_callable_2 : Callable = my_static_func_2 + print(static_callable_2.get_argument_count()) # Should print 3. + + # Test rpc methods. + var rpc_callable_1 : Callable = my_rpc_func_1 + print(rpc_callable_1.get_argument_count()) # Should print 2. + var rpc_callable_2 : Callable = my_rpc_func_2 + print(rpc_callable_2.get_argument_count()) # Should print 3. + + # Test lambdas. + var lambda_callable_1 : Callable = func(_foo, _bar): pass + print(lambda_callable_1.get_argument_count()) # Should print 2. + var lambda_callable_2 : Callable = func(_foo, _bar, _baz): pass + print(lambda_callable_2.get_argument_count()) # Should print 3. + + # Test lambdas with self. + var lambda_self_callable_1 : Callable = func(_foo, _bar): return self + print(lambda_self_callable_1.get_argument_count()) # Should print 2. + var lambda_self_callable_2 : Callable = func(_foo, _bar, _baz): return self + print(lambda_self_callable_2.get_argument_count()) # Should print 3. + + # Test bind. + var bind_callable_1 : Callable = my_func_2.bind(1) + print(bind_callable_1.get_argument_count()) # Should print 2. + var bind_callable_2 : Callable = my_func_2.bind(1, 2) + print(bind_callable_2.get_argument_count()) # Should print 1. + + # Test unbind. + var unbind_callable_1 : Callable = my_func_2.unbind(1) + print(unbind_callable_1.get_argument_count()) # Should print 4. + var unbind_callable_2 : Callable = my_func_2.unbind(2) + print(unbind_callable_2.get_argument_count()) # Should print 5. + + # Test variant callables. + var string_tmp := String() + var variant_callable_1 : Callable = string_tmp.replace + print(variant_callable_1.get_argument_count()) # Should print 2. + var variant_callable_2 : Callable = string_tmp.rsplit + print(variant_callable_2.get_argument_count()) # Should print 3. + + # Test variant vararg callables. + var callable_tmp := Callable() + var variant_vararg_callable_1 : Callable = callable_tmp.call + print(variant_vararg_callable_1.get_argument_count()) # Should print 0. + var variant_vararg_callable_2 : Callable = callable_tmp.rpc_id + print(variant_vararg_callable_2.get_argument_count()) # Should print 1. + + # Test global methods. + var global_callable_1 = is_equal_approx + print(global_callable_1.get_argument_count()) # Should print 2. + var global_callable_2 = inverse_lerp + print(global_callable_2.get_argument_count()) # Should print 3. + + # Test GDScript methods. + var gdscript_callable_1 = char + print(gdscript_callable_1.get_argument_count()) # Should print 1. + var gdscript_callable_2 = is_instance_of + print(gdscript_callable_2.get_argument_count()) # Should print 2. diff --git a/modules/gdscript/tests/scripts/runtime/features/argument_count.out b/modules/gdscript/tests/scripts/runtime/features/argument_count.out new file mode 100644 index 0000000000..42c4ece37d --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/argument_count.out @@ -0,0 +1,27 @@ +GDTEST_OK +2 +3 +1 +2 +2 +3 +2 +3 +2 +3 +2 +3 +2 +3 +2 +1 +4 +5 +2 +3 +0 +1 +2 +3 +1 +2 diff --git a/modules/gdscript/tests/scripts/runtime/features/await_signal_with_parameters.gd b/modules/gdscript/tests/scripts/runtime/features/await_signal_with_parameters.gd new file mode 100644 index 0000000000..ff0001676d --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/await_signal_with_parameters.gd @@ -0,0 +1,25 @@ +signal no_parameters() +signal one_parameter(number) +signal two_parameters(number1, number2) + +func await_no_parameters(): + var result = await no_parameters + print(result) + +func await_one_parameter(): + var result = await one_parameter + print(result) + +func await_two_parameters(): + var result = await two_parameters + print(result) + +func test(): + await_no_parameters() + no_parameters.emit() + + await_one_parameter() + one_parameter.emit(1) + + await_two_parameters() + two_parameters.emit(1, 2) diff --git a/modules/gdscript/tests/scripts/runtime/features/await_signal_with_parameters.out b/modules/gdscript/tests/scripts/runtime/features/await_signal_with_parameters.out new file mode 100644 index 0000000000..9e203c601c --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/await_signal_with_parameters.out @@ -0,0 +1,4 @@ +GDTEST_OK +<null> +1 +[1, 2] diff --git a/modules/gdscript/tests/scripts/runtime/features/builtin_method_as_callable.gd b/modules/gdscript/tests/scripts/runtime/features/builtin_method_as_callable.gd index e4016c0119..cb5ea827f6 100644 --- a/modules/gdscript/tests/scripts/runtime/features/builtin_method_as_callable.gd +++ b/modules/gdscript/tests/scripts/runtime/features/builtin_method_as_callable.gd @@ -1,6 +1,13 @@ func test(): var array: Array = [1, 2, 3] print(array) - var callable: Callable = array.clear - callable.call() + var array_clear: Callable = array.clear + array_clear.call() print(array) + + var dictionary: Dictionary = {1: 2, 3: 4} + print(dictionary) + # `dictionary.clear` is treated as a key. + var dictionary_clear := Callable.create(dictionary, &"clear") + dictionary_clear.call() + print(dictionary) diff --git a/modules/gdscript/tests/scripts/runtime/features/builtin_method_as_callable.out b/modules/gdscript/tests/scripts/runtime/features/builtin_method_as_callable.out index c4182b38e9..c12984ca37 100644 --- a/modules/gdscript/tests/scripts/runtime/features/builtin_method_as_callable.out +++ b/modules/gdscript/tests/scripts/runtime/features/builtin_method_as_callable.out @@ -1,3 +1,5 @@ GDTEST_OK [1, 2, 3] [] +{ 1: 2, 3: 4 } +{ } diff --git a/modules/gdscript/tests/scripts/runtime/features/call_native_static_method_validated.gd b/modules/gdscript/tests/scripts/runtime/features/call_native_static_method_validated.gd new file mode 100644 index 0000000000..a1a9e350b0 --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/call_native_static_method_validated.gd @@ -0,0 +1,6 @@ +func test(): + # Validated native static call with return value. + print(FileAccess.file_exists("some_file")) + + # Validated native static call without return value. + Node.print_orphan_nodes() diff --git a/modules/gdscript/tests/scripts/runtime/features/call_native_static_method_validated.out b/modules/gdscript/tests/scripts/runtime/features/call_native_static_method_validated.out new file mode 100644 index 0000000000..44302c8137 --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/call_native_static_method_validated.out @@ -0,0 +1,2 @@ +GDTEST_OK +false diff --git a/modules/gdscript/tests/scripts/runtime/features/compare-builtin-equals-null.gd b/modules/gdscript/tests/scripts/runtime/features/compare_builtin_equals_null.gd index 809d0d28a9..5d8dafc4a1 100644 --- a/modules/gdscript/tests/scripts/runtime/features/compare-builtin-equals-null.gd +++ b/modules/gdscript/tests/scripts/runtime/features/compare_builtin_equals_null.gd @@ -140,3 +140,7 @@ func test(): # PackedColorArray value = PackedColorArray() print(value == null) + + # PackedVector4Array + value = PackedVector4Array() + print(value == null) diff --git a/modules/gdscript/tests/scripts/runtime/features/compare-null-equals-builtin.out b/modules/gdscript/tests/scripts/runtime/features/compare_builtin_equals_null.out index 639f6027b9..e0e222eccc 100644 --- a/modules/gdscript/tests/scripts/runtime/features/compare-null-equals-builtin.out +++ b/modules/gdscript/tests/scripts/runtime/features/compare_builtin_equals_null.out @@ -33,3 +33,5 @@ false false false false +false +false diff --git a/modules/gdscript/tests/scripts/runtime/features/compare-builtin-not-equals-null.gd b/modules/gdscript/tests/scripts/runtime/features/compare_builtin_not_equals_null.gd index f46afb0f18..88286ede03 100644 --- a/modules/gdscript/tests/scripts/runtime/features/compare-builtin-not-equals-null.gd +++ b/modules/gdscript/tests/scripts/runtime/features/compare_builtin_not_equals_null.gd @@ -140,3 +140,7 @@ func test(): # PackedColorArray value = PackedColorArray() print(value != null) + + # PackedVector4Array + value = PackedVector4Array() + print(value != null) diff --git a/modules/gdscript/tests/scripts/runtime/features/compare-null-not-equals-builtin.out b/modules/gdscript/tests/scripts/runtime/features/compare_builtin_not_equals_null.out index d1e332afba..f6e72aedd5 100644 --- a/modules/gdscript/tests/scripts/runtime/features/compare-null-not-equals-builtin.out +++ b/modules/gdscript/tests/scripts/runtime/features/compare_builtin_not_equals_null.out @@ -33,3 +33,5 @@ true true true true +true +true diff --git a/modules/gdscript/tests/scripts/runtime/features/compare-null-equals-builtin.gd b/modules/gdscript/tests/scripts/runtime/features/compare_null_equals_builtin.gd index 7649062fda..6ca1b3e490 100644 --- a/modules/gdscript/tests/scripts/runtime/features/compare-null-equals-builtin.gd +++ b/modules/gdscript/tests/scripts/runtime/features/compare_null_equals_builtin.gd @@ -136,3 +136,7 @@ func test(): # PackedColorArray value = PackedColorArray() print(null == value) + + # PackedVector4Array + value = PackedVector4Array() + print(null == value) diff --git a/modules/gdscript/tests/scripts/runtime/features/compare-builtin-equals-null.out b/modules/gdscript/tests/scripts/runtime/features/compare_null_equals_builtin.out index 27423ab8e7..27423ab8e7 100644 --- a/modules/gdscript/tests/scripts/runtime/features/compare-builtin-equals-null.out +++ b/modules/gdscript/tests/scripts/runtime/features/compare_null_equals_builtin.out diff --git a/modules/gdscript/tests/scripts/runtime/features/compare-null-not-equals-builtin.gd b/modules/gdscript/tests/scripts/runtime/features/compare_null_not_equals_builtin.gd index 8d5f9df1b8..d7addfa390 100644 --- a/modules/gdscript/tests/scripts/runtime/features/compare-null-not-equals-builtin.gd +++ b/modules/gdscript/tests/scripts/runtime/features/compare_null_not_equals_builtin.gd @@ -136,3 +136,7 @@ func test(): # PackedColorArray value = PackedColorArray() print(null != value) + + # PackedVector4Array + value = PackedVector4Array() + print(null != value) diff --git a/modules/gdscript/tests/scripts/runtime/features/compare-builtin-not-equals-null.out b/modules/gdscript/tests/scripts/runtime/features/compare_null_not_equals_builtin.out index a11c47854a..a11c47854a 100644 --- a/modules/gdscript/tests/scripts/runtime/features/compare-builtin-not-equals-null.out +++ b/modules/gdscript/tests/scripts/runtime/features/compare_null_not_equals_builtin.out diff --git a/modules/gdscript/tests/scripts/runtime/features/emit_after_await.gd b/modules/gdscript/tests/scripts/runtime/features/emit_after_await.gd new file mode 100644 index 0000000000..21fd526acc --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/emit_after_await.gd @@ -0,0 +1,12 @@ +# https://github.com/godotengine/godot/issues/89439 +extends Node + +signal my_signal + +func async_func(): + await my_signal + my_signal.emit() + +func test(): + async_func() + my_signal.emit() diff --git a/modules/gdscript/tests/scripts/runtime/features/emit_after_await.out b/modules/gdscript/tests/scripts/runtime/features/emit_after_await.out new file mode 100644 index 0000000000..d73c5eb7cd --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/emit_after_await.out @@ -0,0 +1 @@ +GDTEST_OK diff --git a/modules/gdscript/tests/scripts/runtime/features/emit_one_shot_is_non_recursive.gd b/modules/gdscript/tests/scripts/runtime/features/emit_one_shot_is_non_recursive.gd new file mode 100644 index 0000000000..5c328dcfcd --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/emit_one_shot_is_non_recursive.gd @@ -0,0 +1,22 @@ +# https://github.com/godotengine/godot/issues/89439 + +signal my_signal + +func foo(): + print("Foo") + my_signal.emit() + +func bar(): + print("Bar") + +func baz(): + print("Baz") + +func test(): + @warning_ignore("return_value_discarded") + my_signal.connect(foo, CONNECT_ONE_SHOT) + @warning_ignore("return_value_discarded") + my_signal.connect(bar, CONNECT_ONE_SHOT) + @warning_ignore("return_value_discarded") + my_signal.connect(baz) + my_signal.emit() diff --git a/modules/gdscript/tests/scripts/runtime/features/emit_one_shot_is_non_recursive.out b/modules/gdscript/tests/scripts/runtime/features/emit_one_shot_is_non_recursive.out new file mode 100644 index 0000000000..3399e08878 --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/emit_one_shot_is_non_recursive.out @@ -0,0 +1,5 @@ +GDTEST_OK +Foo +Baz +Bar +Baz diff --git a/modules/gdscript/tests/scripts/runtime/features/export_group_no_name_conflict_with_properties.gd b/modules/gdscript/tests/scripts/runtime/features/export_group_no_name_conflict_with_properties.gd index e46f24cc5f..0133d7fcfc 100644 --- a/modules/gdscript/tests/scripts/runtime/features/export_group_no_name_conflict_with_properties.gd +++ b/modules/gdscript/tests/scripts/runtime/features/export_group_no_name_conflict_with_properties.gd @@ -1,17 +1,17 @@ -extends RefCounted # TODO: Fix standalone annotations parsing. +const Utils = preload("../../utils.notest.gd") # GH-73843 @export_group("Resource") # GH-78252 -@export var prop_1: int -@export_category("prop_1") -@export var prop_2: int +@export var test_1: int +@export_category("test_1") +@export var test_2: int func test(): var resource := Resource.new() prints("Not shadowed:", resource.get_class()) for property in get_property_list(): - if property.name in ["prop_1", "prop_2"]: - print(property) + if str(property.name).begins_with("test_"): + Utils.print_property_extended_info(property, self) diff --git a/modules/gdscript/tests/scripts/runtime/features/export_group_no_name_conflict_with_properties.out b/modules/gdscript/tests/scripts/runtime/features/export_group_no_name_conflict_with_properties.out index 96ae84e986..a1e7233078 100644 --- a/modules/gdscript/tests/scripts/runtime/features/export_group_no_name_conflict_with_properties.out +++ b/modules/gdscript/tests/scripts/runtime/features/export_group_no_name_conflict_with_properties.out @@ -1,5 +1,8 @@ GDTEST_OK Not shadowed: Resource -{ "name": "prop_1", "class_name": &"", "type": 2, "hint": 0, "hint_string": "int", "usage": 4102 } -{ "name": "prop_1", "class_name": &"", "type": 0, "hint": 0, "hint_string": "", "usage": 128 } -{ "name": "prop_2", "class_name": &"", "type": 2, "hint": 0, "hint_string": "int", "usage": 4102 } +var test_1: int = 0 + hint=NONE hint_string="" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" +@export_category("test_1") + hint=NONE hint_string="" usage=CATEGORY class_name=&"" +var test_2: int = 0 + hint=NONE hint_string="" usage=DEFAULT|SCRIPT_VARIABLE class_name=&"" diff --git a/modules/gdscript/tests/scripts/runtime/features/member_info.gd b/modules/gdscript/tests/scripts/runtime/features/member_info.gd index 805ea42455..42b29eee43 100644 --- a/modules/gdscript/tests/scripts/runtime/features/member_info.gd +++ b/modules/gdscript/tests/scripts/runtime/features/member_info.gd @@ -23,6 +23,7 @@ var test_var_hard_int: int var test_var_hard_variant_type: Variant.Type @export var test_var_hard_variant_type_exported: Variant.Type var test_var_hard_node_process_mode: Node.ProcessMode +@warning_ignore("enum_variable_without_default") var test_var_hard_my_enum: MyEnum var test_var_hard_array: Array var test_var_hard_array_int: Array[int] @@ -56,11 +57,21 @@ signal test_signal_6(a: Resource, b: Array[Resource]) signal test_signal_7(a: TestMemberInfo, b: Array[TestMemberInfo]) signal test_signal_8(a: MyClass, b: Array[MyClass]) +func no_exec(): + test_signal_1.emit() + test_signal_2.emit() + test_signal_3.emit() + test_signal_4.emit() + test_signal_5.emit() + test_signal_6.emit() + test_signal_7.emit() + test_signal_8.emit() + func test(): var script: Script = get_script() for property in script.get_property_list(): if str(property.name).begins_with("test_"): - print(Utils.get_property_signature(property, true)) + print(Utils.get_property_signature(property, null, true)) for property in get_property_list(): if str(property.name).begins_with("test_"): print(Utils.get_property_signature(property)) diff --git a/modules/gdscript/tests/scripts/runtime/features/member_info.out b/modules/gdscript/tests/scripts/runtime/features/member_info.out index 3a91507da9..7c826ac05a 100644 --- a/modules/gdscript/tests/scripts/runtime/features/member_info.out +++ b/modules/gdscript/tests/scripts/runtime/features/member_info.out @@ -6,13 +6,13 @@ static var test_static_var_hard_int: int var test_var_untyped: Variant var test_var_weak_null: Variant var test_var_weak_int: Variant -@export var test_var_weak_int_exported: int +var test_var_weak_int_exported: int var test_var_weak_variant_type: Variant -@export var test_var_weak_variant_type_exported: Variant.Type +var test_var_weak_variant_type_exported: Variant.Type var test_var_hard_variant: Variant var test_var_hard_int: int var test_var_hard_variant_type: Variant.Type -@export var test_var_hard_variant_type_exported: Variant.Type +var test_var_hard_variant_type_exported: Variant.Type var test_var_hard_node_process_mode: Node.ProcessMode var test_var_hard_my_enum: TestMemberInfo.MyEnum var test_var_hard_array: Array diff --git a/modules/gdscript/tests/scripts/runtime/features/member_info_inheritance.gd b/modules/gdscript/tests/scripts/runtime/features/member_info_inheritance.gd index d0cbeeab85..ee5c1e1267 100644 --- a/modules/gdscript/tests/scripts/runtime/features/member_info_inheritance.gd +++ b/modules/gdscript/tests/scripts/runtime/features/member_info_inheritance.gd @@ -11,7 +11,9 @@ class A: static func test_static_func_a2(): pass func test_func_a1(): pass func test_func_a2(): pass + @warning_ignore("unused_signal") signal test_signal_a1() + @warning_ignore("unused_signal") signal test_signal_a2() class B extends A: @@ -23,14 +25,16 @@ class B extends A: static func test_static_func_b2(): pass func test_func_b1(): pass func test_func_b2(): pass + @warning_ignore("unused_signal") signal test_signal_b1() + @warning_ignore("unused_signal") signal test_signal_b2() func test(): var b := B.new() for property in (B as GDScript).get_property_list(): if str(property.name).begins_with("test_"): - print(Utils.get_property_signature(property, true)) + print(Utils.get_property_signature(property, null, true)) print("---") for property in b.get_property_list(): if str(property.name).begins_with("test_"): diff --git a/modules/gdscript/tests/scripts/runtime/features/object_iterators.gd b/modules/gdscript/tests/scripts/runtime/features/object_iterators.gd new file mode 100644 index 0000000000..6fe28c6f78 --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/object_iterators.gd @@ -0,0 +1,49 @@ +class MyIterator: + var count: int + + func _init(p_count: int) -> void: + count = p_count + + func _iter_init(arg: Array) -> bool: + prints("_iter_init", arg) + arg[0] = 0 + return arg[0] < count + + func _iter_next(arg: Array) -> bool: + prints("_iter_next", arg) + arg[0] += 1 + return arg[0] < count + + func _iter_get(arg: Variant) -> Variant: + prints("_iter_get", arg) + return arg + +func test(): + var container := PackedDataContainer.new() + var _err := container.pack([{ + id = 123, + node_path = ^"/some/path", + data = PackedByteArray(), + }]) + + for ref: PackedDataContainerRef in container: + for key: String in ref: + print(key) + + print("===") + + for ref: Variant in container: + for key: String in ref: + print(key) + + print("===") + + var hard_custom := MyIterator.new(3) + for x in hard_custom: + print(x) + + print("===") + + var weak_custom: Variant = MyIterator.new(3) + for x in weak_custom: + print(x) diff --git a/modules/gdscript/tests/scripts/runtime/features/object_iterators.out b/modules/gdscript/tests/scripts/runtime/features/object_iterators.out new file mode 100644 index 0000000000..942a2c9dd8 --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/object_iterators.out @@ -0,0 +1,30 @@ +GDTEST_OK +id +node_path +data +=== +id +node_path +data +=== +_iter_init [<null>] +_iter_get 0 +0 +_iter_next [0] +_iter_get 1 +1 +_iter_next [1] +_iter_get 2 +2 +_iter_next [2] +=== +_iter_init [<null>] +_iter_get 0 +0 +_iter_next [0] +_iter_get 1 +1 +_iter_next [1] +_iter_get 2 +2 +_iter_next [2] diff --git a/modules/gdscript/tests/scripts/runtime/features/onready_base_before_subclass.gd b/modules/gdscript/tests/scripts/runtime/features/onready_base_before_subclass.gd new file mode 100644 index 0000000000..99156adb28 --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/onready_base_before_subclass.gd @@ -0,0 +1,18 @@ +#GH-63329 +class A extends Node: + @onready var a := get_value("a") + + func get_value(var_name: String) -> String: + print(var_name) + return var_name + +class B extends A: + @onready var b := get_value("b") + + func _ready(): + pass + +func test(): + var node := B.new() + node._ready() + node.free() diff --git a/modules/gdscript/tests/scripts/runtime/features/onready_base_before_subclass.out b/modules/gdscript/tests/scripts/runtime/features/onready_base_before_subclass.out new file mode 100644 index 0000000000..b417ce67ca --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/onready_base_before_subclass.out @@ -0,0 +1,3 @@ +GDTEST_OK +a +b diff --git a/modules/gdscript/tests/scripts/runtime/features/reset_local_var_on exit_block.gd b/modules/gdscript/tests/scripts/runtime/features/reset_local_var_on_exit_block.gd index c774ebf83c..c774ebf83c 100644 --- a/modules/gdscript/tests/scripts/runtime/features/reset_local_var_on exit_block.gd +++ b/modules/gdscript/tests/scripts/runtime/features/reset_local_var_on_exit_block.gd diff --git a/modules/gdscript/tests/scripts/runtime/features/reset_local_var_on exit_block.out b/modules/gdscript/tests/scripts/runtime/features/reset_local_var_on_exit_block.out index 04b4638adf..04b4638adf 100644 --- a/modules/gdscript/tests/scripts/runtime/features/reset_local_var_on exit_block.out +++ b/modules/gdscript/tests/scripts/runtime/features/reset_local_var_on_exit_block.out diff --git a/modules/gdscript/tests/scripts/runtime/features/reset_unassigned_variables_in_loops.gd b/modules/gdscript/tests/scripts/runtime/features/reset_unassigned_variables_in_loops.gd index c45f8dce48..2bd5362f2a 100644 --- a/modules/gdscript/tests/scripts/runtime/features/reset_unassigned_variables_in_loops.gd +++ b/modules/gdscript/tests/scripts/runtime/features/reset_unassigned_variables_in_loops.gd @@ -7,6 +7,7 @@ func test(): var b if true: var c + @warning_ignore("unassigned_variable") prints("Begin:", i, a, b, c) a = 1 b = 1 @@ -20,6 +21,7 @@ func test(): var b if true: var c + @warning_ignore("unassigned_variable") prints("Begin:", j, a, b, c) a = 1 b = 1 diff --git a/modules/gdscript/tests/scripts/runtime/features/reset_uninit_local_vars.gd b/modules/gdscript/tests/scripts/runtime/features/reset_uninit_local_vars.gd new file mode 100644 index 0000000000..ef2d9a1d60 --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/reset_uninit_local_vars.gd @@ -0,0 +1,21 @@ +# GH-89958 + +func test(): + if true: + @warning_ignore("unused_variable") + var a = 1 + @warning_ignore("unused_variable") + var b := 1 + @warning_ignore("unused_variable") + var c := 1 + + if true: + var a + @warning_ignore("unassigned_variable") + print(a) + var b + @warning_ignore("unassigned_variable") + print(b) + var c: Object + @warning_ignore("unassigned_variable") + print(c) diff --git a/modules/gdscript/tests/scripts/runtime/features/reset_uninit_local_vars.out b/modules/gdscript/tests/scripts/runtime/features/reset_uninit_local_vars.out new file mode 100644 index 0000000000..279ea2d3b1 --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/reset_uninit_local_vars.out @@ -0,0 +1,4 @@ +GDTEST_OK +<null> +<null> +<null> diff --git a/modules/gdscript/tests/scripts/runtime/features/standalone-calls-do-not-write-to-nil.gd b/modules/gdscript/tests/scripts/runtime/features/standalone_calls_do_not_write_to_nil.gd index 691b611574..691b611574 100644 --- a/modules/gdscript/tests/scripts/runtime/features/standalone-calls-do-not-write-to-nil.gd +++ b/modules/gdscript/tests/scripts/runtime/features/standalone_calls_do_not_write_to_nil.gd diff --git a/modules/gdscript/tests/scripts/runtime/features/standalone-calls-do-not-write-to-nil.out b/modules/gdscript/tests/scripts/runtime/features/standalone_calls_do_not_write_to_nil.out index 5bc3dcf2db..5bc3dcf2db 100644 --- a/modules/gdscript/tests/scripts/runtime/features/standalone-calls-do-not-write-to-nil.out +++ b/modules/gdscript/tests/scripts/runtime/features/standalone_calls_do_not_write_to_nil.out diff --git a/modules/gdscript/tests/scripts/runtime/features/stringify.gd b/modules/gdscript/tests/scripts/runtime/features/stringify.gd index 0dbb252b0e..8579baf876 100644 --- a/modules/gdscript/tests/scripts/runtime/features/stringify.gd +++ b/modules/gdscript/tests/scripts/runtime/features/stringify.gd @@ -40,3 +40,4 @@ func test(): print(PackedVector2Array([Vector2.ONE, Vector2.ZERO])) print(PackedVector3Array([Vector3.ONE, Vector3.ZERO])) print(PackedColorArray([Color.RED, Color.BLUE, Color.GREEN])) + print(PackedVector4Array([Vector4.ONE, Vector4.ZERO])) diff --git a/modules/gdscript/tests/scripts/runtime/features/stringify.out b/modules/gdscript/tests/scripts/runtime/features/stringify.out index 1f33de00cc..7833b6e213 100644 --- a/modules/gdscript/tests/scripts/runtime/features/stringify.out +++ b/modules/gdscript/tests/scripts/runtime/features/stringify.out @@ -32,3 +32,4 @@ Node::[signal]property_list_changed [(1, 1), (0, 0)] [(1, 1, 1), (0, 0, 0)] [(1, 0, 0, 1), (0, 0, 1, 1), (0, 1, 0, 1)] +[(1, 1, 1, 1), (0, 0, 0, 0)] diff --git a/modules/gdscript/tests/scripts/runtime/features/type_casting.gd b/modules/gdscript/tests/scripts/runtime/features/type_casting.gd new file mode 100644 index 0000000000..c63ea16c32 --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/type_casting.gd @@ -0,0 +1,24 @@ +func print_value(value: Variant) -> void: + if value is Object: + @warning_ignore("unsafe_method_access") + print("<%s>" % value.get_class()) + else: + print(var_to_str(value)) + +func test(): + var int_value := 1 + print_value(int_value as Variant) + print_value(int_value as int) + print_value(int_value as float) + + var node_value := Node.new() + print_value(node_value as Variant) + print_value(node_value as Object) + print_value(node_value as Node) + print_value(node_value as Node2D) + node_value.free() + + var null_value = null + print_value(null_value as Variant) + @warning_ignore("unsafe_cast") + print_value(null_value as Node) diff --git a/modules/gdscript/tests/scripts/runtime/features/type_casting.out b/modules/gdscript/tests/scripts/runtime/features/type_casting.out new file mode 100644 index 0000000000..7da5a4c0a4 --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/type_casting.out @@ -0,0 +1,10 @@ +GDTEST_OK +1 +1 +1.0 +<Node> +<Node> +<Node> +null +null +null |