initial commit, 4.5 stable
Some checks failed
🔗 GHA / 📊 Static checks (push) Has been cancelled
🔗 GHA / 🤖 Android (push) Has been cancelled
🔗 GHA / 🍏 iOS (push) Has been cancelled
🔗 GHA / 🐧 Linux (push) Has been cancelled
🔗 GHA / 🍎 macOS (push) Has been cancelled
🔗 GHA / 🏁 Windows (push) Has been cancelled
🔗 GHA / 🌐 Web (push) Has been cancelled
Some checks failed
🔗 GHA / 📊 Static checks (push) Has been cancelled
🔗 GHA / 🤖 Android (push) Has been cancelled
🔗 GHA / 🍏 iOS (push) Has been cancelled
🔗 GHA / 🐧 Linux (push) Has been cancelled
🔗 GHA / 🍎 macOS (push) Has been cancelled
🔗 GHA / 🏁 Windows (push) Has been cancelled
🔗 GHA / 🌐 Web (push) Has been cancelled
This commit is contained in:
@@ -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()
|
@@ -0,0 +1,5 @@
|
||||
GDTEST_OK
|
||||
text_1b
|
||||
text_2c
|
||||
text_1e
|
||||
text_2c text_2d
|
@@ -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.
|
@@ -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
|
@@ -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"))
|
@@ -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
|
@@ -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()
|
@@ -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
|
@@ -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)
|
@@ -0,0 +1,5 @@
|
||||
GDTEST_OK
|
||||
10
|
||||
20
|
||||
30
|
||||
20
|
@@ -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)
|
@@ -0,0 +1,6 @@
|
||||
GDTEST_OK
|
||||
16
|
||||
(8, 16)
|
||||
(8, 16, 24)
|
||||
(8, 16, 24, 32)
|
||||
[1, 2, 3, 4, 5]
|
@@ -0,0 +1,7 @@
|
||||
func wait() -> void:
|
||||
pass
|
||||
|
||||
func test():
|
||||
@warning_ignore("redundant_await")
|
||||
await wait()
|
||||
print("end")
|
@@ -0,0 +1,2 @@
|
||||
GDTEST_OK
|
||||
end
|
@@ -0,0 +1,25 @@
|
||||
signal no_parameters()
|
||||
signal one_parameter(number)
|
||||
signal two_parameters(number1, number2)
|
||||
|
||||
func await_no_parameters():
|
||||
var result = await no_parameters
|
||||
print(result)
|
||||
|
||||
func await_one_parameter():
|
||||
var result = await one_parameter
|
||||
print(result)
|
||||
|
||||
func await_two_parameters():
|
||||
var result = await two_parameters
|
||||
print(result)
|
||||
|
||||
func test():
|
||||
await_no_parameters()
|
||||
no_parameters.emit()
|
||||
|
||||
await_one_parameter()
|
||||
one_parameter.emit(1)
|
||||
|
||||
await_two_parameters()
|
||||
two_parameters.emit(1, 2)
|
@@ -0,0 +1,4 @@
|
||||
GDTEST_OK
|
||||
<null>
|
||||
1
|
||||
[1, 2]
|
@@ -0,0 +1,8 @@
|
||||
# https://github.com/godotengine/godot/issues/50894
|
||||
|
||||
func test():
|
||||
print(await not_coroutine())
|
||||
|
||||
|
||||
func not_coroutine() -> String:
|
||||
return "awaited"
|
@@ -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
|
@@ -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)
|
@@ -0,0 +1,5 @@
|
||||
GDTEST_OK
|
||||
[1, 2, 3]
|
||||
[]
|
||||
{ 1: 2, 3: 4 }
|
||||
{ }
|
@@ -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()
|
@@ -0,0 +1,2 @@
|
||||
GDTEST_OK
|
||||
false
|
@@ -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])
|
@@ -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"]
|
@@ -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)
|
@@ -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)]
|
@@ -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)
|
@@ -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
|
@@ -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)
|
@@ -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
|
@@ -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)
|
@@ -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
|
@@ -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)
|
@@ -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
|
@@ -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
|
@@ -0,0 +1 @@
|
||||
GDTEST_OK
|
@@ -0,0 +1,2 @@
|
||||
class Class:
|
||||
pass
|
@@ -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')
|
@@ -0,0 +1,2 @@
|
||||
GDTEST_OK
|
||||
ok
|
@@ -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')
|
@@ -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
|
@@ -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()
|
@@ -0,0 +1,2 @@
|
||||
GDTEST_OK
|
||||
ok
|
@@ -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)
|
@@ -0,0 +1,3 @@
|
||||
GDTEST_OK
|
||||
GDScript::new
|
||||
GDScriptNativeClass::new
|
@@ -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")
|
@@ -0,0 +1,2 @@
|
||||
GDTEST_OK
|
||||
ok
|
@@ -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
|
@@ -0,0 +1,3 @@
|
||||
GDTEST_OK
|
||||
TEST OTHER DICTIONARY: 0
|
||||
TEST OTHER DICTIONARY: 0
|
@@ -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)
|
@@ -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
|
@@ -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.
|
@@ -0,0 +1,2 @@
|
||||
GDTEST_OK
|
||||
done
|
@@ -0,0 +1,40 @@
|
||||
# We could use @export_custom to really test every property usage, but we know for good
|
||||
# that duplicating scripted properties flows through the same code already thoroughly tested
|
||||
# in the [Resource] test cases. The same goes for all the potential deep duplicate modes.
|
||||
# Therefore, it's enough to ensure the exported scriped properties are copied when invoking
|
||||
# duplication by each entry point.
|
||||
class TestResource:
|
||||
extends Resource
|
||||
@export var text: String = "holaaa"
|
||||
@export var arr: Array = [1, 2, 3]
|
||||
@export var dict: Dictionary = { "a": 1, "b": 2 }
|
||||
|
||||
func test():
|
||||
# Via Resource type.
|
||||
var res := TestResource.new()
|
||||
var dupe: TestResource
|
||||
|
||||
dupe = res.duplicate()
|
||||
print(dupe.text)
|
||||
print(dupe.arr)
|
||||
print(dupe.dict)
|
||||
|
||||
dupe = res.duplicate_deep()
|
||||
print(dupe.text)
|
||||
print(dupe.arr)
|
||||
print(dupe.dict)
|
||||
|
||||
# Via Variant type.
|
||||
|
||||
var res_var = TestResource.new()
|
||||
var dupe_var
|
||||
|
||||
dupe_var = res_var.duplicate()
|
||||
print(dupe_var.text)
|
||||
print(dupe_var.arr)
|
||||
print(dupe_var.dict)
|
||||
|
||||
dupe_var = res_var.duplicate_deep()
|
||||
print(dupe_var.text)
|
||||
print(dupe_var.arr)
|
||||
print(dupe_var.dict)
|
@@ -0,0 +1,13 @@
|
||||
GDTEST_OK
|
||||
holaaa
|
||||
[1, 2, 3]
|
||||
{ "a": 1, "b": 2 }
|
||||
holaaa
|
||||
[1, 2, 3]
|
||||
{ "a": 1, "b": 2 }
|
||||
holaaa
|
||||
[1, 2, 3]
|
||||
{ "a": 1, "b": 2 }
|
||||
holaaa
|
||||
[1, 2, 3]
|
||||
{ "a": 1, "b": 2 }
|
@@ -0,0 +1,12 @@
|
||||
# https://github.com/godotengine/godot/issues/89439
|
||||
extends Node
|
||||
|
||||
signal my_signal
|
||||
|
||||
func async_func():
|
||||
await my_signal
|
||||
my_signal.emit()
|
||||
|
||||
func test():
|
||||
async_func()
|
||||
my_signal.emit()
|
@@ -0,0 +1 @@
|
||||
GDTEST_OK
|
@@ -0,0 +1,22 @@
|
||||
# https://github.com/godotengine/godot/issues/89439
|
||||
|
||||
signal my_signal
|
||||
|
||||
func foo():
|
||||
print("Foo")
|
||||
my_signal.emit()
|
||||
|
||||
func bar():
|
||||
print("Bar")
|
||||
|
||||
func baz():
|
||||
print("Baz")
|
||||
|
||||
func test():
|
||||
@warning_ignore("return_value_discarded")
|
||||
my_signal.connect(foo, CONNECT_ONE_SHOT)
|
||||
@warning_ignore("return_value_discarded")
|
||||
my_signal.connect(bar, CONNECT_ONE_SHOT)
|
||||
@warning_ignore("return_value_discarded")
|
||||
my_signal.connect(baz)
|
||||
my_signal.emit()
|
@@ -0,0 +1,5 @@
|
||||
GDTEST_OK
|
||||
Foo
|
||||
Baz
|
||||
Bar
|
||||
Baz
|
@@ -0,0 +1,15 @@
|
||||
# GH-73843
|
||||
@export_group("Resource")
|
||||
|
||||
# GH-78252
|
||||
@export var test_1: int
|
||||
@export_category("test_1")
|
||||
@export var test_2: int
|
||||
|
||||
func test():
|
||||
var resource := Resource.new()
|
||||
prints("Not shadowed:", resource.get_class())
|
||||
|
||||
for property in get_property_list():
|
||||
if str(property.name).begins_with("test_"):
|
||||
Utils.print_property_extended_info(property, self)
|
@@ -0,0 +1,8 @@
|
||||
GDTEST_OK
|
||||
Not shadowed: Resource
|
||||
var test_1: int = 0
|
||||
hint=NONE hint_string="" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
@export_category("test_1")
|
||||
hint=NONE hint_string="" usage=CATEGORY class_name=&""
|
||||
var test_2: int = 0
|
||||
hint=NONE hint_string="" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
@@ -0,0 +1,14 @@
|
||||
# GH-80157
|
||||
|
||||
extends Node
|
||||
|
||||
func f():
|
||||
pass
|
||||
|
||||
signal s()
|
||||
|
||||
func test():
|
||||
print(f)
|
||||
print(s)
|
||||
print(get_child)
|
||||
print(ready)
|
@@ -0,0 +1,5 @@
|
||||
GDTEST_OK
|
||||
Node::f
|
||||
Node::[signal]s
|
||||
Node::get_child
|
||||
Node::[signal]ready
|
@@ -0,0 +1,45 @@
|
||||
func test():
|
||||
print("Test range.")
|
||||
for e: float in range(2, 5):
|
||||
var elem := e
|
||||
prints(var_to_str(e), var_to_str(elem))
|
||||
|
||||
print("Test int.")
|
||||
for e: float in 3:
|
||||
var elem := e
|
||||
prints(var_to_str(e), var_to_str(elem))
|
||||
|
||||
print("Test untyped int array.")
|
||||
var a1 := [10, 20, 30]
|
||||
for e: float in a1:
|
||||
var elem := e
|
||||
prints(var_to_str(e), var_to_str(elem))
|
||||
|
||||
print("Test typed int array.")
|
||||
var a2: Array[int] = [10, 20, 30]
|
||||
for e: float in a2:
|
||||
var elem := e
|
||||
prints(var_to_str(e), var_to_str(elem))
|
||||
|
||||
# GH-82021
|
||||
print("Test implicitly typed array literal.")
|
||||
for e: float in [100, 200, 300]:
|
||||
var elem := e
|
||||
prints(var_to_str(e), var_to_str(elem))
|
||||
|
||||
print("Test String-keys dictionary.")
|
||||
var d1 := { a = 1, b = 2, c = 3 }
|
||||
for k: StringName in d1:
|
||||
var key := k
|
||||
prints(var_to_str(k), var_to_str(key))
|
||||
|
||||
print("Test RefCounted-keys dictionary.")
|
||||
var d2 := { RefCounted.new(): 1, Resource.new(): 2, ConfigFile.new(): 3 }
|
||||
for k: RefCounted in d2:
|
||||
var key := k
|
||||
prints(k.get_class(), key.get_class())
|
||||
|
||||
print("Test implicitly typed dictionary literal.")
|
||||
for k: StringName in { x = 123, y = 456, z = 789 }:
|
||||
var key := k
|
||||
prints(var_to_str(k), var_to_str(key))
|
@@ -0,0 +1,33 @@
|
||||
GDTEST_OK
|
||||
Test range.
|
||||
2.0 2.0
|
||||
3.0 3.0
|
||||
4.0 4.0
|
||||
Test int.
|
||||
0.0 0.0
|
||||
1.0 1.0
|
||||
2.0 2.0
|
||||
Test untyped int array.
|
||||
10.0 10.0
|
||||
20.0 20.0
|
||||
30.0 30.0
|
||||
Test typed int array.
|
||||
10.0 10.0
|
||||
20.0 20.0
|
||||
30.0 30.0
|
||||
Test implicitly typed array literal.
|
||||
100.0 100.0
|
||||
200.0 200.0
|
||||
300.0 300.0
|
||||
Test String-keys dictionary.
|
||||
&"a" &"a"
|
||||
&"b" &"b"
|
||||
&"c" &"c"
|
||||
Test RefCounted-keys dictionary.
|
||||
RefCounted RefCounted
|
||||
Resource Resource
|
||||
ConfigFile ConfigFile
|
||||
Test implicitly typed dictionary literal.
|
||||
&"x" &"x"
|
||||
&"y" &"y"
|
||||
&"z" &"z"
|
@@ -0,0 +1,51 @@
|
||||
const constant_float = 1.0
|
||||
const constant_int = 1
|
||||
enum { enum_value = 1 }
|
||||
|
||||
class Iterator:
|
||||
func _iter_init(_count):
|
||||
return true
|
||||
func _iter_next(_count):
|
||||
return false
|
||||
func _iter_get(_count) -> StringName:
|
||||
return &'custom'
|
||||
|
||||
func test():
|
||||
var hard_float := 1.0
|
||||
var hard_int := 1
|
||||
var hard_string := '0'
|
||||
var hard_iterator := Iterator.new()
|
||||
|
||||
var variant_float: Variant = hard_float
|
||||
var variant_int: Variant = hard_int
|
||||
var variant_string: Variant = hard_string
|
||||
var variant_iterator: Variant = hard_iterator
|
||||
|
||||
for i in 1.0:
|
||||
print(typeof(i) == TYPE_FLOAT)
|
||||
for i in 1:
|
||||
print(typeof(i) == TYPE_INT)
|
||||
for i in 'a':
|
||||
print(typeof(i) == TYPE_STRING)
|
||||
for i in Iterator.new():
|
||||
print(typeof(i) == TYPE_STRING_NAME)
|
||||
|
||||
for i in hard_float:
|
||||
print(typeof(i) == TYPE_FLOAT)
|
||||
for i in hard_int:
|
||||
print(typeof(i) == TYPE_INT)
|
||||
for i in hard_string:
|
||||
print(typeof(i) == TYPE_STRING)
|
||||
for i in hard_iterator:
|
||||
print(typeof(i) == TYPE_STRING_NAME)
|
||||
|
||||
for i in variant_float:
|
||||
print(typeof(i) == TYPE_FLOAT)
|
||||
for i in variant_int:
|
||||
print(typeof(i) == TYPE_INT)
|
||||
for i in variant_string:
|
||||
print(typeof(i) == TYPE_STRING)
|
||||
for i in variant_iterator:
|
||||
print(typeof(i) == TYPE_STRING_NAME)
|
||||
|
||||
print('ok')
|
@@ -0,0 +1,14 @@
|
||||
GDTEST_OK
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
true
|
||||
ok
|
11
modules/gdscript/tests/scripts/runtime/features/for_range.gd
Normal file
11
modules/gdscript/tests/scripts/runtime/features/for_range.gd
Normal file
@@ -0,0 +1,11 @@
|
||||
func test():
|
||||
# GH-83293
|
||||
for x in range(1 << 31, (1 << 31) + 3):
|
||||
print(x)
|
||||
for x in range(1 << 62, (1 << 62) + 3):
|
||||
print(x)
|
||||
|
||||
# GH-107392
|
||||
var n = 1.0
|
||||
for x in range(n):
|
||||
print(x)
|
@@ -0,0 +1,8 @@
|
||||
GDTEST_OK
|
||||
2147483648
|
||||
2147483649
|
||||
2147483650
|
||||
4611686018427387904
|
||||
4611686018427387905
|
||||
4611686018427387906
|
||||
0
|
@@ -0,0 +1,10 @@
|
||||
func test():
|
||||
var node := Node.new()
|
||||
var callable: Callable = node.free
|
||||
callable.call()
|
||||
print(node)
|
||||
|
||||
node = Node.new()
|
||||
callable = node["free"]
|
||||
callable.call()
|
||||
print(node)
|
@@ -0,0 +1,3 @@
|
||||
GDTEST_OK
|
||||
<Freed Object>
|
||||
<Freed Object>
|
20
modules/gdscript/tests/scripts/runtime/features/gdscript.gd
Normal file
20
modules/gdscript/tests/scripts/runtime/features/gdscript.gd
Normal file
@@ -0,0 +1,20 @@
|
||||
func test():
|
||||
var gdscr: = GDScript.new()
|
||||
gdscr.source_code = '''
|
||||
extends Resource
|
||||
|
||||
func test() -> void:
|
||||
prints("Outer")
|
||||
var inner = InnerClass.new()
|
||||
|
||||
class InnerClass:
|
||||
func _init() -> void:
|
||||
prints("Inner")
|
||||
'''
|
||||
@warning_ignore("return_value_discarded")
|
||||
gdscr.reload()
|
||||
|
||||
var inst = gdscr.new()
|
||||
|
||||
@warning_ignore("unsafe_method_access")
|
||||
inst.test()
|
@@ -0,0 +1,3 @@
|
||||
GDTEST_OK
|
||||
Outer
|
||||
Inner
|
@@ -0,0 +1,12 @@
|
||||
func test():
|
||||
const COLOR = Color8(255, 0.0, false)
|
||||
var false_value := false
|
||||
@warning_ignore("narrowing_conversion")
|
||||
var color = Color8(255, 0.0, false_value)
|
||||
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))
|
@@ -0,0 +1,5 @@
|
||||
GDTEST_OK
|
||||
Color(1, 0, 0, 1)
|
||||
Color(1, 0, 0, 1)
|
||||
true
|
||||
true
|
@@ -0,0 +1,15 @@
|
||||
# https://github.com/godotengine/godot/issues/68184
|
||||
|
||||
var node: Node:
|
||||
get:
|
||||
return node
|
||||
set(n):
|
||||
node = n
|
||||
|
||||
|
||||
func test():
|
||||
node = Node.new()
|
||||
node.free()
|
||||
|
||||
if !is_instance_valid(node):
|
||||
print("It is freed")
|
@@ -0,0 +1,2 @@
|
||||
GDTEST_OK
|
||||
It is freed
|
@@ -0,0 +1,18 @@
|
||||
# https://github.com/godotengine/godot/issues/93952
|
||||
|
||||
func foo():
|
||||
pass
|
||||
|
||||
func test():
|
||||
var a: int
|
||||
|
||||
var lambda_self := func (x: int) -> void:
|
||||
foo()
|
||||
print(a, x)
|
||||
|
||||
print(lambda_self.get_argument_count()) # Should print 1.
|
||||
|
||||
var lambda_non_self := func (x: int) -> void:
|
||||
print(a, x)
|
||||
|
||||
print(lambda_non_self.get_argument_count()) # Should print 1.
|
@@ -0,0 +1,3 @@
|
||||
GDTEST_OK
|
||||
1
|
||||
1
|
@@ -0,0 +1,26 @@
|
||||
# GH-92217
|
||||
# TODO: Add more tests.
|
||||
|
||||
static var static_var: int:
|
||||
set(value):
|
||||
prints("set static_var", value)
|
||||
get:
|
||||
print("get static_var")
|
||||
return 0
|
||||
|
||||
var member_var: int:
|
||||
set(value):
|
||||
prints("set member_var", value)
|
||||
get:
|
||||
print("get member_var")
|
||||
return 0
|
||||
|
||||
func test():
|
||||
var lambda := func ():
|
||||
var _tmp := static_var
|
||||
_tmp = member_var
|
||||
|
||||
static_var = 1
|
||||
member_var = 1
|
||||
|
||||
lambda.call()
|
@@ -0,0 +1,5 @@
|
||||
GDTEST_OK
|
||||
get static_var
|
||||
get member_var
|
||||
set static_var 1
|
||||
set member_var 1
|
@@ -0,0 +1,21 @@
|
||||
# https://github.com/godotengine/godot/issues/94074
|
||||
|
||||
func foo():
|
||||
pass
|
||||
|
||||
func test():
|
||||
var lambda_self := func test() -> void:
|
||||
foo()
|
||||
var anon_lambda_self := func() -> void:
|
||||
foo()
|
||||
|
||||
print(lambda_self.get_method()) # Should print "test".
|
||||
print(anon_lambda_self.get_method()) # Should print "<anonymous lambda>".
|
||||
|
||||
var lambda_non_self := func test() -> void:
|
||||
pass
|
||||
var anon_lambda_non_self := func() -> void:
|
||||
pass
|
||||
|
||||
print(lambda_non_self.get_method()) # Should print "test".
|
||||
print(anon_lambda_non_self.get_method()) # Should print "<anonymous lambda>".
|
@@ -0,0 +1,5 @@
|
||||
GDTEST_OK
|
||||
test
|
||||
<anonymous lambda>
|
||||
test
|
||||
<anonymous lambda>
|
@@ -0,0 +1,23 @@
|
||||
var member = "foo"
|
||||
|
||||
func bar():
|
||||
print("bar")
|
||||
|
||||
func test():
|
||||
var lambda1 = func():
|
||||
print(member)
|
||||
lambda1.call()
|
||||
|
||||
var lambda2 = func():
|
||||
var nested = func():
|
||||
print(member)
|
||||
nested.call()
|
||||
lambda2.call()
|
||||
|
||||
var lambda3 = func():
|
||||
bar()
|
||||
lambda3.call()
|
||||
|
||||
var lambda4 = func():
|
||||
return self
|
||||
print(lambda4.call() == self)
|
@@ -0,0 +1,5 @@
|
||||
GDTEST_OK
|
||||
foo
|
||||
foo
|
||||
bar
|
||||
true
|
@@ -0,0 +1,4 @@
|
||||
func test():
|
||||
var dict = {}
|
||||
dict.test = 1
|
||||
print(dict.test)
|
@@ -0,0 +1,2 @@
|
||||
GDTEST_OK
|
||||
1
|
@@ -0,0 +1,6 @@
|
||||
func test():
|
||||
match null:
|
||||
null:
|
||||
print('null matched')
|
||||
_:
|
||||
pass
|
@@ -0,0 +1,2 @@
|
||||
GDTEST_OK
|
||||
null matched
|
@@ -0,0 +1,71 @@
|
||||
var global := 0
|
||||
|
||||
func test():
|
||||
var a = 0
|
||||
var b = 1
|
||||
|
||||
match a:
|
||||
0 when b == 0:
|
||||
print("does not run" if true else "")
|
||||
0 when b == 1:
|
||||
print("guards work")
|
||||
_:
|
||||
print("does not run")
|
||||
|
||||
match a:
|
||||
var a_bind when b == 0:
|
||||
prints("a is", a_bind, "and b is 0")
|
||||
var a_bind when b == 1:
|
||||
prints("a is", a_bind, "and b is 1")
|
||||
_:
|
||||
print("does not run")
|
||||
|
||||
match a:
|
||||
var a_bind when a_bind < 0:
|
||||
print("a is less than zero")
|
||||
var a_bind when a_bind == 0:
|
||||
print("a is equal to zero")
|
||||
_:
|
||||
print("a is more than zero")
|
||||
|
||||
match [1, 2, 3]:
|
||||
[1, 2, var element] when element == 0:
|
||||
print("does not run")
|
||||
[1, 2, var element] when element == 3:
|
||||
print("3rd element is 3")
|
||||
|
||||
match a:
|
||||
_ when b == 0:
|
||||
print("does not run")
|
||||
_ when b == 1:
|
||||
print("works with wildcard too.")
|
||||
_:
|
||||
print("does not run")
|
||||
|
||||
match a:
|
||||
0, 1 when b == 0:
|
||||
print("does not run")
|
||||
0, 1 when b == 1:
|
||||
print("guard with multiple patterns")
|
||||
_:
|
||||
print("does not run")
|
||||
|
||||
match a:
|
||||
0 when b == 0:
|
||||
print("does not run")
|
||||
0:
|
||||
print("regular pattern after guard mismatch")
|
||||
|
||||
match a:
|
||||
1 when side_effect():
|
||||
print("should not run the side effect call")
|
||||
0 when side_effect():
|
||||
print("will run the side effect call, but not this")
|
||||
_:
|
||||
Utils.check(global == 1)
|
||||
print("side effect only ran once")
|
||||
|
||||
func side_effect():
|
||||
print("side effect")
|
||||
global += 1
|
||||
return false
|
@@ -0,0 +1,10 @@
|
||||
GDTEST_OK
|
||||
guards work
|
||||
a is 0 and b is 1
|
||||
a is equal to zero
|
||||
3rd element is 3
|
||||
works with wildcard too.
|
||||
guard with multiple patterns
|
||||
regular pattern after guard mismatch
|
||||
side effect
|
||||
side effect only ran once
|
@@ -0,0 +1,83 @@
|
||||
class_name TestMemberInfo
|
||||
|
||||
class MyClass:
|
||||
pass
|
||||
|
||||
enum MyEnum {}
|
||||
|
||||
static var test_static_var_untyped
|
||||
static var test_static_var_weak_null = null
|
||||
static var test_static_var_weak_int = 1
|
||||
static var test_static_var_hard_int: int
|
||||
|
||||
var test_var_untyped
|
||||
var test_var_weak_null = null
|
||||
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_array: 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]
|
||||
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_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]
|
||||
var test_var_hard_dictionary_variant_type: Dictionary[Variant.Type, Variant.Type]
|
||||
var test_var_hard_dictionary_node_process_mode: Dictionary[Node.ProcessMode, Node.ProcessMode]
|
||||
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_weak_null(): return null
|
||||
func test_func_weak_int(): return 1
|
||||
func test_func_hard_variant() -> Variant: return null
|
||||
func test_func_hard_int() -> int: return 1
|
||||
func test_func_args_1(_a: int, _b: Array[int], _c: Dictionary[int, int], _d: int = 1, _e = 2): pass
|
||||
func test_func_args_2(_a = 1, _b = _a, _c = [2], _d = 3): pass
|
||||
|
||||
@warning_ignore_start("unused_signal")
|
||||
signal test_signal_1()
|
||||
signal test_signal_2(a: Variant, b)
|
||||
signal test_signal_3(a: int, b: Array[int], c: Dictionary[int, int])
|
||||
signal test_signal_4(a: Variant.Type, b: Array[Variant.Type], c: Dictionary[Variant.Type, Variant.Type])
|
||||
signal test_signal_5(a: MyEnum, b: Array[MyEnum], c: Dictionary[MyEnum, MyEnum])
|
||||
signal test_signal_6(a: Resource, b: Array[Resource], c: Dictionary[Resource, Resource])
|
||||
signal test_signal_7(a: TestMemberInfo, b: Array[TestMemberInfo], c: Dictionary[TestMemberInfo, TestMemberInfo])
|
||||
signal test_signal_8(a: MyClass, b: Array[MyClass], c: Dictionary[MyClass, MyClass])
|
||||
@warning_ignore_restore("unused_signal")
|
||||
|
||||
func test():
|
||||
var script: Script = get_script()
|
||||
for property in script.get_property_list():
|
||||
if str(property.name).begins_with("test_"):
|
||||
print(Utils.get_property_signature(property, null, true))
|
||||
for property in get_property_list():
|
||||
if str(property.name).begins_with("test_"):
|
||||
print(Utils.get_property_signature(property))
|
||||
for method in get_method_list():
|
||||
if str(method.name).begins_with("test_"):
|
||||
print(Utils.get_method_signature(method))
|
||||
for method in get_signal_list():
|
||||
if str(method.name).begins_with("test_"):
|
||||
print(Utils.get_method_signature(method, true))
|
@@ -0,0 +1,55 @@
|
||||
GDTEST_OK
|
||||
static var test_static_var_untyped: Variant
|
||||
static var test_static_var_weak_null: Variant
|
||||
static var test_static_var_weak_int: Variant
|
||||
static var test_static_var_hard_int: int
|
||||
var test_var_untyped: Variant
|
||||
var test_var_weak_null: Variant
|
||||
var test_var_weak_int: Variant
|
||||
var test_var_weak_int_exported: int
|
||||
var test_var_weak_variant_type: Variant
|
||||
var test_var_weak_variant_type_exported: Variant.Type
|
||||
var test_var_hard_variant: Variant
|
||||
var test_var_hard_int: int
|
||||
var test_var_hard_variant_type: Variant.Type
|
||||
var test_var_hard_variant_type_exported: Variant.Type
|
||||
var test_var_hard_node_process_mode: Node.ProcessMode
|
||||
var test_var_hard_my_enum: TestMemberInfo.MyEnum
|
||||
var test_var_hard_array: Array
|
||||
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]
|
||||
var test_var_hard_array_my_enum: Array[TestMemberInfo.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[RefCounted]
|
||||
var test_var_hard_dictionary: 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]
|
||||
var test_var_hard_dictionary_variant_type: Dictionary[Variant.Type, Variant.Type]
|
||||
var test_var_hard_dictionary_node_process_mode: Dictionary[Node.ProcessMode, Node.ProcessMode]
|
||||
var test_var_hard_dictionary_my_enum: Dictionary[TestMemberInfo.MyEnum, TestMemberInfo.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[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
|
||||
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
|
||||
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])
|
||||
signal test_signal_4(a: Variant.Type, b: Array[Variant.Type], c: Dictionary[Variant.Type, Variant.Type])
|
||||
signal test_signal_5(a: TestMemberInfo.MyEnum, b: Array[TestMemberInfo.MyEnum], c: Dictionary[TestMemberInfo.MyEnum, TestMemberInfo.MyEnum])
|
||||
signal test_signal_6(a: Resource, b: Array[Resource], c: Dictionary[Resource, Resource])
|
||||
signal test_signal_7(a: TestMemberInfo, b: Array[TestMemberInfo], c: Dictionary[TestMemberInfo, TestMemberInfo])
|
||||
signal test_signal_8(a: RefCounted, b: Array[RefCounted], c: Dictionary[RefCounted, RefCounted])
|
@@ -0,0 +1,81 @@
|
||||
# GH-82169
|
||||
|
||||
@warning_ignore_start("unused_signal")
|
||||
|
||||
@abstract class A:
|
||||
@abstract func test_abstract_func_1()
|
||||
@abstract func test_abstract_func_2()
|
||||
func test_override_func_1(): pass
|
||||
func test_override_func_2(): pass
|
||||
|
||||
class B extends A:
|
||||
static var test_static_var_b1
|
||||
static var test_static_var_b2
|
||||
var test_var_b1
|
||||
var test_var_b2
|
||||
static func test_static_func_b1(): pass
|
||||
static func test_static_func_b2(): pass
|
||||
func test_abstract_func_1(): pass
|
||||
func test_abstract_func_2(): pass
|
||||
func test_override_func_1(): pass
|
||||
func test_override_func_2(): pass
|
||||
func test_func_b1(): pass
|
||||
func test_func_b2(): pass
|
||||
signal test_signal_b1()
|
||||
signal test_signal_b2()
|
||||
|
||||
class C extends B:
|
||||
static var test_static_var_c1
|
||||
static var test_static_var_c2
|
||||
var test_var_c1
|
||||
var test_var_c2
|
||||
static func test_static_func_c1(): pass
|
||||
static func test_static_func_c2(): pass
|
||||
func test_abstract_func_1(): pass
|
||||
func test_abstract_func_2(): pass
|
||||
func test_override_func_1(): pass
|
||||
func test_override_func_2(): pass
|
||||
func test_func_c1(): pass
|
||||
func test_func_c2(): pass
|
||||
signal test_signal_c1()
|
||||
signal test_signal_c2()
|
||||
|
||||
func test_property_signature(name: String, base: Object, is_static: bool = false) -> void:
|
||||
prints("---", name, "---")
|
||||
for property in base.get_property_list():
|
||||
if str(property.name).begins_with("test_"):
|
||||
print(Utils.get_property_signature(property, null, is_static))
|
||||
|
||||
func test_method_signature(name: String, base: Object) -> void:
|
||||
prints("---", name, "---")
|
||||
for method in base.get_method_list():
|
||||
if str(method.name).begins_with("test_"):
|
||||
print(Utils.get_method_signature(method))
|
||||
|
||||
func test_signal_signature(name: String, base: Object) -> void:
|
||||
prints("---", name, "---")
|
||||
for method in base.get_signal_list():
|
||||
if str(method.name).begins_with("test_"):
|
||||
print(Utils.get_method_signature(method, true))
|
||||
|
||||
func test():
|
||||
var b := B.new()
|
||||
var c := C.new()
|
||||
|
||||
print("=== Class Properties ===")
|
||||
test_property_signature("A", A as GDScript, true)
|
||||
test_property_signature("B", B as GDScript, true)
|
||||
test_property_signature("C", C as GDScript, true)
|
||||
print("=== Member Properties ===")
|
||||
test_property_signature("B", b)
|
||||
test_property_signature("C", c)
|
||||
print("=== Class Methods ===")
|
||||
test_method_signature("A", A as GDScript)
|
||||
test_method_signature("B", B as GDScript)
|
||||
test_method_signature("C", C as GDScript)
|
||||
print("=== Member Methods ===")
|
||||
test_method_signature("B", b)
|
||||
test_method_signature("C", c)
|
||||
print("=== Signals ===")
|
||||
test_signal_signature("B", b)
|
||||
test_signal_signature("C", c)
|
@@ -0,0 +1,68 @@
|
||||
GDTEST_OK
|
||||
=== Class Properties ===
|
||||
--- A ---
|
||||
--- B ---
|
||||
static var test_static_var_b1: Variant
|
||||
static var test_static_var_b2: Variant
|
||||
--- C ---
|
||||
static var test_static_var_b1: Variant
|
||||
static var test_static_var_b2: Variant
|
||||
static var test_static_var_c1: Variant
|
||||
static var test_static_var_c2: Variant
|
||||
=== Member Properties ===
|
||||
--- B ---
|
||||
var test_var_b1: Variant
|
||||
var test_var_b2: Variant
|
||||
--- C ---
|
||||
var test_var_c1: Variant
|
||||
var test_var_c2: Variant
|
||||
var test_var_b1: Variant
|
||||
var test_var_b2: Variant
|
||||
=== Class Methods ===
|
||||
--- A ---
|
||||
--- B ---
|
||||
--- 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
|
||||
--- 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
|
||||
=== Signals ===
|
||||
--- B ---
|
||||
signal test_signal_b1()
|
||||
signal test_signal_b2()
|
||||
--- C ---
|
||||
signal test_signal_c1()
|
||||
signal test_signal_c2()
|
||||
signal test_signal_b1()
|
||||
signal test_signal_b2()
|
47
modules/gdscript/tests/scripts/runtime/features/metatypes.gd
Normal file
47
modules/gdscript/tests/scripts/runtime/features/metatypes.gd
Normal file
@@ -0,0 +1,47 @@
|
||||
class MyClass:
|
||||
const TEST = 10
|
||||
|
||||
enum MyEnum {A, B, C}
|
||||
|
||||
const Other = preload("./metatypes.notest.gd")
|
||||
|
||||
var test_native := JSON
|
||||
var test_script := Other
|
||||
var test_class := MyClass
|
||||
var test_enum := MyEnum
|
||||
|
||||
func check_gdscript_native_class(value: Variant) -> void:
|
||||
print(var_to_str(value).get_slice(",", 0).trim_prefix("Object("))
|
||||
|
||||
func check_gdscript(value: GDScript) -> void:
|
||||
print(value.get_class())
|
||||
|
||||
func check_enum(value: Dictionary) -> void:
|
||||
print(value)
|
||||
|
||||
func test():
|
||||
for property in get_property_list():
|
||||
if str(property.name).begins_with("test_"):
|
||||
print(Utils.get_property_signature(property))
|
||||
|
||||
print("---")
|
||||
check_gdscript_native_class(test_native)
|
||||
check_gdscript(test_script)
|
||||
check_gdscript(test_class)
|
||||
check_enum(test_enum)
|
||||
|
||||
print("---")
|
||||
print(test_native.stringify([]))
|
||||
print(test_script.TEST)
|
||||
print(test_class.TEST)
|
||||
print(test_enum.keys())
|
||||
|
||||
print("---")
|
||||
# Some users add unnecessary type hints to `const`-`preload`, which removes metatypes.
|
||||
# For **constant** `GDScript` we still check the class members, despite the wider type.
|
||||
const ScriptNoMeta: GDScript = Other
|
||||
const ClassNoMeta: GDScript = MyClass
|
||||
var a := ScriptNoMeta.TEST
|
||||
var b := ClassNoMeta.TEST
|
||||
print(a)
|
||||
print(b)
|
@@ -0,0 +1 @@
|
||||
const TEST = 100
|
@@ -0,0 +1,18 @@
|
||||
GDTEST_OK
|
||||
var test_native: GDScriptNativeClass
|
||||
var test_script: GDScript
|
||||
var test_class: GDScript
|
||||
var test_enum: Dictionary
|
||||
---
|
||||
GDScriptNativeClass
|
||||
GDScript
|
||||
GDScript
|
||||
{ "A": 0, "B": 1, "C": 2 }
|
||||
---
|
||||
[]
|
||||
100
|
||||
10
|
||||
["A", "B", "C"]
|
||||
---
|
||||
100
|
||||
10
|
@@ -0,0 +1,8 @@
|
||||
func get_parse_string(t: Variant):
|
||||
return t.parse_string
|
||||
|
||||
func test():
|
||||
var a: Callable = JSON.parse_string
|
||||
var b: Callable = get_parse_string(JSON)
|
||||
prints(a.call("{\"test\": \"a\"}"), a.is_valid())
|
||||
prints(b.call("{\"test\": \"b\"}"), b.is_valid())
|
@@ -0,0 +1,3 @@
|
||||
GDTEST_OK
|
||||
{ "test": "a" } false
|
||||
{ "test": "b" } false
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user