Merge commit '1843c454bd' as 'engine'

This commit is contained in:
Sara Gerretsen 2026-04-28 14:58:19 +02:00
commit e7cc4cd72f
13965 changed files with 7502032 additions and 0 deletions

View file

@ -0,0 +1,5 @@
func test():
var array := [1, 2, 3]
array.set(4, 4)
var _value = array.get(4)
_value = array[4]

View file

@ -0,0 +1,4 @@
GDTEST_RUNTIME_ERROR
>> ERROR: Index p_index = 4 is out of bounds (p_instance->size() = 3).
>> ERROR: Index p_index = 4 is out of bounds (p_instance->size() = 3).
>> SCRIPT ERROR at runtime/errors/array_bad_index.gd:5 on test(): Out of bounds get index '4' (on base: 'Array')

View file

@ -0,0 +1,20 @@
class A extends Node:
pass
func subtest_native():
var x = Node.new()
x.free()
var _ok = x
var _bad: Node = x
print("end subtest_native")
func subtest_script():
var x = A.new()
x.free()
var _ok = x
var _bad: A = x
print("end subtest_script")
func test():
subtest_native()
subtest_script()

View file

@ -0,0 +1,3 @@
GDTEST_RUNTIME_ERROR
>> SCRIPT ERROR at runtime/errors/assign_freed_instance.gd:8 on subtest_native(): Trying to assign invalid previously freed instance.
>> SCRIPT ERROR at runtime/errors/assign_freed_instance.gd:15 on subtest_script(): Trying to assign invalid previously freed instance.

View file

@ -0,0 +1,13 @@
func subtest_attribute(state):
state.center_of_mass.x -= 1.0
print("end subtest_attribute")
func subtest_variable_index(state, prop):
state[prop].x = 1.0
print("end subtest_variable_index")
func test():
var state = PhysicsDirectBodyState3DExtension.new()
subtest_attribute(state)
subtest_variable_index(state, &"center_of_mass")
state.free()

View file

@ -0,0 +1,6 @@
GDTEST_RUNTIME_ERROR
~~ WARNING at line 11: (UNSAFE_CALL_ARGUMENT) The argument 1 of the function "subtest_attribute()" requires the subtype "Variant" but the supertype "Variant" was provided.
~~ WARNING at line 12: (UNSAFE_CALL_ARGUMENT) The argument 1 of the function "subtest_variable_index()" requires the subtype "Variant" but the supertype "Variant" was provided.
>> ERROR: Required virtual method PhysicsDirectBodyState3DExtension::_get_center_of_mass must be overridden before calling.
>> SCRIPT ERROR at runtime/errors/assign_to_read_only_property.gd:2 on subtest_attribute(): Cannot set value into property "center_of_mass" (on base "PhysicsDirectBodyState3DExtension") because it is read-only.
>> SCRIPT ERROR at runtime/errors/assign_to_read_only_property.gd:6 on subtest_variable_index(): Cannot set value into property "center_of_mass" (on base "PhysicsDirectBodyState3DExtension") because it is read-only.

View file

@ -0,0 +1,8 @@
var weakling = 'not float'
func weak(x: float = weakling):
print(x)
print('typeof x is', typeof(x))
func test():
print(typeof(weak()))
print('not ok')

View file

@ -0,0 +1,4 @@
GDTEST_RUNTIME_ERROR
>> SCRIPT ERROR at runtime/errors/bad_conversion_for_default_parameter.gd:2 on weak(): Trying to assign value of type 'String' to a variable of type 'float'.
0
not ok

View file

@ -0,0 +1,7 @@
#debug-only
func test():
var node := Node.new()
var inside_tree = node.is_inside_tree
node.free()
inside_tree.call()
print(node)

View file

@ -0,0 +1,2 @@
GDTEST_RUNTIME_ERROR
>> SCRIPT ERROR at runtime/errors/callable_call_after_free_object.gd:6 on test(): Attempt to call function 'null::is_inside_tree (Callable)' on a null instance.

View file

@ -0,0 +1,3 @@
#debug-only
func test():
print(load.bind([]).call())

View file

@ -0,0 +1,2 @@
GDTEST_RUNTIME_ERROR
>> SCRIPT ERROR at runtime/errors/callable_call_invalid_arg_type.gd:3 on test(): Invalid type in function '@GDScript::load (Callable)'. Cannot convert argument 1 from Array to String.

View file

@ -0,0 +1,32 @@
const ARRAY := [{}]
const DICTIONARY := { 0: [0] }
func subtest_constant_array():
var dictionary := ARRAY[0]
var key := 0
dictionary[key] = 0
print(ARRAY)
func subtest_constant_dictionary():
var array := DICTIONARY[0]
var key := 0
array[key] = 0
print(DICTIONARY)
func subtest_readonly_array():
var array := [0]
array.make_read_only()
array[0] = 1
print(array)
func subtest_readonly_dictionary():
var dictionary := { "a": 0 }
dictionary.make_read_only()
dictionary.a = 1
print(dictionary)
func test():
subtest_constant_array()
subtest_constant_dictionary()
subtest_readonly_array()
subtest_readonly_dictionary()

View file

@ -0,0 +1,9 @@
GDTEST_RUNTIME_ERROR
>> ERROR: Condition "_p->read_only" is true. Returning: false
>> Dictionary is in read-only state.
>> SCRIPT ERROR at runtime/errors/constant_collections.gd:7 on subtest_constant_array(): Invalid assignment on read-only value (on base: 'Dictionary').
>> SCRIPT ERROR at runtime/errors/constant_collections.gd:13 on subtest_constant_dictionary(): Invalid assignment on read-only value (on base: 'Array').
>> SCRIPT ERROR at runtime/errors/constant_collections.gd:19 on subtest_readonly_array(): Invalid assignment on read-only value (on base: 'Array').
>> ERROR: Condition "_p->read_only" is true. Returning: false
>> Dictionary is in read-only state.
>> SCRIPT ERROR at runtime/errors/constant_collections.gd:25 on subtest_readonly_dictionary(): Invalid assignment on read-only value (on base: 'Dictionary').

View file

@ -0,0 +1,43 @@
func subtest_int():
var x: int = 1
x /= 0
print(x)
func subtest_vector2i():
var v: Vector2i = Vector2i.ONE
v /= Vector2i.ZERO
print(v)
func subtest_vector3i():
var v: Vector3i = Vector3i.ONE
v /= Vector3i.ZERO
print(v)
func subtest_vector4i():
var v: Vector4i = Vector4i.ONE
v /= Vector4i.ZERO
print(v)
func subtest_vector2i_div_int():
var v: Vector2i = Vector2i.ONE
v /= 0
print(v)
func subtest_vector3i_div_int():
var v: Vector3i = Vector3i.ONE
v /= 0
print(v)
func subtest_vector4i_div_int():
var v: Vector4i = Vector4i.ONE
v /= 0
print(v)
func test():
subtest_int()
subtest_vector2i()
subtest_vector3i()
subtest_vector4i()
subtest_vector2i_div_int()
subtest_vector3i_div_int()
subtest_vector4i_div_int()

View file

@ -0,0 +1,8 @@
GDTEST_RUNTIME_ERROR
>> SCRIPT ERROR at runtime/errors/division_by_zero.gd:3 on subtest_int(): Division by zero error in operator '/'.
>> SCRIPT ERROR at runtime/errors/division_by_zero.gd:8 on subtest_vector2i(): Division by zero error in operator '/'.
>> SCRIPT ERROR at runtime/errors/division_by_zero.gd:13 on subtest_vector3i(): Division by zero error in operator '/'.
>> SCRIPT ERROR at runtime/errors/division_by_zero.gd:18 on subtest_vector4i(): Division by zero error in operator '/'.
>> SCRIPT ERROR at runtime/errors/division_by_zero.gd:23 on subtest_vector2i_div_int(): Division by zero error in operator '/'.
>> SCRIPT ERROR at runtime/errors/division_by_zero.gd:28 on subtest_vector3i_div_int(): Division by zero error in operator '/'.
>> SCRIPT ERROR at runtime/errors/division_by_zero.gd:33 on subtest_vector4i_div_int(): Division by zero error in operator '/'.

View file

@ -0,0 +1,4 @@
func test():
var a: Array = [Resource.new()]
for node: Node in a:
print(node)

View file

@ -0,0 +1,2 @@
GDTEST_RUNTIME_ERROR
>> SCRIPT ERROR at runtime/errors/for_loop_iterator_type_not_match_specified.gd:3 on test(): Trying to assign value of type 'Resource' to a variable of type 'Node'.

View file

@ -0,0 +1,22 @@
func subtest_wrong_builtin():
var integer: Variant = 1
print(integer as Array)
func subtest_builtin_as_object():
var integer: Variant = 1
print(integer as Node)
func subtest_object_as_builtin():
var object: Variant = RefCounted.new()
print(object as int)
func subtest_freed_object():
var node := Node.new()
node.free()
print(node as Node2D)
func test():
subtest_wrong_builtin()
subtest_builtin_as_object()
subtest_object_as_builtin()
subtest_freed_object()

View file

@ -0,0 +1,8 @@
GDTEST_RUNTIME_ERROR
~~ WARNING at line 3: (UNSAFE_CAST) Casting "Variant" to "Array" is unsafe.
~~ WARNING at line 7: (UNSAFE_CAST) Casting "Variant" to "Node" is unsafe.
~~ WARNING at line 11: (UNSAFE_CAST) Casting "Variant" to "int" is unsafe.
>> SCRIPT ERROR at runtime/errors/invalid_cast.gd:3 on subtest_wrong_builtin(): Invalid cast: could not convert value to 'Array'.
>> SCRIPT ERROR at runtime/errors/invalid_cast.gd:7 on subtest_builtin_as_object(): Invalid cast: can't convert a non-object value to an object type.
>> SCRIPT ERROR at runtime/errors/invalid_cast.gd:11 on subtest_object_as_builtin(): Invalid cast: could not convert value to 'int'.
>> SCRIPT ERROR at runtime/errors/invalid_cast.gd:16 on subtest_freed_object(): Trying to cast a freed object.

View file

@ -0,0 +1,10 @@
# https://github.com/godotengine/godot/issues/90086
class MyObj:
var obj: WeakRef
func test():
var obj_1 = MyObj.new()
var obj_2 = MyObj.new()
obj_1.obj = obj_2
prints(obj_1, obj_2)

View file

@ -0,0 +1,2 @@
GDTEST_RUNTIME_ERROR
>> SCRIPT ERROR at runtime/errors/invalid_property_assignment.gd:9 on test(): Invalid assignment of property or key 'obj' with value of type 'RefCounted (MyObj)' on a base object of type 'RefCounted (MyObj)'.

View file

@ -0,0 +1,43 @@
func subtest_int():
var x: int = 1
x %= 0
print(x)
func subtest_vector2i():
var v: Vector2i = Vector2i.ONE
v %= Vector2i.ZERO
print(v)
func subtest_vector3i():
var v: Vector3i = Vector3i.ONE
v %= Vector3i.ZERO
print(v)
func subtest_vector4i():
var v: Vector4i = Vector4i.ONE
v %= Vector4i.ZERO
print(v)
func subtest_vector2i_mod_int():
var v: Vector2i = Vector2i.ONE
v %= 0
print(v)
func subtest_vector3i_mod_int():
var v: Vector3i = Vector3i.ONE
v %= 0
print(v)
func subtest_vector4i_mod_int():
var v: Vector4i = Vector4i.ONE
v %= 0
print(v)
func test():
subtest_int()
subtest_vector2i()
subtest_vector3i()
subtest_vector4i()
subtest_vector2i_mod_int()
subtest_vector3i_mod_int()
subtest_vector4i_mod_int()

View file

@ -0,0 +1,8 @@
GDTEST_RUNTIME_ERROR
>> SCRIPT ERROR at runtime/errors/modulo_by_zero.gd:3 on subtest_int(): Modulo by zero error in operator '%'.
>> SCRIPT ERROR at runtime/errors/modulo_by_zero.gd:8 on subtest_vector2i(): Modulo by zero error in operator '%'.
>> SCRIPT ERROR at runtime/errors/modulo_by_zero.gd:13 on subtest_vector3i(): Modulo by zero error in operator '%'.
>> SCRIPT ERROR at runtime/errors/modulo_by_zero.gd:18 on subtest_vector4i(): Modulo by zero error in operator '%'.
>> SCRIPT ERROR at runtime/errors/modulo_by_zero.gd:23 on subtest_vector2i_mod_int(): Modulo by zero error in operator '%'.
>> SCRIPT ERROR at runtime/errors/modulo_by_zero.gd:28 on subtest_vector3i_mod_int(): Modulo by zero error in operator '%'.
>> SCRIPT ERROR at runtime/errors/modulo_by_zero.gd:33 on subtest_vector4i_mod_int(): Modulo by zero error in operator '%'.

View file

@ -0,0 +1,7 @@
# https://github.com/godotengine/godot/issues/66675
func example(thing):
print(thing.has_method("asdf"))
func test():
example(Node2D)

View file

@ -0,0 +1,3 @@
GDTEST_RUNTIME_ERROR
~~ WARNING at line 4: (UNSAFE_METHOD_ACCESS) The method "has_method()" is not present on the inferred type "Variant" (but may be present on a subtype).
>> SCRIPT ERROR at runtime/errors/non_static_method_call_on_native_class.gd:4 on example(): Invalid call. Nonexistent function 'has_method' in base 'Node2D'.

View file

@ -0,0 +1,28 @@
class Outer:
const OUTER_CONST := 0
class Inner:
pass
func subtest_type_hard():
var type := Outer.Inner
print(type.OUTER_CONST)
func subtest_type_weak():
var type := Outer.Inner
var type_v: Variant = type
print(type_v.OUTER_CONST)
func subtest_instance_hard():
var instance := Outer.Inner.new()
print(instance.OUTER_CONST)
func subtest_instance_weak():
var instance := Outer.Inner.new()
var instance_v: Variant = instance
print(instance_v.OUTER_CONST)
func test():
subtest_type_hard()
subtest_type_weak()
subtest_instance_hard()
subtest_instance_weak()

View file

@ -0,0 +1,7 @@
GDTEST_RUNTIME_ERROR
~~ WARNING at line 8: (UNSAFE_PROPERTY_ACCESS) The property "OUTER_CONST" is not present on the inferred type "Inner" (but may be present on a subtype).
~~ WARNING at line 17: (UNSAFE_PROPERTY_ACCESS) The property "OUTER_CONST" is not present on the inferred type "Inner" (but may be present on a subtype).
>> SCRIPT ERROR at runtime/errors/outer_class_constants.gd:8 on subtest_type_hard(): Invalid access to property or key 'OUTER_CONST' on a base object of type 'GDScript'.
>> SCRIPT ERROR at runtime/errors/outer_class_constants.gd:13 on subtest_type_weak(): Invalid access to property or key 'OUTER_CONST' on a base object of type 'GDScript'.
>> SCRIPT ERROR at runtime/errors/outer_class_constants.gd:17 on subtest_instance_hard(): Invalid access to property or key 'OUTER_CONST' on a base object of type 'RefCounted (Inner)'.
>> SCRIPT ERROR at runtime/errors/outer_class_constants.gd:22 on subtest_instance_weak(): Invalid access to property or key 'OUTER_CONST' on a base object of type 'RefCounted (Inner)'.

View file

@ -0,0 +1,12 @@
# TODO: This test is currently disabled since it triggers some complex memory leaks. Try enabling it again once GH-101830 is fixed.
signal finished
const scr: GDScript = preload("reload_suspended_function_helper.notest.gd")
func test():
@warning_ignore("UNSAFE_METHOD_ACCESS")
scr.test(self)
@warning_ignore("RETURN_VALUE_DISCARDED")
scr.reload(true)
finished.emit()

View file

@ -0,0 +1,2 @@
GDTEST_RUNTIME_ERROR
>> WARNING: Canceling suspended execution of "test" due to a script reload.

View file

@ -0,0 +1,3 @@
static func test(a):
await a.finished
pass

View file

@ -0,0 +1,37 @@
class Foo: pass
class Bar extends Foo: pass
class Baz extends Foo: pass
func expect_typed(typed: Array[int]):
print(typed.size())
func subtest_assign_basic_to_typed():
var basic := [1]
var _typed: Array[int] = basic
print("end subtest_assign_basic_to_typed")
func subtest_assign_basic_to_differently_typed():
var differently: Variant = [1.0] as Array[float]
var _typed: Array[int] = differently
print("end subtest_assign_basic_to_differently_typed")
func subtest_assign_wrong_to_typed():
var _typed: Array[Bar] = [Baz.new() as Foo]
print("end subtest_assign_wrong_to_typed")
func subtest_pass_basic_to_typed():
var basic := [1]
expect_typed(basic)
print("end subtest_pass_basic_to_typed")
func subtest_pass_basic_to_differently_typed():
var differently: Variant = [1.0] as Array[float]
expect_typed(differently)
print("end subtest_pass_basic_to_differently_typed")
func test():
subtest_assign_basic_to_typed()
subtest_assign_basic_to_differently_typed()
subtest_assign_wrong_to_typed()
subtest_pass_basic_to_typed()
subtest_pass_basic_to_differently_typed()

View file

@ -0,0 +1,10 @@
GDTEST_RUNTIME_ERROR
~~ WARNING at line 29: (UNSAFE_CALL_ARGUMENT) The argument 1 of the function "expect_typed()" requires the subtype "Array[int]" but the supertype "Variant" was provided.
>> SCRIPT ERROR at runtime/errors/typed_array.gd:10 on subtest_assign_basic_to_typed(): Trying to assign an array of type "Array" to a variable of type "Array[int]".
>> SCRIPT ERROR at runtime/errors/typed_array.gd:15 on subtest_assign_basic_to_differently_typed(): Trying to assign an array of type "Array[float]" to a variable of type "Array[int]".
>> ERROR: Method/function failed. Returning: false
>> Attempted to set an object into a TypedArray, that does not inherit from 'GDScript'.
>> ERROR: Condition "!_p->typed.validate(value, "set")" is true.
end subtest_assign_wrong_to_typed
>> SCRIPT ERROR at runtime/errors/typed_array.gd:24 on subtest_pass_basic_to_typed(): Invalid type in function 'expect_typed' in base 'RefCounted (typed_array.gd)'. The array of argument 1 (Array) does not have the same element type as the expected typed array argument.
>> SCRIPT ERROR at runtime/errors/typed_array.gd:29 on subtest_pass_basic_to_differently_typed(): Invalid type in function 'expect_typed' in base 'RefCounted (typed_array.gd)'. The array of argument 1 (Array[float]) does not have the same element type as the expected typed array argument.

View file

@ -0,0 +1,55 @@
class Foo: pass
class Bar extends Foo: pass
class Baz extends Foo: pass
func get_key() -> Variant:
return "key"
func get_value() -> Variant:
return "value"
func expect_typed(typed: Dictionary[int, int]):
print(typed.size())
func subtest_assign_basic_to_typed():
var basic := { 1: 1 }
var _typed: Dictionary[int, int] = basic
print("end subtest_assign_basic_to_typed")
func subtest_assign_basic_to_differently_typed_key():
var typed: Dictionary[int, int]
typed[get_key()] = 0
print("end subtest_assign_basic_to_differently_typed_key")
func subtest_assign_basic_to_differently_typed_value():
var typed: Dictionary[int, int]
typed[0] = get_value()
print("end subtest_assign_basic_to_differently_typed_value")
func subtest_assign_differently_typed():
var differently: Variant = { 1.0: 0.0 } as Dictionary[float, float]
var _typed: Dictionary[int, int] = differently
print("end subtest_assign_differently_typed")
func subtest_assign_wrong_to_typed():
var _typed: Dictionary[Bar, Bar] = { Baz.new() as Foo: Baz.new() as Foo }
print("end subtest_assign_wrong_to_typed")
func subtest_pass_basic_to_typed():
var basic := { 1: 1 }
expect_typed(basic)
print("end subtest_pass_basic_to_typed")
func subtest_pass_basic_to_differently_typed():
var differently: Variant = { 1.0: 0.0 } as Dictionary[float, float]
expect_typed(differently)
print("end subtest_pass_basic_to_differently_typed")
func test():
subtest_assign_basic_to_typed()
subtest_assign_basic_to_differently_typed_key()
subtest_assign_basic_to_differently_typed_value()
subtest_assign_differently_typed()
subtest_assign_wrong_to_typed()
subtest_pass_basic_to_typed()
subtest_pass_basic_to_differently_typed()

View file

@ -0,0 +1,18 @@
GDTEST_RUNTIME_ERROR
~~ WARNING at line 45: (UNSAFE_CALL_ARGUMENT) The argument 1 of the function "expect_typed()" requires the subtype "Dictionary[int, int]" but the supertype "Variant" was provided.
>> SCRIPT ERROR at runtime/errors/typed_dictionary.gd:16 on subtest_assign_basic_to_typed(): Trying to assign a dictionary of type "Dictionary" to a variable of type "Dictionary[int, int]".
>> ERROR: Method/function failed. Returning: false
>> Attempted to set a variable of type 'String' into a TypedDictionary.Key of type 'int'.
>> ERROR: Condition "!_p->typed_key.validate(key, "set")" is true. Returning: false
>> SCRIPT ERROR at runtime/errors/typed_dictionary.gd:21 on subtest_assign_basic_to_differently_typed_key(): Invalid assignment of property or key 'key' with value of type 'int' on a base object of type 'Dictionary[int, int]'.
>> ERROR: Method/function failed. Returning: false
>> Attempted to set a variable of type 'String' into a TypedDictionary.Value of type 'int'.
>> ERROR: Condition "!_p->typed_value.validate(value, "set")" is true. Returning: false
>> SCRIPT ERROR at runtime/errors/typed_dictionary.gd:26 on subtest_assign_basic_to_differently_typed_value(): Invalid assignment of property or key '0' with value of type 'String' on a base object of type 'Dictionary[int, int]'.
>> SCRIPT ERROR at runtime/errors/typed_dictionary.gd:31 on subtest_assign_differently_typed(): Trying to assign a dictionary of type "Dictionary[float, float]" to a variable of type "Dictionary[int, int]".
>> ERROR: Method/function failed. Returning: false
>> Attempted to set an object into a TypedDictionary.Key, that does not inherit from 'GDScript'.
>> ERROR: Condition "!_p->typed_key.validate(key, "set")" is true. Returning: false
end subtest_assign_wrong_to_typed
>> SCRIPT ERROR at runtime/errors/typed_dictionary.gd:40 on subtest_pass_basic_to_typed(): Invalid type in function 'expect_typed' in base 'RefCounted (typed_dictionary.gd)'. The dictionary of argument 1 (Dictionary) does not have the same element type as the expected typed dictionary argument.
>> SCRIPT ERROR at runtime/errors/typed_dictionary.gd:45 on subtest_pass_basic_to_differently_typed(): Invalid type in function 'expect_typed' in base 'RefCounted (typed_dictionary.gd)'. The dictionary of argument 1 (Dictionary[float, float]) does not have the same element type as the expected typed dictionary argument.

View file

@ -0,0 +1,43 @@
class A:
func return_int(_variant: Variant) -> int: return 123
func return_int_array(_variant: Variant) -> Array[int]: return [1]
func return_int_dict(_variant: Variant) -> Dictionary[int, int]: return {1: 1}
func return_node(_variant: Variant) -> Node: return null
class B extends A:
func return_int(variant: Variant): return variant
func return_int_array(variant: Variant): return variant
func return_int_dict(variant: Variant): return variant
func return_node(variant: Variant): return variant
func output(value: Variant) -> void:
if value is Object:
var object: Object = value
print("<%s>" % object.get_class())
else:
print(var_to_str(value).replace("\n", ""))
func test():
var b := B.new()
output(b.return_int("abc"))
output(b.return_int_array("abc"))
output(b.return_int_dict("abc"))
output(b.return_node("abc"))
var resource := Resource.new()
output(b.return_int(resource))
output(b.return_int_array(resource))
output(b.return_int_dict(resource))
output(b.return_node(resource))
var untyped_array: Array
var string_array: Array[String]
var untyped_dict: Dictionary
var string_dict: Dictionary[String, String]
output(b.return_int_array(untyped_array))
output(b.return_int_array(string_array))
output(b.return_int_dict(untyped_dict))
output(b.return_int_dict(string_dict))

View file

@ -0,0 +1,25 @@
GDTEST_RUNTIME_ERROR
>> SCRIPT ERROR at runtime/errors/untyped_override_return_incompatible_value.gd:8 on B.return_int(): Trying to return a value of type "String" from a function whose return type is "int".
0
>> SCRIPT ERROR at runtime/errors/untyped_override_return_incompatible_value.gd:9 on B.return_int_array(): Trying to return a value of type "String" from a function whose return type is "Array[int]".
Array[int]([])
>> SCRIPT ERROR at runtime/errors/untyped_override_return_incompatible_value.gd:10 on B.return_int_dict(): Trying to return a value of type "String" from a function whose return type is "Dictionary[int, int]".
Dictionary[int, int]({})
>> SCRIPT ERROR at runtime/errors/untyped_override_return_incompatible_value.gd:11 on B.return_node(): Trying to return a value of type "String" from a function whose return type is "Node".
null
>> SCRIPT ERROR at runtime/errors/untyped_override_return_incompatible_value.gd:8 on B.return_int(): Trying to return a value of type "Resource" from a function whose return type is "int".
0
>> SCRIPT ERROR at runtime/errors/untyped_override_return_incompatible_value.gd:9 on B.return_int_array(): Trying to return a value of type "Resource" from a function whose return type is "Array[int]".
Array[int]([])
>> SCRIPT ERROR at runtime/errors/untyped_override_return_incompatible_value.gd:10 on B.return_int_dict(): Trying to return a value of type "Resource" from a function whose return type is "Dictionary[int, int]".
Dictionary[int, int]({})
>> SCRIPT ERROR at runtime/errors/untyped_override_return_incompatible_value.gd:11 on B.return_node(): Trying to return a value of type "Resource" from a function whose return type is "Node".
null
>> SCRIPT ERROR at runtime/errors/untyped_override_return_incompatible_value.gd:9 on B.return_int_array(): Trying to return a value of type "Array" from a function whose return type is "Array[int]".
Array[int]([])
>> SCRIPT ERROR at runtime/errors/untyped_override_return_incompatible_value.gd:9 on B.return_int_array(): Trying to return a value of type "Array[String]" from a function whose return type is "Array[int]".
Array[int]([])
>> SCRIPT ERROR at runtime/errors/untyped_override_return_incompatible_value.gd:10 on B.return_int_dict(): Trying to return a value of type "Dictionary" from a function whose return type is "Dictionary[int, int]".
Dictionary[int, int]({})
>> SCRIPT ERROR at runtime/errors/untyped_override_return_incompatible_value.gd:10 on B.return_int_dict(): Trying to return a value of type "Dictionary[String, String]" from a function whose return type is "Dictionary[int, int]".
Dictionary[int, int]({})

View file

@ -0,0 +1,16 @@
func subtest_builtin():
var array: Variant = []
print(array.reverse())
func subtest_native():
var ref_counted: Variant = RefCounted.new()
print(ref_counted.notify_property_list_changed())
func subtest_free():
var node: Variant = Node.new()
print(node.free())
func test():
subtest_builtin()
subtest_native()
subtest_free()

View file

@ -0,0 +1,7 @@
GDTEST_RUNTIME_ERROR
~~ WARNING at line 3: (UNSAFE_METHOD_ACCESS) The method "reverse()" is not present on the inferred type "Variant" (but may be present on a subtype).
~~ WARNING at line 7: (UNSAFE_METHOD_ACCESS) The method "notify_property_list_changed()" is not present on the inferred type "Variant" (but may be present on a subtype).
~~ WARNING at line 11: (UNSAFE_METHOD_ACCESS) The method "free()" is not present on the inferred type "Variant" (but may be present on a subtype).
>> SCRIPT ERROR at runtime/errors/use_value_of_void_function.gd:3 on subtest_builtin(): Trying to get a return value of a method that returns "void"
>> SCRIPT ERROR at runtime/errors/use_value_of_void_function.gd:7 on subtest_native(): Trying to get a return value of a method that returns "void"
>> SCRIPT ERROR at runtime/errors/use_value_of_void_function.gd:11 on subtest_free(): Trying to get a return value of a method that returns "void"

View file

@ -0,0 +1,11 @@
func subtest_pass_wrong_arg_builtin():
var x = Color()
print(floor(x)) # Built-in utility function.
func subtest_pass_wrong_arg_gdscript():
var x = Color()
print(len(x)) # GDScript utility function.
func test():
subtest_pass_wrong_arg_builtin()
subtest_pass_wrong_arg_gdscript()

View file

@ -0,0 +1,3 @@
GDTEST_RUNTIME_ERROR
>> SCRIPT ERROR at runtime/errors/utility_functions.gd:3 on subtest_pass_wrong_arg_builtin(): Error calling utility function "floor()": Argument "x" must be "int", "float", "Vector2", "Vector2i", "Vector3", "Vector3i", "Vector4", or "Vector4i".
>> SCRIPT ERROR at runtime/errors/utility_functions.gd:7 on subtest_pass_wrong_arg_gdscript(): Error calling GDScript utility function "len()": Value of type 'Color' can't provide a length.

View file

@ -0,0 +1,50 @@
@abstract class A:
@abstract func get_text_1() -> String
@abstract func get_text_2() -> String
# No `UNUSED_PARAMETER` warning.
@abstract func func_with_param(param: int) -> int
@abstract func func_with_rest_param(...args: Array) -> int
@abstract func func_with_semicolon() -> int;
@abstract func func_1() -> int; @abstract func func_2() -> int
@abstract func func_without_return_type()
func print_text_1() -> void:
print(get_text_1())
@abstract class B extends A:
func get_text_1() -> String:
return "text_1b"
func print_text_2() -> void:
print(get_text_2())
class C extends B:
func get_text_2() -> String:
return "text_2c"
func func_with_param(param: int) -> int: return param
func func_with_rest_param(...args: Array) -> int: return args.size()
func func_with_semicolon() -> int: return 0
func func_1() -> int: return 0
func func_2() -> int: return 0
func func_without_return_type(): pass
@abstract class D extends C:
@abstract func get_text_1() -> String
func get_text_2() -> String:
return super() + " text_2d"
class E extends D:
func get_text_1() -> String:
return "text_1e"
func test():
var c := C.new()
c.print_text_1()
c.print_text_2()
var e := E.new()
e.print_text_1()
e.print_text_2()

View file

@ -0,0 +1,5 @@
GDTEST_OK
text_1b
text_2c
text_1e
text_2c text_2d

View file

@ -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.

View file

@ -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

View file

@ -0,0 +1,6 @@
func test():
# GH-114299
var a1: Array[PackedInt32Array] = [[1]]
var a2 = [[2]] as Array[PackedInt32Array]
print(var_to_str(a1))
print(var_to_str(a2))

View file

@ -0,0 +1,3 @@
GDTEST_OK
Array[PackedInt32Array]([PackedInt32Array(1)])
Array[PackedInt32Array]([PackedInt32Array(2)])

View file

@ -0,0 +1,35 @@
# https://github.com/godotengine/godot/issues/63965
func test():
var array_str: Array = []
array_str.push_back("godot")
print("StringName in Array: ", &"godot" in array_str)
var array_sname: Array = []
array_sname.push_back(&"godot")
print("String in Array: ", "godot" in array_sname)
# Not equal because the values are different types.
print("Arrays not equal: ", array_str != array_sname)
var string_array: Array[String] = []
var stringname_array: Array[StringName] = []
string_array.push_back(&"abc")
print("Array[String] insert converted: ", typeof(string_array[0]) == TYPE_STRING)
stringname_array.push_back("abc")
print("Array[StringName] insert converted: ", typeof(stringname_array[0]) == TYPE_STRING_NAME)
print("StringName in Array[String]: ", &"abc" in string_array)
print("String in Array[StringName]: ", "abc" in stringname_array)
var packed_string_array: PackedStringArray = []
Utils.check(!packed_string_array.push_back("abc"))
print("StringName in PackedStringArray: ", &"abc" in packed_string_array)
string_array.push_back("abc")
print("StringName finds String in Array: ", string_array.find(&"abc"))
stringname_array.push_back(&"abc")
print("String finds StringName in Array: ", stringname_array.find("abc"))

View file

@ -0,0 +1,11 @@
GDTEST_OK
StringName in Array: true
String in Array: true
Arrays not equal: true
Array[String] insert converted: true
Array[StringName] insert converted: true
StringName in Array[String]: true
String in Array[StringName]: true
StringName in PackedStringArray: true
StringName finds String in Array: 0
String finds StringName in Array: 0

View file

@ -0,0 +1,32 @@
# https://github.com/godotengine/godot/issues/48121
func test():
var x := []
var y := []
x.push_back(y)
print("TEST ARRAY ADD TO SELF: " + str(len(y)))
x.clear()
x = Array()
y = Array()
x.push_back(y)
print("TEST ARRAY ADD TO SELF: " + str(len(y)))
x.clear()
x = Array().duplicate()
y = Array().duplicate()
x.push_back(y)
print("TEST ARRAY ADD TO SELF: " + str(len(y)))
x.clear()
x = [].duplicate()
y = [].duplicate()
x.push_back(y)
print("TEST ARRAY ADD TO SELF: " + str(len(y)))
x.clear()
x = Array()
y = Array()
x.push_back(y)
print("TEST ARRAY ADD TO SELF: " + str(len(y)))
x.clear()

View file

@ -0,0 +1,6 @@
GDTEST_OK
TEST ARRAY ADD TO SELF: 0
TEST ARRAY ADD TO SELF: 0
TEST ARRAY ADD TO SELF: 0
TEST ARRAY ADD TO SELF: 0
TEST ARRAY ADD TO SELF: 0

View file

@ -0,0 +1,13 @@
extends Node
func test():
process_priority = 10
var change = 20
print(process_priority)
print(change)
process_priority += change
print(process_priority)
print(change)

View file

@ -0,0 +1,5 @@
GDTEST_OK
10
20
30
20

View file

@ -0,0 +1,31 @@
# https://github.com/godotengine/godot/issues/75832
@warning_ignore_start("narrowing_conversion")
func test():
var hf := 2.0
var sf = 2.0
var i := 2
i *= hf
i *= sf
i *= 2.0
print(i)
var v2 := Vector2i(1, 2)
v2 *= hf
v2 *= sf
v2 *= 2.0
print(v2)
var v3 := Vector3i(1, 2, 3)
v3 *= hf
v3 *= sf
v3 *= 2.0
print(v3)
var v4 := Vector4i(1, 2, 3, 4)
v4 *= hf
v4 *= sf
v4 *= 2.0
print(v4)
var arr := [1, 2, 3]
arr += [4, 5]
print(arr)

View file

@ -0,0 +1,6 @@
GDTEST_OK
16
(8, 16)
(8, 16, 24)
(8, 16, 24, 32)
[1, 2, 3, 4, 5]

View file

@ -0,0 +1,7 @@
func wait() -> void:
pass
func test():
@warning_ignore("redundant_await")
await wait()
print("end")

View file

@ -0,0 +1,2 @@
GDTEST_OK
end

View file

@ -0,0 +1,28 @@
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():
@warning_ignore("missing_await")
await_no_parameters()
no_parameters.emit()
@warning_ignore("missing_await")
await_one_parameter()
one_parameter.emit(1)
@warning_ignore("missing_await")
await_two_parameters()
two_parameters.emit(1, 2)

View file

@ -0,0 +1,4 @@
GDTEST_OK
<null>
1
[1, 2]

View file

@ -0,0 +1,8 @@
# https://github.com/godotengine/godot/issues/50894
func test():
print(await not_coroutine())
func not_coroutine() -> String:
return "awaited"

View file

@ -0,0 +1,3 @@
GDTEST_OK
~~ WARNING at line 4: (REDUNDANT_AWAIT) "await" keyword is unnecessary because the expression isn't a coroutine nor a signal.
awaited

View file

@ -0,0 +1,13 @@
func test():
var array: Array = [1, 2, 3]
print(array)
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)

View file

@ -0,0 +1,5 @@
GDTEST_OK
[1, 2, 3]
[]
{ 1: 2, 3: 4 }
{ }

View file

@ -0,0 +1,9 @@
class_name TestCallNativeStatic
extends JSON
func test():
var s: GDScript = get_script()
@warning_ignore("unsafe_method_access")
print(s.stringify("test"))
print(s.call(&"stringify", "test"))
print(TestCallNativeStatic.stringify("test"))

View file

@ -0,0 +1,4 @@
GDTEST_OK
"test"
"test"
"test"

View file

@ -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()

View file

@ -0,0 +1,26 @@
var array_var: Array = ["one", "two", "three", "four"]
const array_const: Array = ["one", "two", "three", "four"]
var array_nested_var: Array = [["one"], ["two"], ["three"], ["four"]]
const array_nested_const: Array = [["one"], ["two"], ["three"], ["four"]]
func test():
Utils.check(array_const.is_read_only() == true)
Utils.check(array_nested_const.is_read_only() == true)
print("TEST Callable::callv")
print_four_variants.callv(array_var)
print_four_variants.callv(array_const)
print_four_variants.callv(array_nested_var)
print_four_variants.callv(array_nested_const)
print("TEST Object::callv")
self.callv("print_four_variants", array_var)
self.callv("print_four_variants", array_const)
self.callv("print_four_variants", array_nested_var)
self.callv("print_four_variants", array_nested_const)
func print_four_variants(v1, v2, v3, v4):
print("%s %s %s %s" % [v1, v2, v3, v4])

View file

@ -0,0 +1,11 @@
GDTEST_OK
TEST Callable::callv
one two three four
one two three four
["one"] ["two"] ["three"] ["four"]
["one"] ["two"] ["three"] ["four"]
TEST Object::callv
one two three four
one two three four
["one"] ["two"] ["three"] ["four"]
["one"] ["two"] ["three"] ["four"]

View file

@ -0,0 +1,19 @@
func test():
var dictionary1: Variant = {1:Vector2()}
dictionary1[1].x = 2
var dictionary2: Dictionary = {3:Vector2()}
dictionary2[3].x = 4
var array1: Variant = [[Vector2()]]
array1[0][0].x = 5
var array2: Array = [[Vector2()]]
array2[0][0].x = 6
var array3: Array[Array] = [[Vector2()]]
array3[0][0].x = 7
var transform = Transform3D()
transform.basis.x = Vector3(8.0, 9.0, 7.0)
print(dictionary1)
print(dictionary2)
print(array1)
print(array2)
print(array3)
print(transform)

View file

@ -0,0 +1,7 @@
GDTEST_OK
{ 1: (2.0, 0.0) }
{ 3: (4.0, 0.0) }
[[(5.0, 0.0)]]
[[(6.0, 0.0)]]
[[(7.0, 0.0)]]
[X: (8.0, 9.0, 7.0), Y: (0.0, 1.0, 0.0), Z: (0.0, 0.0, 1.0), O: (0.0, 0.0, 0.0)]

View file

@ -0,0 +1,146 @@
func test():
var value
# null
value = null
print(value == null)
# bool
value = false
print(value == null)
# int
value = 0
print(value == null)
# float
value = 0.0
print(value == null)
# String
value = ""
print(value == null)
# Vector2
value = Vector2()
print(value == null)
# Vector2i
value = Vector2i()
print(value == null)
# Rect2
value = Rect2()
print(value == null)
# Rect2i
value = Rect2i()
print(value == null)
# Vector3
value = Vector3()
print(value == null)
# Vector3i
value = Vector3i()
print(value == null)
# Transform2D
value = Transform2D()
print(value == null)
# Plane
value = Plane()
print(value == null)
# Quaternion
value = Quaternion()
print(value == null)
# AABB
value = AABB()
print(value == null)
# Basis
value = Basis()
print(value == null)
# Transform3D
value = Transform3D()
print(value == null)
# Projection
value = Projection()
print(value == null)
# Color
value = Color()
print(value == null)
# StringName
value = &""
print(value == null)
# NodePath
value = ^""
print(value == null)
# RID
value = RID()
print(value == null)
# Callable
value = Callable()
print(value == null)
# Signal
value = Signal()
print(value == null)
# Dictionary
value = {}
print(value == null)
# Array
value = []
print(value == null)
# PackedByteArray
value = PackedByteArray()
print(value == null)
# PackedInt32Array
value = PackedInt32Array()
print(value == null)
# PackedInt64Array
value = PackedInt64Array()
print(value == null)
# PackedFloat32Array
value = PackedFloat32Array()
print(value == null)
# PackedFloat64Array
value = PackedFloat64Array()
print(value == null)
# PackedStringArray
value = PackedStringArray()
print(value == null)
# PackedVector2Array
value = PackedVector2Array()
print(value == null)
# PackedVector3Array
value = PackedVector3Array()
print(value == null)
# PackedColorArray
value = PackedColorArray()
print(value == null)
# PackedVector4Array
value = PackedVector4Array()
print(value == null)

View file

@ -0,0 +1,37 @@
GDTEST_OK
true
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false

View file

@ -0,0 +1,146 @@
func test():
var value
# null
value = null
print(value != null)
# bool
value = false
print(value != null)
# int
value = 0
print(value != null)
# float
value = 0.0
print(value != null)
# String
value = ""
print(value != null)
# Vector2
value = Vector2()
print(value != null)
# Vector2i
value = Vector2i()
print(value != null)
# Rect2
value = Rect2()
print(value != null)
# Rect2i
value = Rect2i()
print(value != null)
# Vector3
value = Vector3()
print(value != null)
# Vector3i
value = Vector3i()
print(value != null)
# Transform2D
value = Transform2D()
print(value != null)
# Plane
value = Plane()
print(value != null)
# Quaternion
value = Quaternion()
print(value != null)
# AABB
value = AABB()
print(value != null)
# Basis
value = Basis()
print(value != null)
# Transform3D
value = Transform3D()
print(value != null)
# Projection
value = Projection()
print(value != null)
# Color
value = Color()
print(value != null)
# StringName
value = &""
print(value != null)
# NodePath
value = ^""
print(value != null)
# RID
value = RID()
print(value != null)
# Callable
value = Callable()
print(value != null)
# Signal
value = Signal()
print(value != null)
# Dictionary
value = {}
print(value != null)
# Array
value = []
print(value != null)
# PackedByteArray
value = PackedByteArray()
print(value != null)
# PackedInt32Array
value = PackedInt32Array()
print(value != null)
# PackedInt64Array
value = PackedInt64Array()
print(value != null)
# PackedFloat32Array
value = PackedFloat32Array()
print(value != null)
# PackedFloat64Array
value = PackedFloat64Array()
print(value != null)
# PackedStringArray
value = PackedStringArray()
print(value != null)
# PackedVector2Array
value = PackedVector2Array()
print(value != null)
# PackedVector3Array
value = PackedVector3Array()
print(value != null)
# PackedColorArray
value = PackedColorArray()
print(value != null)
# PackedVector4Array
value = PackedVector4Array()
print(value != null)

View file

@ -0,0 +1,37 @@
GDTEST_OK
false
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true

View file

@ -0,0 +1,142 @@
func test():
var value
# null
value = null
print(null == value)
# bool
value = false
print(null == value)
# int
value = 0
print(null == value)
# float
value = 0.0
print(null == value)
# String
value = ""
print(null == value)
# Vector2
value = Vector2()
print(null == value)
# Vector2i
value = Vector2i()
print(null == value)
# Rect2
value = Rect2()
print(null == value)
# Rect2i
value = Rect2i()
print(null == value)
# Vector3
value = Vector3()
print(null == value)
# Vector3i
value = Vector3i()
print(null == value)
# Transform2D
value = Transform2D()
print(null == value)
# Plane
value = Plane()
print(null == value)
# Quaternion
value = Quaternion()
print(null == value)
# AABB
value = AABB()
print(null == value)
# Basis
value = Basis()
print(null == value)
# Transform3D
value = Transform3D()
print(null == value)
# Color
value = Color()
print(null == value)
# StringName
value = &""
print(null == value)
# NodePath
value = ^""
print(null == value)
# RID
value = RID()
print(null == value)
# Callable
value = Callable()
print(null == value)
# Signal
value = Signal()
print(null == value)
# Dictionary
value = {}
print(null == value)
# Array
value = []
print(null == value)
# PackedByteArray
value = PackedByteArray()
print(null == value)
# PackedInt32Array
value = PackedInt32Array()
print(null == value)
# PackedInt64Array
value = PackedInt64Array()
print(null == value)
# PackedFloat32Array
value = PackedFloat32Array()
print(null == value)
# PackedFloat64Array
value = PackedFloat64Array()
print(null == value)
# PackedStringArray
value = PackedStringArray()
print(null == value)
# PackedVector2Array
value = PackedVector2Array()
print(null == value)
# PackedVector3Array
value = PackedVector3Array()
print(null == value)
# PackedColorArray
value = PackedColorArray()
print(null == value)
# PackedVector4Array
value = PackedVector4Array()
print(null == value)

View file

@ -0,0 +1,36 @@
GDTEST_OK
true
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false

View file

@ -0,0 +1,142 @@
func test():
var value
# null
value = null
print(null != value)
# bool
value = false
print(null != value)
# int
value = 0
print(null != value)
# float
value = 0.0
print(null != value)
# String
value = ""
print(null != value)
# Vector2
value = Vector2()
print(null != value)
# Vector2i
value = Vector2i()
print(null != value)
# Rect2
value = Rect2()
print(null != value)
# Rect2i
value = Rect2i()
print(null != value)
# Vector3
value = Vector3()
print(null != value)
# Vector3i
value = Vector3i()
print(null != value)
# Transform2D
value = Transform2D()
print(null != value)
# Plane
value = Plane()
print(null != value)
# Quaternion
value = Quaternion()
print(null != value)
# AABB
value = AABB()
print(null != value)
# Basis
value = Basis()
print(null != value)
# Transform3D
value = Transform3D()
print(null != value)
# Color
value = Color()
print(null != value)
# StringName
value = &""
print(null != value)
# NodePath
value = ^""
print(null != value)
# RID
value = RID()
print(null != value)
# Callable
value = Callable()
print(null != value)
# Signal
value = Signal()
print(null != value)
# Dictionary
value = {}
print(null != value)
# Array
value = []
print(null != value)
# PackedByteArray
value = PackedByteArray()
print(null != value)
# PackedInt32Array
value = PackedInt32Array()
print(null != value)
# PackedInt64Array
value = PackedInt64Array()
print(null != value)
# PackedFloat32Array
value = PackedFloat32Array()
print(null != value)
# PackedFloat64Array
value = PackedFloat64Array()
print(null != value)
# PackedStringArray
value = PackedStringArray()
print(null != value)
# PackedVector2Array
value = PackedVector2Array()
print(null != value)
# PackedVector3Array
value = PackedVector3Array()
print(null != value)
# PackedColorArray
value = PackedColorArray()
print(null != value)
# PackedVector4Array
value = PackedVector4Array()
print(null != value)

View file

@ -0,0 +1,36 @@
GDTEST_OK
false
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true
true

View file

@ -0,0 +1,16 @@
# https://github.com/godotengine/godot/issues/61636
const External := preload("const_class_reference_external.notest.gd")
class Class1:
class Class2:
pass
const Class1Alias = Class1
const Class1Class2Alias = Class1.Class2
const ExternalAlias = External
const ExternalClassAlias = External.Class
func test():
pass

View file

@ -0,0 +1,9 @@
const array: Array = [0]
const dictionary := {1: 2}
func test():
Utils.check(array.is_read_only() == true)
Utils.check(str(array) == '[0]')
Utils.check(dictionary.is_read_only() == true)
Utils.check(str(dictionary) == '{ 1: 2 }')
print('ok')

View file

@ -0,0 +1,2 @@
GDTEST_OK
ok

View file

@ -0,0 +1,19 @@
func literal(x: float = 1):
print('x is ', x)
print('typeof x is ', typeof(x))
var inferring := 2
func inferred(x: float = inferring):
print('x is ', x)
print('typeof x is ', typeof(x))
var weakling = 3
func weak(x: float = weakling):
print('x is ', x)
print('typeof x is ', typeof(x))
func test():
literal()
inferred()
weak()
print('ok')

View file

@ -0,0 +1,8 @@
GDTEST_OK
x is 1.0
typeof x is 3
x is 2.0
typeof x is 3
x is 3.0
typeof x is 3
ok

View file

@ -0,0 +1,11 @@
class Foo extends Node:
func _init():
name = 'f'
var string: String = name
Utils.check(typeof(string) == TYPE_STRING)
Utils.check(string == 'f')
print('ok')
func test():
var foo := Foo.new()
foo.free()

View file

@ -0,0 +1,78 @@
class Instance:
func _init() -> void:
print("Instance _init")
func _to_string() -> String:
return "<Instance>"
func _notification(what: int) -> void:
if what == NOTIFICATION_PREDELETE:
print("Instance predelete")
# GH-116706
class LocalOwner:
signal never_emitted()
func _init() -> void:
print("LocalOwner _init")
func _notification(what: int) -> void:
if what == NOTIFICATION_PREDELETE:
print("LocalOwner predelete")
func interrupted_coroutine() -> void:
print("interrupted_coroutine begin")
var _instance := Instance.new()
await never_emitted
print("interrupted_coroutine end")
func subtest_order():
print("subtest_order begin")
var local_owner := LocalOwner.new()
@warning_ignore("missing_await")
local_owner.interrupted_coroutine()
local_owner = null
print("subtest_order end")
# GH-117049
signal tick()
func await_before_and_after() -> void:
await tick
var packed_array: PackedStringArray = ["abc"]
var instance := Instance.new()
await tick
prints(packed_array, instance)
func await_two_after() -> void:
var packed_array: PackedStringArray = ["abc"]
var instance := Instance.new()
await tick
await tick
prints(packed_array, instance)
func subtest_resume():
print("subtest_resume begin")
@warning_ignore("missing_await")
await_before_and_after()
tick.emit()
tick.emit()
print("---")
@warning_ignore("missing_await")
await_two_after()
tick.emit()
tick.emit()
print("subtest_resume end")
# ===
func test():
subtest_order()
print("===")
subtest_resume()

View file

@ -0,0 +1,18 @@
GDTEST_OK
subtest_order begin
LocalOwner _init
interrupted_coroutine begin
Instance _init
LocalOwner predelete
Instance predelete
subtest_order end
===
subtest_resume begin
Instance _init
["abc"] <Instance>
Instance predelete
---
Instance _init
["abc"] <Instance>
Instance predelete
subtest_resume end

View file

@ -0,0 +1,10 @@
# https://github.com/godotengine/godot/issues/70319
class InnerClass:
pass
func test():
var inner_ctor : Callable = InnerClass.new
print(inner_ctor)
var native_ctor : Callable = Node.new
print(native_ctor)

View file

@ -0,0 +1,3 @@
GDTEST_OK
GDScript::new
GDScriptNativeClass::new

View file

@ -0,0 +1,20 @@
extends Node
@onready var later_inferred := [1]
@onready var later_static: Array
@onready var later_static_with_init: Array = [1]
@onready var later_untyped = [1]
func test():
Utils.check(typeof(later_inferred) == TYPE_ARRAY)
Utils.check(later_inferred.size() == 0)
Utils.check(typeof(later_static) == TYPE_ARRAY)
Utils.check(later_static.size() == 0)
Utils.check(typeof(later_static_with_init) == TYPE_ARRAY)
Utils.check(later_static_with_init.size() == 0)
Utils.check(typeof(later_untyped) == TYPE_NIL)
print("ok")

View file

@ -0,0 +1,2 @@
GDTEST_OK
ok

View file

@ -0,0 +1,19 @@
# https://github.com/godotengine/godot/issues/48121
func test():
var x := Dictionary()
var y := Dictionary()
y[0]=1
y[1]=1
y[2]=1
print("TEST OTHER DICTIONARY: " + str(len(x)))
x.clear()
x = Dictionary().duplicate()
y = Dictionary().duplicate()
y[0]=1
y[1]=1
y[2]=1
print("TEST OTHER DICTIONARY: " + str(len(x)))
x.clear()
return

View file

@ -0,0 +1,3 @@
GDTEST_OK
TEST OTHER DICTIONARY: 0
TEST OTHER DICTIONARY: 0

View file

@ -0,0 +1,17 @@
# https://github.com/godotengine/godot/issues/62957
func test():
var string_dict = {}
string_dict["abc"] = 42
var stringname_dict = {}
stringname_dict[&"abc"] = 24
print("String key is TYPE_STRING: ", typeof(string_dict.keys()[0]) == TYPE_STRING)
print("StringName key is TYPE_STRING_NAME: ", typeof(stringname_dict.keys()[0]) == TYPE_STRING_NAME)
print("StringName gets String: ", string_dict.get(&"abc"))
print("String gets StringName: ", stringname_dict.get("abc"))
stringname_dict[&"abc"] = 42
# They compare equal because StringName keys are considered equivalent to String keys.
print("String Dictionary == StringName Dictionary: ", string_dict == stringname_dict)

View file

@ -0,0 +1,6 @@
GDTEST_OK
String key is TYPE_STRING: true
StringName key is TYPE_STRING_NAME: true
StringName gets String: 42
String gets StringName: 24
String Dictionary == StringName Dictionary: true

View file

@ -0,0 +1,17 @@
# https://github.com/godotengine/godot/issues/71177
func test():
builtin_method()
builtin_method_static()
print("done")
func builtin_method():
var pba := PackedByteArray()
@warning_ignore("return_value_discarded")
pba.resize(1) # Built-in validated.
func builtin_method_static():
var _pba := PackedByteArray()
@warning_ignore("return_value_discarded")
Vector2.from_angle(PI) # Static built-in validated.

Some files were not shown because too many files have changed in this diff Show more