mirror of
https://github.com/Relintai/regression-test-project.git
synced 2024-11-14 10:27:53 +01:00
RefCounted (#53)
This commit is contained in:
parent
eab0326c65
commit
e3ceee2097
@ -232,7 +232,7 @@ func check_if_is_allowed(method_data : Dictionary) -> bool:
|
||||
continue
|
||||
if name_of_class in disabled_classes:
|
||||
return false
|
||||
if name_of_class.find("Server") != -1 && ClassDB.class_exists(name_of_class) && !ClassDB.is_parent_class(name_of_class,"Reference"):
|
||||
if name_of_class.find("Server") != -1 && ClassDB.class_exists(name_of_class) && !obj_is_reference(name_of_class):
|
||||
return false
|
||||
# Editor stuff usually aren't good choice for arhuments
|
||||
if name_of_class.find("Editor") != -1 || name_of_class.find("SkinReference") != -1:
|
||||
@ -267,6 +267,8 @@ func remove_disabled_methods(method_list : Array, exceptions : Array) -> void:
|
||||
if index != -1:
|
||||
method_list.remove(index)
|
||||
|
||||
|
||||
|
||||
# Return all available classes which can be used
|
||||
func get_list_of_available_classes(must_be_instantable : bool = true) -> Array:
|
||||
var full_class_list : Array = Array(ClassDB.get_class_list())
|
||||
@ -284,10 +286,10 @@ func get_list_of_available_classes(must_be_instantable : bool = true) -> Array:
|
||||
|
||||
#This is only for RegressionTestProject, because it needs for now clear visual info what is going on screen, but some nodes broke view
|
||||
if regression_test_project:
|
||||
if !ClassDB.is_parent_class(name_of_class, "Node") && !ClassDB.is_parent_class(name_of_class, "Reference"):
|
||||
if !ClassDB.is_parent_class(name_of_class, "Node") && !obj_is_reference(name_of_class):
|
||||
continue
|
||||
|
||||
if name_of_class.find("Server") != -1 && !ClassDB.is_parent_class(name_of_class,"Reference"):
|
||||
if name_of_class.find("Server") != -1 && !(obj_is_reference(name_of_class)):
|
||||
continue
|
||||
if name_of_class.find("Editor") != -1 && regression_test_project:
|
||||
continue
|
||||
@ -299,3 +301,8 @@ func get_list_of_available_classes(must_be_instantable : bool = true) -> Array:
|
||||
|
||||
print(str(c) + " choosen classes from all " + str(full_class_list.size()) + " classes.")
|
||||
return classes
|
||||
|
||||
func obj_is_reference(name_of_class : String) -> bool:
|
||||
if ClassDB.class_exists("Reference"):
|
||||
return ClassDB.is_parent_class(name_of_class, "Reference")
|
||||
return ClassDB.is_parent_class(name_of_class, "RefCounted")
|
||||
|
@ -62,7 +62,7 @@ func tests_all_functions() -> void:
|
||||
if (
|
||||
ClassDB.is_parent_class(name_of_class, "Object")
|
||||
&& !ClassDB.is_parent_class(name_of_class, "Node")
|
||||
&& !ClassDB.is_parent_class(name_of_class, "Reference")
|
||||
&& !obj_is_reference(name_of_class)
|
||||
&& !ClassDB.class_has_method(name_of_class, "new")
|
||||
):
|
||||
to_print += "ClassDB.instance(\"" + name_of_class + "\")." + method_data.get("name") + "("
|
||||
@ -81,13 +81,13 @@ func tests_all_functions() -> void:
|
||||
for argument in arguments:
|
||||
if argument is Node:
|
||||
argument.queue_free()
|
||||
elif argument is Object && !(argument is Reference):
|
||||
elif argument is Object && !(obj_is_reference(argument.get_class())):
|
||||
argument.free()
|
||||
|
||||
if use_always_new_object:
|
||||
if object is Node:
|
||||
object.queue_free()
|
||||
elif object is Object && !(object is Reference):
|
||||
elif object is Object && !(obj_is_reference(object.get_class())):
|
||||
object.free()
|
||||
|
||||
object = ClassDB.instance(name_of_class)
|
||||
@ -97,5 +97,10 @@ func tests_all_functions() -> void:
|
||||
|
||||
if object is Node:
|
||||
object.queue_free()
|
||||
elif object is Object && !(object is Reference):
|
||||
elif object is Object && !(obj_is_reference(object.get_class())):
|
||||
object.free()
|
||||
|
||||
func obj_is_reference(name_of_class : String) -> bool:
|
||||
if ClassDB.class_exists("Reference"):
|
||||
return ClassDB.is_parent_class(name_of_class, "Reference")
|
||||
return ClassDB.is_parent_class(name_of_class, "RefCounted")
|
||||
|
@ -193,7 +193,7 @@ func return_gdscript_code_which_run_this_object(data) -> String:
|
||||
if (
|
||||
ClassDB.is_parent_class(name_of_class, "Object")
|
||||
&& !ClassDB.is_parent_class(name_of_class, "Node")
|
||||
&& !ClassDB.is_parent_class(name_of_class, "Reference")
|
||||
&& !obj_is_reference(name_of_class)
|
||||
&& !ClassDB.class_has_method(name_of_class, "new")
|
||||
):
|
||||
return_string += "ClassDB.instance(\"" + name_of_class + "\")"
|
||||
@ -334,3 +334,8 @@ func return_gdscript_code_which_run_this_object(data) -> String:
|
||||
assert(false, "Missing type, needs to be added to project")
|
||||
|
||||
return return_string
|
||||
|
||||
func obj_is_reference(name_of_class : String) -> bool:
|
||||
if ClassDB.class_exists("Reference"):
|
||||
return ClassDB.is_parent_class(name_of_class, "Reference")
|
||||
return ClassDB.is_parent_class(name_of_class, "RefCounted")
|
||||
|
@ -273,19 +273,19 @@ func get_object(object_name: String) -> Object:
|
||||
|
||||
var a = 0
|
||||
if random:
|
||||
var classes = ClassDB.get_inheriters_from_class("Node") + ClassDB.get_inheriters_from_class("Reference")
|
||||
var classes = ClassDB.get_inheriters_from_class("Node") + ClassDB.get_inheriters_from_class("Reference") + ClassDB.get_inheriters_from_class("RefCounted")
|
||||
|
||||
if object_name == "Object":
|
||||
while true:
|
||||
var choosen_class: String = classes[randi() % classes.size()]
|
||||
if (
|
||||
ClassDB.can_instance(choosen_class)
|
||||
&& (ClassDB.is_parent_class(choosen_class, "Node") || ClassDB.is_parent_class(choosen_class, "Reference"))
|
||||
&& (ClassDB.is_parent_class(choosen_class, "Node") || obj_is_reference(choosen_class))
|
||||
&& !(choosen_class in BasicData.disabled_classes)
|
||||
):
|
||||
return ClassDB.instance(choosen_class)
|
||||
|
||||
if ClassDB.is_parent_class(object_name, "Node") || ClassDB.is_parent_class(object_name, "Reference"):
|
||||
if ClassDB.is_parent_class(object_name, "Node") || obj_is_reference(object_name):
|
||||
if should_be_always_valid:
|
||||
var to_use_classes = ClassDB.get_inheriters_from_class(object_name)
|
||||
to_use_classes.append(object_name)
|
||||
@ -333,7 +333,7 @@ func get_object(object_name: String) -> Object:
|
||||
var list_of_class = ClassDB.get_inheriters_from_class(object_name)
|
||||
assert(list_of_class.size() > 0, "Cannot find proper instantable child for ") # Number of inherited class of non instantable class must be greater than 0, otherwise this function would be useless
|
||||
for i in list_of_class:
|
||||
if ClassDB.can_instance(i) && (ClassDB.is_parent_class(i, "Node") || ClassDB.is_parent_class(i, "Reference")):
|
||||
if ClassDB.can_instance(i) && (ClassDB.is_parent_class(i, "Node") || obj_is_reference(i)):
|
||||
return ClassDB.instance(i)
|
||||
assert(false, "Cannot find proper instantable child for ")
|
||||
|
||||
@ -347,15 +347,15 @@ func get_object_string(object_name: String) -> String:
|
||||
|
||||
var a = 0
|
||||
if random:
|
||||
var classes = ClassDB.get_inheriters_from_class("Node") + ClassDB.get_inheriters_from_class("Reference")
|
||||
var classes = ClassDB.get_inheriters_from_class("Node") + ClassDB.get_inheriters_from_class("Reference") + ClassDB.get_inheriters_from_class("RefCounted")
|
||||
|
||||
if object_name == "Object":
|
||||
while true:
|
||||
var choosen_class: String = classes[randi() % classes.size()]
|
||||
if ClassDB.can_instance(choosen_class) && (ClassDB.is_parent_class(choosen_class, "Node") || ClassDB.is_parent_class(choosen_class, "Reference")):
|
||||
if ClassDB.can_instance(choosen_class) && (ClassDB.is_parent_class(choosen_class, "Node") || obj_is_reference(choosen_class)):
|
||||
return choosen_class
|
||||
|
||||
if ClassDB.is_parent_class(object_name, "Node") || ClassDB.is_parent_class(object_name, "Reference"):
|
||||
if ClassDB.is_parent_class(object_name, "Node") || obj_is_reference(object_name):
|
||||
if should_be_always_valid:
|
||||
var to_use_classes = ClassDB.get_inheriters_from_class(object_name)
|
||||
to_use_classes.append(object_name)
|
||||
@ -403,9 +403,14 @@ func get_object_string(object_name: String) -> String:
|
||||
var list_of_class = ClassDB.get_inheriters_from_class(object_name)
|
||||
assert(list_of_class.size() > 0, "Cannot find proper instantable child for ") # Number of inherited class of non instantable class must be greater than 0, otherwise this function would be useless
|
||||
for i in list_of_class:
|
||||
if ClassDB.can_instance(i) && (ClassDB.is_parent_class(i, "Node") || ClassDB.is_parent_class(i, "Reference")):
|
||||
if ClassDB.can_instance(i) && (ClassDB.is_parent_class(i, "Node") || obj_is_reference(i)):
|
||||
return i
|
||||
assert(false, "Cannot find proper instantable child for ")
|
||||
|
||||
assert(false, "Cannot find proper instantable child for ")
|
||||
return "BoxMesh"
|
||||
|
||||
func obj_is_reference(name_of_class : String) -> bool:
|
||||
if ClassDB.class_exists("Reference"):
|
||||
return ClassDB.is_parent_class(name_of_class, "Reference")
|
||||
return ClassDB.is_parent_class(name_of_class, "RefCounted")
|
||||
|
Loading…
Reference in New Issue
Block a user