feat: updated engine
This commit is contained in:
parent
cbe99774ff
commit
f4cf6b3999
6607 changed files with 910135 additions and 430025 deletions
|
|
@ -0,0 +1,69 @@
|
|||
const UNTYPED_ARRAY: Variant = [1000]
|
||||
const TYPED_ARRAY: Variant = [2000] as Array[int]
|
||||
const UNTYPED_DICT: Variant = {1000: 1000}
|
||||
const TYPED_DICT: Variant = {2000: 2000} as Dictionary[int, int]
|
||||
|
||||
const TEST_STRING_INDEX = "data"[0]
|
||||
const TEST_VECTOR2_ATTR = Vector2(1, 2).x
|
||||
const TEST_ARRAY_INDEX = [100, 200][0]
|
||||
const TEST_DICT_ATTR = {a = 1, b = 2}.a
|
||||
|
||||
const TEST_CALL_ARRAY = Array()
|
||||
const TEST_CALL_DICT = Dictionary()
|
||||
|
||||
const TEST_BINARY_OP = [1] + [2]
|
||||
const TEST_TERNARY_OP = [123] if [true] else [456]
|
||||
|
||||
const TEST_CAST_UNTYPED_ARRAY = [11] as Array
|
||||
const TEST_CAST_TYPED_ARRAY = [22] as Array[int]
|
||||
const TEST_CAST_UNTYPED_DICT = {11: 111} as Dictionary
|
||||
const TEST_CAST_TYPED_DICT = {22: 222} as Dictionary[int, int]
|
||||
|
||||
const TEST_TYPE_TEST_LITERAL_UNTYPED_ARRAY = [33] is Array
|
||||
const TEST_TYPE_TEST_LITERAL_TYPED_ARRAY = [44] is Array[int]
|
||||
const TEST_TYPE_TEST_LITERAL_UNTYPED_DICT = {33: 333} is Dictionary
|
||||
const TEST_TYPE_TEST_LITERAL_TYPED_DICT = {44: 444} is Dictionary[int, int]
|
||||
|
||||
const TEST_TYPE_TEST_UNTYPED_UNTYPED_ARRAY = UNTYPED_ARRAY is Array
|
||||
const TEST_TYPE_TEST_UNTYPED_TYPED_ARRAY = UNTYPED_ARRAY is Array[int]
|
||||
const TEST_TYPE_TEST_UNTYPED_UNTYPED_DICT = UNTYPED_DICT is Dictionary
|
||||
const TEST_TYPE_TEST_UNTYPED_TYPED_DICT = UNTYPED_DICT is Dictionary[int, int]
|
||||
|
||||
const TEST_TYPE_TEST_TYPED_UNTYPED_ARRAY = TYPED_ARRAY is Array
|
||||
const TEST_TYPE_TEST_TYPED_TYPED_ARRAY = TYPED_ARRAY is Array[int]
|
||||
const TEST_TYPE_TEST_TYPED_UNTYPED_DICT = TYPED_DICT is Dictionary
|
||||
const TEST_TYPE_TEST_TYPED_TYPED_DICT = TYPED_DICT is Dictionary[int, int]
|
||||
|
||||
@export_custom(
|
||||
PROPERTY_HINT_TYPE_STRING,
|
||||
"%d/%d:Zero,One,Two" % [TYPE_INT, PROPERTY_HINT_ENUM],
|
||||
)
|
||||
var test_export_custom: Array
|
||||
|
||||
func test():
|
||||
var script: Script = get_script()
|
||||
var constants: Dictionary = script.get_script_constant_map()
|
||||
for constant: StringName in constants:
|
||||
if constant.begins_with("TEST_"):
|
||||
print("const %s = %s" % [constant, var_to_str(constants[constant]).replace("\n", "")])
|
||||
if constants[constant] is Array:
|
||||
var array: Array = constants[constant]
|
||||
Utils.check(array.is_read_only())
|
||||
array = get(constant)
|
||||
Utils.check(array.is_read_only())
|
||||
elif constants[constant] is Dictionary:
|
||||
var dict: Dictionary = constants[constant]
|
||||
Utils.check(dict.is_read_only())
|
||||
dict = get(constant)
|
||||
Utils.check(dict.is_read_only())
|
||||
|
||||
for property in get_property_list():
|
||||
if str(property.name).begins_with("test_"):
|
||||
print(Utils.get_property_extended_info(property, self))
|
||||
|
||||
# GH-96152
|
||||
const ARRAY = [42]
|
||||
const CONST_CONCAT = ARRAY + ARRAY
|
||||
var var_concat := ARRAY + ARRAY
|
||||
prints(CONST_CONCAT, CONST_CONCAT.is_read_only())
|
||||
prints(var_concat, var_concat.is_read_only())
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
GDTEST_OK
|
||||
const TEST_STRING_INDEX = "d"
|
||||
const TEST_VECTOR2_ATTR = 1.0
|
||||
const TEST_ARRAY_INDEX = 100
|
||||
const TEST_DICT_ATTR = 1
|
||||
const TEST_CALL_ARRAY = []
|
||||
const TEST_CALL_DICT = {}
|
||||
const TEST_BINARY_OP = [1, 2]
|
||||
const TEST_TERNARY_OP = [123]
|
||||
const TEST_CAST_UNTYPED_ARRAY = [11]
|
||||
const TEST_CAST_TYPED_ARRAY = Array[int]([22])
|
||||
const TEST_CAST_UNTYPED_DICT = {11: 111}
|
||||
const TEST_CAST_TYPED_DICT = Dictionary[int, int]({22: 222})
|
||||
const TEST_TYPE_TEST_LITERAL_UNTYPED_ARRAY = true
|
||||
const TEST_TYPE_TEST_LITERAL_TYPED_ARRAY = false
|
||||
const TEST_TYPE_TEST_LITERAL_UNTYPED_DICT = true
|
||||
const TEST_TYPE_TEST_LITERAL_TYPED_DICT = false
|
||||
const TEST_TYPE_TEST_UNTYPED_UNTYPED_ARRAY = true
|
||||
const TEST_TYPE_TEST_UNTYPED_TYPED_ARRAY = false
|
||||
const TEST_TYPE_TEST_UNTYPED_UNTYPED_DICT = true
|
||||
const TEST_TYPE_TEST_UNTYPED_TYPED_DICT = false
|
||||
const TEST_TYPE_TEST_TYPED_UNTYPED_ARRAY = true
|
||||
const TEST_TYPE_TEST_TYPED_TYPED_ARRAY = true
|
||||
const TEST_TYPE_TEST_TYPED_UNTYPED_DICT = true
|
||||
const TEST_TYPE_TEST_TYPED_TYPED_DICT = true
|
||||
var test_export_custom: Array = []
|
||||
hint=TYPE_STRING hint_string="<int>/<ENUM>:Zero,One,Two" usage=DEFAULT|SCRIPT_VARIABLE class_name=&""
|
||||
[42, 42] true
|
||||
[42, 42] false
|
||||
|
|
@ -11,4 +11,4 @@ enum MyEnum {A, B, C}
|
|||
func test():
|
||||
for property in get_property_list():
|
||||
if str(property.name).begins_with("test_"):
|
||||
Utils.print_property_extended_info(property)
|
||||
print(Utils.get_property_extended_info(property))
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@ class B extends A:
|
|||
func untyped_to_node() -> Node: return null
|
||||
|
||||
func void_to_untyped(): pass
|
||||
func variant_to_untyped(): pass
|
||||
func int_to_untyped(): pass
|
||||
func node_to_untyped(): pass
|
||||
func variant_to_untyped(): return null
|
||||
func int_to_untyped(): return 0
|
||||
func node_to_untyped(): return null
|
||||
|
||||
func test():
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ extends Node
|
|||
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))
|
||||
|
||||
func test_no_exec():
|
||||
# GH-99309
|
||||
|
|
|
|||
|
|
@ -19,6 +19,24 @@ func test():
|
|||
Utils.check((const_builtin is float) == false)
|
||||
Utils.check(is_instance_of(const_builtin, TYPE_FLOAT) == false)
|
||||
|
||||
var untyped_array: Variant = []
|
||||
Utils.check((untyped_array is Variant) == true)
|
||||
Utils.check((untyped_array is Array) == true)
|
||||
Utils.check(is_instance_of(untyped_array, TYPE_ARRAY) == true)
|
||||
Utils.check((untyped_array is Array[int]) == false)
|
||||
Utils.check((untyped_array is Array[float]) == false)
|
||||
Utils.check((untyped_array is int) == false)
|
||||
Utils.check(is_instance_of(untyped_array, TYPE_INT) == false)
|
||||
|
||||
const const_untyped_array: Variant = []
|
||||
Utils.check((const_untyped_array is Variant) == true)
|
||||
Utils.check((const_untyped_array is Array) == true)
|
||||
Utils.check(is_instance_of(const_untyped_array, TYPE_ARRAY) == true)
|
||||
Utils.check((const_untyped_array is Array[int]) == false)
|
||||
Utils.check((const_untyped_array is Array[float]) == false)
|
||||
Utils.check((const_untyped_array is int) == false)
|
||||
Utils.check(is_instance_of(const_untyped_array, TYPE_INT) == false)
|
||||
|
||||
var int_array: Variant = [] as Array[int]
|
||||
Utils.check((int_array is Variant) == true)
|
||||
Utils.check((int_array is Array) == true)
|
||||
|
|
@ -28,7 +46,7 @@ func test():
|
|||
Utils.check((int_array is int) == false)
|
||||
Utils.check(is_instance_of(int_array, TYPE_INT) == false)
|
||||
|
||||
var const_int_array: Variant = [] as Array[int]
|
||||
const const_int_array: Variant = [] as Array[int]
|
||||
Utils.check((const_int_array is Variant) == true)
|
||||
Utils.check((const_int_array is Array) == true)
|
||||
Utils.check(is_instance_of(const_int_array, TYPE_ARRAY) == true)
|
||||
|
|
@ -47,7 +65,7 @@ func test():
|
|||
Utils.check((b_array is int) == false)
|
||||
Utils.check(is_instance_of(b_array, TYPE_INT) == false)
|
||||
|
||||
var const_b_array: Variant = [] as Array[B]
|
||||
const const_b_array: Variant = [] as Array[B]
|
||||
Utils.check((const_b_array is Variant) == true)
|
||||
Utils.check((const_b_array is Array) == true)
|
||||
Utils.check(is_instance_of(const_b_array, TYPE_ARRAY) == true)
|
||||
|
|
@ -57,6 +75,62 @@ func test():
|
|||
Utils.check((const_b_array is int) == false)
|
||||
Utils.check(is_instance_of(const_b_array, TYPE_INT) == false)
|
||||
|
||||
var untyped_dict: Variant = {}
|
||||
Utils.check((untyped_dict is Variant) == true)
|
||||
Utils.check((untyped_dict is Dictionary) == true)
|
||||
Utils.check(is_instance_of(untyped_dict, TYPE_DICTIONARY) == true)
|
||||
Utils.check((untyped_dict is Dictionary[int, int]) == false)
|
||||
Utils.check((untyped_dict is Dictionary[float, String]) == false)
|
||||
Utils.check((untyped_dict is int) == false)
|
||||
Utils.check(is_instance_of(untyped_dict, TYPE_INT) == false)
|
||||
|
||||
const const_untyped_dict: Variant = {}
|
||||
Utils.check((const_untyped_dict is Variant) == true)
|
||||
Utils.check((const_untyped_dict is Dictionary) == true)
|
||||
Utils.check(is_instance_of(const_untyped_dict, TYPE_DICTIONARY) == true)
|
||||
Utils.check((const_untyped_dict is Dictionary[int, int]) == false)
|
||||
Utils.check((const_untyped_dict is Dictionary[float, String]) == false)
|
||||
Utils.check((const_untyped_dict is int) == false)
|
||||
Utils.check(is_instance_of(const_untyped_dict, TYPE_INT) == false)
|
||||
|
||||
var int_dict: Variant = {} as Dictionary[int, int]
|
||||
Utils.check((int_dict is Variant) == true)
|
||||
Utils.check((int_dict is Dictionary) == true)
|
||||
Utils.check(is_instance_of(int_dict, TYPE_DICTIONARY) == true)
|
||||
Utils.check((int_dict is Dictionary[int, int]) == true)
|
||||
Utils.check((int_dict is Dictionary[float, String]) == false)
|
||||
Utils.check((int_dict is int) == false)
|
||||
Utils.check(is_instance_of(int_dict, TYPE_INT) == false)
|
||||
|
||||
const const_int_dict: Variant = {} as Dictionary[int, int]
|
||||
Utils.check((const_int_dict is Variant) == true)
|
||||
Utils.check((const_int_dict is Dictionary) == true)
|
||||
Utils.check(is_instance_of(const_int_dict, TYPE_DICTIONARY) == true)
|
||||
Utils.check((const_int_dict is Dictionary[int, int]) == true)
|
||||
Utils.check((const_int_dict is Dictionary[float, String]) == false)
|
||||
Utils.check((const_int_dict is int) == false)
|
||||
Utils.check(is_instance_of(const_int_dict, TYPE_INT) == false)
|
||||
|
||||
var b_dict: Variant = {} as Dictionary[String, B]
|
||||
Utils.check((b_dict is Variant) == true)
|
||||
Utils.check((b_dict is Dictionary) == true)
|
||||
Utils.check(is_instance_of(b_dict, TYPE_DICTIONARY) == true)
|
||||
Utils.check((b_dict is Dictionary[String, B]) == true)
|
||||
Utils.check((b_dict is Dictionary[String, A]) == false)
|
||||
Utils.check((b_dict is Dictionary[String, int]) == false)
|
||||
Utils.check((b_dict is int) == false)
|
||||
Utils.check(is_instance_of(b_dict, TYPE_INT) == false)
|
||||
|
||||
const const_b_dict: Variant = {} as Dictionary[String, B]
|
||||
Utils.check((const_b_dict is Variant) == true)
|
||||
Utils.check((const_b_dict is Dictionary) == true)
|
||||
Utils.check(is_instance_of(const_b_dict, TYPE_DICTIONARY) == true)
|
||||
Utils.check((const_b_dict is Dictionary[String, B]) == true)
|
||||
Utils.check((const_b_dict is Dictionary[String, A]) == false)
|
||||
Utils.check((const_b_dict is Dictionary[String, int]) == false)
|
||||
Utils.check((const_b_dict is int) == false)
|
||||
Utils.check(is_instance_of(const_b_dict, TYPE_INT) == false)
|
||||
|
||||
var native: Variant = RefCounted.new()
|
||||
Utils.check((native is Variant) == true)
|
||||
Utils.check((native is Object) == true)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
class A:
|
||||
func return_float() -> float: return 1.0
|
||||
func return_int_as_float(_x: int) -> float: return 1.0
|
||||
func return_variant_as_float(_x: Variant) -> float: return 1.0
|
||||
func return_float_array() -> Array[float]: return [1.0]
|
||||
func return_untyped_array_as_float_array(_array: Array) -> Array[float]: return [1.0]
|
||||
func return_float_dict() -> Dictionary[float, float]: return {1.0: 1.0}
|
||||
func return_untyped_dict_as_float_dict(_dict: Dictionary) -> Dictionary[float, float]: return {1.0: 1.0}
|
||||
func return_object_as_node(_object: Object) -> Node: return null
|
||||
|
||||
class B extends A:
|
||||
func return_float(): return 2
|
||||
func return_int_as_float(x: int): return x
|
||||
func return_variant_as_float(x: Variant): return x
|
||||
func return_float_array(): return [2]
|
||||
func return_untyped_array_as_float_array(array: Array): return array
|
||||
func return_float_dict(): return {2: 2}
|
||||
func return_untyped_dict_as_float_dict(dict: Dictionary): return dict
|
||||
func return_object_as_node(object: Object): return object
|
||||
|
||||
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()
|
||||
var float_array: Array[float] = [2]
|
||||
var float_dict: Dictionary[float, float] = {2: 2}
|
||||
var node := Node.new()
|
||||
|
||||
output(b.return_float())
|
||||
output(b.return_int_as_float(2))
|
||||
output(b.return_variant_as_float(2))
|
||||
output(b.return_float_array())
|
||||
output(b.return_untyped_array_as_float_array(float_array))
|
||||
output(b.return_float_dict())
|
||||
output(b.return_untyped_dict_as_float_dict(float_dict))
|
||||
output(b.return_object_as_node(node))
|
||||
|
||||
node.free()
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
GDTEST_OK
|
||||
2.0
|
||||
2.0
|
||||
2.0
|
||||
Array[float]([2.0])
|
||||
Array[float]([2.0])
|
||||
Dictionary[float, float]({2.0: 2.0})
|
||||
Dictionary[float, float]({2.0: 2.0})
|
||||
<Node>
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
class BaseClass:
|
||||
func _get_property_list():
|
||||
return {"property" : "definition"}
|
||||
return [{"property" : "definition"}]
|
||||
|
||||
class SuperClassMethodsRecognized extends BaseClass:
|
||||
func _init():
|
||||
|
|
@ -11,7 +11,7 @@ class SuperMethodsRecognized extends BaseClass:
|
|||
func _get_property_list():
|
||||
# Recognizes super method.
|
||||
var result = super()
|
||||
result["new"] = "new"
|
||||
result[0]["new"] = "new"
|
||||
return result
|
||||
|
||||
func test():
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
GDTEST_OK
|
||||
{ "property": "definition" }
|
||||
{ "property": "definition", "new": "new" }
|
||||
[{ "property": "definition" }]
|
||||
[{ "property": "definition", "new": "new" }]
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ func test_unsafe_void_return() -> void:
|
|||
|
||||
@warning_ignore("native_method_override")
|
||||
func get_class():
|
||||
pass
|
||||
return ""
|
||||
|
||||
# We don't want to execute it because of errors, just analyze.
|
||||
func test():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue