feat: updated engine

This commit is contained in:
Sara Gerretsen 2026-07-10 17:04:34 +02:00
parent cbe99774ff
commit f4cf6b3999
6607 changed files with 910135 additions and 430025 deletions

View file

@ -3,19 +3,17 @@ class A extends Node:
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()

View file

@ -1,3 +1,3 @@
GDTEST_RUNTIME_ERROR
>> SCRIPT ERROR at runtime/errors/assign_freed_instance.gd:10 on subtest_native(): Trying to assign invalid previously freed instance.
>> SCRIPT ERROR at runtime/errors/assign_freed_instance.gd:18 on subtest_script(): Trying to assign invalid previously freed instance.
>> 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

@ -1,8 +1,10 @@
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()

View file

@ -1,6 +1,6 @@
GDTEST_RUNTIME_ERROR
~~ WARNING at line 9: (UNSAFE_CALL_ARGUMENT) The argument 1 of the function "subtest_attribute()" requires the subtype "Variant" but the supertype "Variant" was provided.
~~ WARNING at line 10: (UNSAFE_CALL_ARGUMENT) The argument 1 of the function "subtest_variable_index()" requires the subtype "Variant" but the supertype "Variant" was provided.
~~ 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:5 on subtest_variable_index(): 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

@ -4,3 +4,4 @@ func test():
var inside_tree = node.is_inside_tree
node.free()
inside_tree.call()
print(node)

View file

@ -1,4 +0,0 @@
func test():
var node := Node.new()
node.free()
print(node as Node2D)

View file

@ -1,2 +0,0 @@
GDTEST_RUNTIME_ERROR
>> SCRIPT ERROR at runtime/errors/cast_freed_object.gd:4 on test(): Trying to cast a freed object.

View file

@ -1,4 +0,0 @@
func test():
var integer: Variant = 1
@warning_ignore("unsafe_cast")
print(integer as Array)

View file

@ -1,2 +0,0 @@
GDTEST_RUNTIME_ERROR
>> SCRIPT ERROR at runtime/errors/cast_int_to_array.gd:4 on test(): Invalid cast: could not convert value to 'Array'.

View file

@ -1,4 +0,0 @@
func test():
var integer: Variant = 1
@warning_ignore("unsafe_cast")
print(integer as Node)

View file

@ -1,2 +0,0 @@
GDTEST_RUNTIME_ERROR
>> SCRIPT ERROR at runtime/errors/cast_int_to_object.gd:4 on test(): Invalid cast: can't convert a non-object value to an object type.

View file

@ -1,4 +0,0 @@
func test():
var object: Variant = RefCounted.new()
@warning_ignore("unsafe_cast")
print(object as int)

View file

@ -1,2 +0,0 @@
GDTEST_RUNTIME_ERROR
>> SCRIPT ERROR at runtime/errors/cast_object_to_int.gd:4 on test(): Invalid cast: could not convert value to 'int'.

View file

@ -0,0 +1,36 @@
# GH-118877
class Test1:
func _get_property_list():
return [
{ "name": "test_property", "type": TYPE_INT },
]
class Test2:
func _get_property_list():
var properties = []
properties.append({ "name": "test_property", "type": TYPE_INT })
return properties
class Test3:
func _get_property_list() -> Array[Dictionary]:
var properties = []
properties.append({ "name": "test_property", "type": TYPE_INT })
return properties
func check(instance: Object) -> void:
var has_property: bool = false
for property in instance.get_property_list():
if str(property.name) == "test_property":
has_property = true
break
print(has_property)
func test():
check(Test1.new())
check(Test2.new())
check(Test3.new())

View file

@ -0,0 +1,6 @@
GDTEST_RUNTIME_ERROR
>> ERROR: "_get_property_list()" should return "Array[Dictionary]", not "Array". The old behavior is supported for compatibility and may be removed in the future. This message is printed once and will not be repeated for similar errors.
true
true
>> SCRIPT ERROR at runtime/errors/compat_get_property_list.gd:23 on Test3._get_property_list(): Trying to return a value of type "Array" from a function whose return type is "Array[Dictionary]".
false

View file

@ -1,6 +0,0 @@
const array: Array = [{}]
func test():
var dictionary := array[0]
var key: int = 0
dictionary[key] = 0

View file

@ -1,4 +0,0 @@
GDTEST_RUNTIME_ERROR
>> ERROR: Condition "_p->read_only" is true. Returning: false
>> Dictionary is in read-only state.
>> SCRIPT ERROR at runtime/errors/constant_array_is_deep.gd:6 on test(): Invalid assignment on read-only value (on base: 'Dictionary').

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

@ -1,6 +0,0 @@
const dictionary := {0: [0]}
func test():
var array := dictionary[0]
var key: int = 0
array[key] = 0

View file

@ -1,2 +0,0 @@
GDTEST_RUNTIME_ERROR
>> SCRIPT ERROR at runtime/errors/constant_dictionary_is_deep.gd:6 on test(): Invalid assignment on read-only value (on base: 'Array').

View file

@ -1,3 +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():
var integer: int = 1
integer /= 0
subtest_int()
subtest_vector2i()
subtest_vector3i()
subtest_vector4i()
subtest_vector2i_div_int()
subtest_vector3i_div_int()
subtest_vector4i_div_int()

View file

@ -1,3 +1,8 @@
GDTEST_RUNTIME_ERROR
~~ WARNING at line 2: (UNUSED_VARIABLE) The local variable "integer" is declared but never used in the block. If this is intended, prefix it with an underscore: "_integer".
>> SCRIPT ERROR at runtime/errors/division_by_zero.gd:3 on test(): Division by zero error in operator '/'.
>> 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,94 @@
func iterate(v: Variant):
for i in v:
print(i)
class BadInit:
# Whether to push or pop during init
var push
func _init(new_push):
push = new_push
func _iter_init(iter: Array):
if push:
iter.push_back("hi")
else:
iter.pop_back()
return true
func _iter_next(iter: Array):
iter.pop_back()
return !iter.is_empty()
func _iter_get(iter):
return iter
func subtest_init_array_large():
print("SUBTEST_INIT_ARRAY_LARGE")
for i in BadInit.new(true):
print(i)
func subtest_init_array_empty():
print("SUBTEST_INIT_ARRAY_EMPTY")
for i in BadInit.new(false):
print(i)
func subtest_variant_init_array_large():
print("SUBTEST_VARIANT_INIT_ARRAY_LARGE")
iterate(BadInit.new(true))
func subtest_variant_init_array_empty():
print("SUBTEST_VARIANT_INIT_ARRAY_EMPTY")
iterate(BadInit.new(false))
class BadNext:
var push: bool
func _init(new_push):
push = new_push
func _iter_init(iter: Array):
iter[0] = 1
return true
func _iter_next(iter: Array):
if push:
iter.push_back(2)
else:
iter.pop_back()
return true
func _iter_get(iter):
return iter
func subtest_next_array_large():
print("SUBTEST_NEXT_ARRAY_LARGE")
for i in BadNext.new(true):
print(i)
func subtest_next_array_empty():
print("SUBTEST_NEXT_ARRAY_EMPTY")
for i in BadNext.new(false):
print(i)
func subtest_variant_next_array_large():
print("SUBTEST_VARIANT_NEXT_ARRAY_LARGE")
iterate(BadNext.new(true))
func subtest_variant_next_array_empty():
print("SUBTEST_VARIANT_NEXT_ARRAY_EMPTY")
iterate(BadNext.new(false))
func test():
# Typed
subtest_init_array_large()
subtest_init_array_empty()
subtest_next_array_large()
subtest_next_array_empty()
# Untyped
subtest_variant_init_array_large()
subtest_variant_init_array_empty()
subtest_variant_next_array_large()
subtest_variant_next_array_empty()

View file

@ -0,0 +1,21 @@
GDTEST_RUNTIME_ERROR
SUBTEST_INIT_ARRAY_LARGE
>> SCRIPT ERROR at runtime/errors/for_loop_iterator_array_size.gd:28 on subtest_init_array_large(): There was an error calling "_iter_next" on iterator object of type "BadInit".
SUBTEST_INIT_ARRAY_EMPTY
>> SCRIPT ERROR at runtime/errors/for_loop_iterator_array_size.gd:33 on subtest_init_array_empty(): There was an error calling "_iter_next" on iterator object of type "BadInit".
SUBTEST_NEXT_ARRAY_LARGE
1
>> SCRIPT ERROR at runtime/errors/for_loop_iterator_array_size.gd:67 on subtest_next_array_large(): There was an error calling "_iter_next" on iterator object of type "BadNext".
SUBTEST_NEXT_ARRAY_EMPTY
1
>> SCRIPT ERROR at runtime/errors/for_loop_iterator_array_size.gd:72 on subtest_next_array_empty(): There was an error calling "_iter_next" on iterator object of type "BadNext".
SUBTEST_VARIANT_INIT_ARRAY_LARGE
>> SCRIPT ERROR at runtime/errors/for_loop_iterator_array_size.gd:2 on iterate(): Unable to iterate on object of type 'Object'.
SUBTEST_VARIANT_INIT_ARRAY_EMPTY
>> SCRIPT ERROR at runtime/errors/for_loop_iterator_array_size.gd:2 on iterate(): Unable to iterate on object of type 'Object'.
SUBTEST_VARIANT_NEXT_ARRAY_LARGE
1
>> SCRIPT ERROR at runtime/errors/for_loop_iterator_array_size.gd:3 on iterate(): Unable to iterate on object of type 'Object' (type changed since first iteration?).
SUBTEST_VARIANT_NEXT_ARRAY_EMPTY
1
>> SCRIPT ERROR at runtime/errors/for_loop_iterator_array_size.gd:3 on iterate(): Unable to iterate on object of type 'Object' (type changed since first iteration?).

View file

@ -1,3 +0,0 @@
func test():
var x = Color()
print(len(x)) # GDScript utility function.

View file

@ -1,2 +0,0 @@
GDTEST_RUNTIME_ERROR
>> SCRIPT ERROR at runtime/errors/gd_utility_function_wrong_arg.gd:3 on test(): Error calling GDScript utility function "len()": Value of type 'Color' can't provide a length.

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

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

View file

@ -1,3 +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():
var integer: int = 1
integer %= 0
subtest_int()
subtest_vector2i()
subtest_vector3i()
subtest_vector4i()
subtest_vector2i_mod_int()
subtest_vector3i_mod_int()
subtest_vector4i_mod_int()

View file

@ -1,3 +1,8 @@
GDTEST_RUNTIME_ERROR
~~ WARNING at line 2: (UNUSED_VARIABLE) The local variable "integer" is declared but never used in the block. If this is intended, prefix it with an underscore: "_integer".
>> SCRIPT ERROR at runtime/errors/modulo_by_zero.gd:3 on test(): Modulo by zero error in operator '%'.
>> 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

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

View file

@ -1,3 +1,3 @@
GDTEST_RUNTIME_ERROR
~~ WARNING at line 6: (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:6 on example(): Invalid call. Nonexistent function 'has_method' in base 'Node2D'.
~~ 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

@ -1,4 +0,0 @@
func test():
var dictionary := { "a": 0 }
dictionary.make_read_only()
dictionary.a = 1

View file

@ -1,4 +0,0 @@
GDTEST_RUNTIME_ERROR
>> ERROR: Condition "_p->read_only" is true. Returning: false
>> Dictionary is in read-only state.
>> SCRIPT ERROR at runtime/errors/read_only_dictionary.gd:4 on test(): Invalid assignment on read-only value (on base: 'Dictionary').

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 of incompatible type '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

@ -1,4 +0,0 @@
func test():
var basic := [1]
var _typed: Array[int] = basic
print('not ok')

View file

@ -1,2 +0,0 @@
GDTEST_RUNTIME_ERROR
>> SCRIPT ERROR at runtime/errors/typed_array_assign_basic_to_typed.gd:3 on test(): Trying to assign an array of type "Array" to a variable of type "Array[int]".

View file

@ -1,4 +0,0 @@
func test():
var differently: Variant = [1.0] as Array[float]
var _typed: Array[int] = differently
print('not ok')

View file

@ -1,2 +0,0 @@
GDTEST_RUNTIME_ERROR
>> SCRIPT ERROR at runtime/errors/typed_array_assign_differently_typed.gd:3 on test(): Trying to assign an array of type "Array[float]" to a variable of type "Array[int]".

View file

@ -1,7 +0,0 @@
class Foo: pass
class Bar extends Foo: pass
class Baz extends Foo: pass
func test():
var _typed: Array[Bar] = [Baz.new() as Foo]
print('not ok')

View file

@ -1,5 +0,0 @@
GDTEST_RUNTIME_ERROR
>> 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.
not ok

View file

@ -1,7 +0,0 @@
func expect_typed(typed: Array[int]):
print(typed.size())
func test():
var basic := [1]
expect_typed(basic)
print('not ok')

View file

@ -1,2 +0,0 @@
GDTEST_RUNTIME_ERROR
>> SCRIPT ERROR at runtime/errors/typed_array_pass_basic_to_typed.gd:6 on test(): Invalid type in function 'expect_typed' in base 'RefCounted (typed_array_pass_basic_to_typed.gd)'. The array of argument 1 (Array) does not have the same element type as the expected typed array argument.

View file

@ -1,7 +0,0 @@
func expect_typed(typed: Array[int]):
print(typed.size())
func test():
var differently: Variant = [1.0] as Array[float]
expect_typed(differently)
print('not ok')

View file

@ -1,3 +0,0 @@
GDTEST_RUNTIME_ERROR
~~ WARNING at line 6: (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_pass_differently_to_typed.gd:6 on test(): Invalid type in function 'expect_typed' in base 'RefCounted (typed_array_pass_differently_to_typed.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 incompatible 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 incompatible 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 of incompatible type '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

@ -1,4 +0,0 @@
func test():
var basic := { 1: 1 }
var _typed: Dictionary[int, int] = basic
print('not ok')

View file

@ -1,2 +0,0 @@
GDTEST_RUNTIME_ERROR
>> SCRIPT ERROR at runtime/errors/typed_dictionary_assign_basic_to_typed.gd:3 on test(): Trying to assign a dictionary of type "Dictionary" to a variable of type "Dictionary[int, int]".

View file

@ -1,4 +0,0 @@
func test():
var differently: Variant = { 1.0: 0.0 } as Dictionary[float, float]
var _typed: Dictionary[int, int] = differently
print('not ok')

View file

@ -1,2 +0,0 @@
GDTEST_RUNTIME_ERROR
>> SCRIPT ERROR at runtime/errors/typed_dictionary_assign_differently_typed.gd:3 on test(): Trying to assign a dictionary of type "Dictionary[float, float]" to a variable of type "Dictionary[int, int]".

View file

@ -1,7 +0,0 @@
func get_key() -> Variant:
return "key"
func test():
var typed: Dictionary[int, int]
typed[get_key()] = 0
print('not ok')

View file

@ -1,5 +0,0 @@
GDTEST_RUNTIME_ERROR
>> 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_assign_differently_typed_key.gd:6 on test(): Invalid assignment of property or key 'key' with value of type 'int' on a base object of type 'Dictionary[int, int]'.

View file

@ -1,7 +0,0 @@
func get_value() -> Variant:
return "value"
func test():
var typed: Dictionary[int, int]
typed[0] = get_value()
print("not ok")

View file

@ -1,5 +0,0 @@
GDTEST_RUNTIME_ERROR
>> 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_assign_differently_typed_value.gd:6 on test(): Invalid assignment of property or key '0' with value of type 'String' on a base object of type 'Dictionary[int, int]'.

View file

@ -1,7 +0,0 @@
class Foo: pass
class Bar extends Foo: pass
class Baz extends Foo: pass
func test():
var _typed: Dictionary[Bar, Bar] = { Baz.new() as Foo: Baz.new() as Foo }
print('not ok')

View file

@ -1,5 +0,0 @@
GDTEST_RUNTIME_ERROR
>> 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
not ok

View file

@ -1,7 +0,0 @@
func expect_typed(typed: Dictionary[int, int]):
print(typed.size())
func test():
var basic := { 1: 1 }
expect_typed(basic)
print('not ok')

View file

@ -1,2 +0,0 @@
GDTEST_RUNTIME_ERROR
>> SCRIPT ERROR at runtime/errors/typed_dictionary_pass_basic_to_typed.gd:6 on test(): Invalid type in function 'expect_typed' in base 'RefCounted (typed_dictionary_pass_basic_to_typed.gd)'. The dictionary of argument 1 (Dictionary) does not have the same element type as the expected typed dictionary argument.

View file

@ -1,7 +0,0 @@
func expect_typed(typed: Dictionary[int, int]):
print(typed.size())
func test():
var differently: Variant = { 1.0: 0.0 } as Dictionary[float, float]
expect_typed(differently)
print('not ok')

View file

@ -1,3 +0,0 @@
GDTEST_RUNTIME_ERROR
~~ WARNING at line 6: (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_pass_differently_to_typed.gd:6 on test(): Invalid type in function 'expect_typed' in base 'RefCounted (typed_dictionary_pass_differently_to_typed.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

@ -1,4 +0,0 @@
func test():
var obj
obj = Node.new()
print(obj.free())

View file

@ -1,3 +0,0 @@
GDTEST_RUNTIME_ERROR
~~ WARNING at line 4: (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_return_value_of_free_call.gd:4 on test(): Trying to get a return value of a method that returns "void"

View file

@ -1,4 +0,0 @@
func test():
var value
value = []
print(value.reverse())

View file

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

View file

@ -1,4 +0,0 @@
func test():
var obj
obj = RefCounted.new()
print(obj.notify_property_list_changed())

View file

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

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

@ -1,3 +0,0 @@
func test():
var x = Color()
print(floor(x)) # Built-in utility function.

View file

@ -1,2 +0,0 @@
GDTEST_RUNTIME_ERROR
>> SCRIPT ERROR at runtime/errors/utility_function_wrong_arg.gd:3 on test(): Error calling utility function "floor()": Argument "x" must be "int", "float", "Vector2", "Vector2i", "Vector3", "Vector3i", "Vector4", or "Vector4i".

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

@ -1,102 +1,102 @@
extends Node
func my_func_1(_foo, _bar):
pass
pass
func my_func_2(_foo, _bar, _baz):
pass
pass
static func my_static_func_1(_foo, _bar):
pass
pass
static func my_static_func_2(_foo, _bar, _baz):
pass
pass
@rpc
func my_rpc_func_1(_foo, _bar):
pass
pass
@rpc
func my_rpc_func_2(_foo, _bar, _baz):
pass
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 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 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 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 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 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.
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 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 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 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 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 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 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.
# 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,24 @@
class BaseClass:
signal release_bool
func get_bool() -> bool:
return true
class InheritedClass extends BaseClass:
func get_bool() -> bool:
await release_bool
return false
var instance: BaseClass = InheritedClass.new()
func test() -> void:
@warning_ignore("missing_await")
await_with_overwritten_coroutine()
instance.release_bool.emit()
func await_with_overwritten_coroutine():
var res_v := await instance.get_bool()
print(res_v == true)
var result: bool = bool(res_v)
print(result == true)

View file

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

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

@ -3,8 +3,8 @@
const External := preload("const_class_reference_external.notest.gd")
class Class1:
class Class2:
pass
class Class2:
pass
const Class1Alias = Class1
const Class1Class2Alias = Class1.Class2
@ -13,4 +13,4 @@ const ExternalAlias = External
const ExternalClassAlias = External.Class
func test():
pass
pass

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

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

View file

@ -12,4 +12,4 @@ func test():
for property in get_property_list():
if str(property.name).begins_with("test_"):
Utils.print_property_extended_info(property, self)
print(Utils.get_property_extended_info(property, self))

View file

@ -0,0 +1,102 @@
# Tests custom iterator correctness both typed and untyped.
class ExponentialIterator:
var base: int
var end: int
func _init(new_base: int, new_end: int):
self.base = new_base
self.end = new_end
func _iter_init(iter: Array):
iter[0] = 1
return iter[0] < end
func _iter_next(iter: Array):
iter[0] *= base
return iter[0] < end
func _iter_get(iter: Variant):
return iter
@warning_ignore_start("unsafe_method_access")
class StringIterator:
var s: String
func _init(value: String):
self.s = value
func _iter_init(iter: Array):
iter[0] = s
return !iter[0].is_empty()
func _iter_next(iter: Array):
iter[0] = iter[0].substr(1)
return !iter[0].is_empty()
func _iter_get(iter: Variant):
return iter.left(1)
func iterate_variant(v: Variant, break_condition: Callable = Callable()):
for i in v:
if break_condition.is_valid() and break_condition.call(i):
break
print(i)
func iterate_variant_nested(a: Variant, b: Variant, break_condition: Callable = Callable()):
for i in a:
for j in b:
if break_condition.is_valid() and break_condition.call(i, j):
break
print(i, j)
func test():
print("Test typed exp 2,16")
for i in ExponentialIterator.new(2, 17):
print(i)
print("Test variant exp 2,16")
iterate_variant(ExponentialIterator.new(2, 17))
print("Test typed exp -3,-27")
for i in ExponentialIterator.new(-3, 30):
print(i)
print("Test typed exp -3,-27")
iterate_variant(ExponentialIterator.new(-3, 30))
print("Test typed nested same str iterator")
var si := StringIterator.new("abc")
for i in si:
for j in si:
print(i, j)
print("Test nested variant same str iterator")
iterate_variant_nested(si, si)
print("Test break from typed str")
for i in StringIterator.new("world"):
if i in "hello":
break
print(i)
print("Test break from variant str")
iterate_variant(StringIterator.new("world"), func(i): return i in "hello")
print("Test break from nested diff typed")
for i: String in StringIterator.new("a2z"):
for j in ExponentialIterator.new(2, 100):
if j > ord(i):
break
print(i, j)
print("Test break from nested diff variant")
iterate_variant_nested(
StringIterator.new("a2z"),
ExponentialIterator.new(2, 100),
func(i: String, j): return j > ord(i)
)

View file

@ -0,0 +1,89 @@
GDTEST_OK
Test typed exp 2,16
1
2
4
8
16
Test variant exp 2,16
1
2
4
8
16
Test typed exp -3,-27
1
-3
9
-27
Test typed exp -3,-27
1
-3
9
-27
Test typed nested same str iterator
aa
ab
ac
ba
bb
bc
ca
cb
cc
Test nested variant same str iterator
aa
ab
ac
ba
bb
bc
ca
cb
cc
Test break from typed str
w
Test break from variant str
w
Test break from nested diff typed
a1
a2
a4
a8
a16
a32
a64
21
22
24
28
216
232
z1
z2
z4
z8
z16
z32
z64
Test break from nested diff variant
a1
a2
a4
a8
a16
a32
a64
21
22
24
28
216
232
z1
z2
z4
z8
z16
z32
z64

View file

@ -6,7 +6,7 @@ func test():
print(var_to_str(COLOR))
print(var_to_str(color))
var string := "Node"
var string_name := &"Node"
print(type_exists(string))
print(type_exists(string_name))
var string := "A"
var string_name := &"A"
print(ord(string))
print(ord(string_name))

View file

@ -1,5 +1,5 @@
GDTEST_OK
Color(1, 0, 0, 1)
Color(1, 0, 0, 1)
true
true
65
65

View file

@ -3,7 +3,7 @@ class_name TestMemberInfo
class MyClass:
pass
enum MyEnum {}
enum MyEnum { NONE }
static var test_static_var_untyped
static var test_static_var_weak_null = null
@ -16,14 +16,19 @@ var test_var_weak_int = 1
@export var test_var_weak_int_exported = 1
var test_var_weak_variant_type = TYPE_NIL
@export var test_var_weak_variant_type_exported = TYPE_NIL
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_node_process_mode: Node.ProcessMode
@warning_ignore("enum_variable_without_default")
var test_var_hard_my_enum: MyEnum
var test_var_hard_resource: Resource
var test_var_hard_this: TestMemberInfo
var test_var_hard_my_class: MyClass
var test_var_hard_array: Array
var test_var_hard_array_variant: Array[Variant]
var test_var_hard_array_int: Array[int]
var test_var_hard_array_variant_type: Array[Variant.Type]
var test_var_hard_array_node_process_mode: Array[Node.ProcessMode]
@ -31,7 +36,9 @@ var test_var_hard_array_my_enum: Array[MyEnum]
var test_var_hard_array_resource: Array[Resource]
var test_var_hard_array_this: Array[TestMemberInfo]
var test_var_hard_array_my_class: Array[MyClass]
var test_var_hard_dictionary: Dictionary
var test_var_hard_dictionary_variant_variant: Dictionary[Variant, Variant]
var test_var_hard_dictionary_int_variant: Dictionary[int, Variant]
var test_var_hard_dictionary_variant_int: Dictionary[Variant, int]
var test_var_hard_dictionary_int_int: Dictionary[int, int]
@ -41,14 +48,11 @@ var test_var_hard_dictionary_my_enum: Dictionary[MyEnum, MyEnum]
var test_var_hard_dictionary_resource: Dictionary[Resource, Resource]
var test_var_hard_dictionary_this: Dictionary[TestMemberInfo, TestMemberInfo]
var test_var_hard_dictionary_my_class: Dictionary[MyClass, MyClass]
var test_var_hard_resource: Resource
var test_var_hard_this: TestMemberInfo
var test_var_hard_my_class: MyClass
static func test_static_func(): pass
func test_func_implicit_void(): pass
func test_func_explicit_void() -> void: pass
func test_func_untyped(): pass
func test_func_void() -> void: pass
func test_func_weak_null(): return null
func test_func_weak_int(): return 1
func test_func_hard_variant() -> Variant: return null

View file

@ -15,7 +15,11 @@ var test_var_hard_variant_type: 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_resource: Resource
var test_var_hard_this: TestMemberInfo
var test_var_hard_my_class: RefCounted
var test_var_hard_array: Array
var test_var_hard_array_variant: Array
var test_var_hard_array_int: Array[int]
var test_var_hard_array_variant_type: Array[Variant.Type]
var test_var_hard_array_node_process_mode: Array[Node.ProcessMode]
@ -24,6 +28,7 @@ var test_var_hard_array_resource: Array[Resource]
var test_var_hard_array_this: Array[TestMemberInfo]
var test_var_hard_array_my_class: Array[RefCounted]
var test_var_hard_dictionary: Dictionary
var test_var_hard_dictionary_variant_variant: Dictionary
var test_var_hard_dictionary_int_variant: Dictionary[int, Variant]
var test_var_hard_dictionary_variant_int: Dictionary[Variant, int]
var test_var_hard_dictionary_int_int: Dictionary[int, int]
@ -33,18 +38,15 @@ var test_var_hard_dictionary_my_enum: Dictionary[TestMemberInfo.MyEnum, TestMemb
var test_var_hard_dictionary_resource: Dictionary[Resource, Resource]
var test_var_hard_dictionary_this: Dictionary[TestMemberInfo, TestMemberInfo]
var test_var_hard_dictionary_my_class: Dictionary[RefCounted, RefCounted]
var test_var_hard_resource: Resource
var test_var_hard_this: TestMemberInfo
var test_var_hard_my_class: RefCounted
static func test_static_func() -> void
func test_func_implicit_void() -> void
func test_func_explicit_void() -> void
static func test_static_func() -> Variant
func test_func_untyped() -> Variant
func test_func_void() -> void
func test_func_weak_null() -> Variant
func test_func_weak_int() -> Variant
func test_func_hard_variant() -> Variant
func test_func_hard_int() -> int
func test_func_args_1(_a: int, _b: Array[int], _c: Dictionary[int, int], _d: int = 1, _e: Variant = 2) -> void
func test_func_args_2(_a: Variant = 1, _b: Variant = null, _c: Variant = null, _d: Variant = 3) -> void
func test_func_args_1(_a: int, _b: Array[int], _c: Dictionary[int, int], _d: int = 1, _e: Variant = 2) -> Variant
func test_func_args_2(_a: Variant = 1, _b: Variant = null, _c: Variant = null, _d: Variant = 3) -> Variant
signal test_signal_1()
signal test_signal_2(a: Variant, b: Variant)
signal test_signal_3(a: int, b: Array[int], c: Dictionary[int, int])

View file

@ -0,0 +1,38 @@
@abstract class A:
@abstract func test_untyped_1()
@abstract func test_untyped_2()
@abstract func test_untyped_3()
@abstract func test_untyped_4()
@abstract func test_void() -> void
@abstract func test_variant() -> Variant
@abstract func test_int() -> int
class B extends A:
func test_untyped_1(): pass
func test_untyped_2(): return
func test_untyped_3(): return null
func test_untyped_4(): return 0
func test_void() -> void: pass
func test_variant() -> Variant: return null
func test_int() -> int: return 0
func test_script_method_signature(name: String, script: Script) -> void:
prints("---", name, "---")
for method: Dictionary in script.get_script_method_list():
if str(method.name).begins_with("test_"):
print(Utils.get_method_signature(method))
func test_instance_method_signature(name: String, instance: Object) -> void:
prints("---", name, "---")
for method in instance.get_method_list():
if str(method.name).begins_with("test_"):
print(Utils.get_method_signature(method))
func test():
var b := B.new()
print("=== Script Methods ===")
test_script_method_signature("A", A as GDScript)
test_script_method_signature("B", B as GDScript)
print("=== Instance Methods ===")
test_instance_method_signature("B", b)

View file

@ -0,0 +1,41 @@
GDTEST_OK
=== Script Methods ===
--- A ---
@abstract func test_untyped_1() -> Variant
@abstract func test_untyped_2() -> Variant
@abstract func test_untyped_3() -> Variant
@abstract func test_untyped_4() -> Variant
@abstract func test_void() -> void
@abstract func test_variant() -> Variant
@abstract func test_int() -> int
--- B ---
func test_untyped_1() -> Variant
func test_untyped_2() -> Variant
func test_untyped_3() -> Variant
func test_untyped_4() -> Variant
func test_void() -> void
func test_variant() -> Variant
func test_int() -> int
@abstract func test_untyped_1() -> Variant
@abstract func test_untyped_2() -> Variant
@abstract func test_untyped_3() -> Variant
@abstract func test_untyped_4() -> Variant
@abstract func test_void() -> void
@abstract func test_variant() -> Variant
@abstract func test_int() -> int
=== Instance Methods ===
--- B ---
func test_untyped_1() -> Variant
func test_untyped_2() -> Variant
func test_untyped_3() -> Variant
func test_untyped_4() -> Variant
func test_void() -> void
func test_variant() -> Variant
func test_int() -> int
@abstract func test_untyped_1() -> Variant
@abstract func test_untyped_2() -> Variant
@abstract func test_untyped_3() -> Variant
@abstract func test_untyped_4() -> Variant
@abstract func test_void() -> void
@abstract func test_variant() -> Variant
@abstract func test_int() -> int

View file

@ -24,39 +24,39 @@ var test_var_b2: Variant
--- C ---
=== Member Methods ===
--- B ---
static func test_static_func_b1() -> void
static func test_static_func_b2() -> void
func test_abstract_func_1() -> void
func test_abstract_func_2() -> void
func test_override_func_1() -> void
func test_override_func_2() -> void
func test_func_b1() -> void
func test_func_b2() -> void
@abstract func test_abstract_func_1() -> void
@abstract func test_abstract_func_2() -> void
func test_override_func_1() -> void
func test_override_func_2() -> void
static func test_static_func_b1() -> Variant
static func test_static_func_b2() -> Variant
func test_abstract_func_1() -> Variant
func test_abstract_func_2() -> Variant
func test_override_func_1() -> Variant
func test_override_func_2() -> Variant
func test_func_b1() -> Variant
func test_func_b2() -> Variant
@abstract func test_abstract_func_1() -> Variant
@abstract func test_abstract_func_2() -> Variant
func test_override_func_1() -> Variant
func test_override_func_2() -> Variant
--- C ---
static func test_static_func_c1() -> void
static func test_static_func_c2() -> void
func test_abstract_func_1() -> void
func test_abstract_func_2() -> void
func test_override_func_1() -> void
func test_override_func_2() -> void
func test_func_c1() -> void
func test_func_c2() -> void
static func test_static_func_b1() -> void
static func test_static_func_b2() -> void
func test_abstract_func_1() -> void
func test_abstract_func_2() -> void
func test_override_func_1() -> void
func test_override_func_2() -> void
func test_func_b1() -> void
func test_func_b2() -> void
@abstract func test_abstract_func_1() -> void
@abstract func test_abstract_func_2() -> void
func test_override_func_1() -> void
func test_override_func_2() -> void
static func test_static_func_c1() -> Variant
static func test_static_func_c2() -> Variant
func test_abstract_func_1() -> Variant
func test_abstract_func_2() -> Variant
func test_override_func_1() -> Variant
func test_override_func_2() -> Variant
func test_func_c1() -> Variant
func test_func_c2() -> Variant
static func test_static_func_b1() -> Variant
static func test_static_func_b2() -> Variant
func test_abstract_func_1() -> Variant
func test_abstract_func_2() -> Variant
func test_override_func_1() -> Variant
func test_override_func_2() -> Variant
func test_func_b1() -> Variant
func test_func_b2() -> Variant
@abstract func test_abstract_func_1() -> Variant
@abstract func test_abstract_func_2() -> Variant
func test_override_func_1() -> Variant
func test_override_func_2() -> Variant
=== Signals ===
--- B ---
signal test_signal_b1()

View file

@ -0,0 +1,31 @@
var a: Array = [1]:
set(v):
prints("set a", v)
a = v
get:
prints("get a")
return a
var b: PackedByteArray = [1]:
set(v):
prints("set b", v)
b = v
get:
prints("get b")
return b
var c: PackedVector2Array = [Vector2.ONE]:
set(v):
prints("set c", v)
c = v
get:
prints("get c")
return c
func test():
a[0] = 2
print(a)
b[0] = 2
print(b)
c[0].x = 2
print(c)

View file

@ -0,0 +1,10 @@
GDTEST_OK
get a
get a
[2]
get b
get b
[2]
get c
get c
[(2.0, 1.0)]

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