Migrate to functions for delivering test results
This commit is contained in:
parent
8d819c9ffa
commit
3f08bfbbd0
2 changed files with 33 additions and 56 deletions
|
@ -7,12 +7,10 @@ func test_initialization() -> void:
|
||||||
|
|
||||||
# Check
|
# Check
|
||||||
if !is_framework_loaded():
|
if !is_framework_loaded():
|
||||||
test_status = 2
|
rerror("is_framework_loaded() returned 'false'")
|
||||||
test_message = "is_framework_loaded() returned 'false'"
|
|
||||||
return
|
return
|
||||||
|
|
||||||
test_status = 0
|
rok()
|
||||||
test_message = ""
|
|
||||||
|
|
||||||
# Custom module support
|
# Custom module support
|
||||||
func test_custom_module_support() -> void:
|
func test_custom_module_support() -> void:
|
||||||
|
@ -31,29 +29,24 @@ func test_custom_module_support() -> void:
|
||||||
|
|
||||||
# Check if registered
|
# Check if registered
|
||||||
if callback != "_initialize" and callback != "_pull_config":
|
if callback != "_initialize" and callback != "_pull_config":
|
||||||
test_status = 2
|
rerror("Module did not register")
|
||||||
test_message = "Module did not register"
|
|
||||||
return
|
return
|
||||||
elif core_test.get_node_or_null("Custom Modules/test_module") == null:
|
elif core_test.get_node_or_null("Custom Modules/test_module") == null:
|
||||||
test_status = 2
|
rerror("Could not find module node")
|
||||||
test_message = "Could not find module node"
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# Get module
|
# Get module
|
||||||
var module_get: CoreBaseModule = core_test.get_custom_module("test_module")
|
var module_get: CoreBaseModule = core_test.get_custom_module("test_module")
|
||||||
if module_get == null:
|
if module_get == null:
|
||||||
test_status = 2
|
rerror("Got null from get_custom_module method")
|
||||||
test_message = "Got null from get_custom_module method"
|
|
||||||
return
|
return
|
||||||
if module_get != module:
|
if module_get != module:
|
||||||
test_status = 2
|
rerror("Got invalid node from get_custom_module method")
|
||||||
test_message = "Got invalid node from get_custom_module method"
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# Get string
|
# Get string
|
||||||
if module.hello_test() != "Hello Test!":
|
if module.hello_test() != "Hello Test!":
|
||||||
test_status = 2
|
rerror("Module did not return test string")
|
||||||
test_message = "Module did not return test string"
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# Unregister module
|
# Unregister module
|
||||||
|
@ -62,8 +55,7 @@ func test_custom_module_support() -> void:
|
||||||
|
|
||||||
# Check if unregistered
|
# Check if unregistered
|
||||||
if core_test.get_node_or_null("Custom Modules/test_module") == null:
|
if core_test.get_node_or_null("Custom Modules/test_module") == null:
|
||||||
test_status = 0
|
rok("Successfully registered, got, used and unregistered a custom module")
|
||||||
test_message = "Successfully registered, got, used and unregistered a custom module"
|
|
||||||
return
|
return
|
||||||
|
|
||||||
func test_reload_config() -> void:
|
func test_reload_config() -> void:
|
||||||
|
@ -83,18 +75,15 @@ func test_reload_config() -> void:
|
||||||
|
|
||||||
# Check config
|
# Check config
|
||||||
if core_test.config != config:
|
if core_test.config != config:
|
||||||
test_status = 2
|
rerror("Got invalid node from config variable")
|
||||||
test_message = "Got invalid node from config variable"
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# Check config in modules
|
# Check config in modules
|
||||||
if core_test.logger.config_colored != false or core_test.logger.config_level != CoreTypes.LoggerLevel.NONE or core_test.logui.background.visible != false:
|
if core_test.logger.config_colored != false or core_test.logger.config_level != CoreTypes.LoggerLevel.NONE or core_test.logui.background.visible != false:
|
||||||
test_status = 2
|
rerror("Configuration did not apply all values correctly")
|
||||||
test_message = "Configuration did not apply all values correctly"
|
|
||||||
return
|
return
|
||||||
|
|
||||||
test_status = 0
|
rok()
|
||||||
test_message = ""
|
|
||||||
|
|
||||||
func test_formatted_string() -> void:
|
func test_formatted_string() -> void:
|
||||||
# Init CORE
|
# Init CORE
|
||||||
|
@ -135,5 +124,5 @@ func test_formatted_string() -> void:
|
||||||
var test_formatted: String = "version=" + str(core_test.version_version) + " typerelease=" + str(core_test.version_typerelease) + " semantic=" + str(test_semantic[0]) + "." + str(test_semantic[1]) + "." + str(test_semantic[2]) + " type=" + test_type + " type_technical=" + test_type_technical + " devmode=" + test_devmode + " headless=" + test_headless + " custommodules=" + test_custommodules + " HELLO TEST! #TransRightsAreHumanRights"
|
var test_formatted: String = "version=" + str(core_test.version_version) + " typerelease=" + str(core_test.version_typerelease) + " semantic=" + str(test_semantic[0]) + "." + str(test_semantic[1]) + "." + str(test_semantic[2]) + " type=" + test_type + " type_technical=" + test_type_technical + " devmode=" + test_devmode + " headless=" + test_headless + " custommodules=" + test_custommodules + " HELLO TEST! #TransRightsAreHumanRights"
|
||||||
|
|
||||||
# Compare
|
# Compare
|
||||||
if await core_test.get_formatted_string(test_raw) != test_formatted: test_status = 2
|
if await core_test.get_formatted_string(test_raw) != test_formatted: rerror("Test did not return the right value (in '" + test_raw + "', expected '" + test_formatted + "', got '" + await core_test.get_formatted_string(test_raw) + "')")
|
||||||
else: test_status = 0
|
else: rok()
|
||||||
|
|
|
@ -11,16 +11,14 @@ func test_byte2mib() -> void:
|
||||||
var test_out_flat: float = 49.0
|
var test_out_flat: float = 49.0
|
||||||
|
|
||||||
if core_test.misc.byte2mib(test_in, false) != test_out:
|
if core_test.misc.byte2mib(test_in, false) != test_out:
|
||||||
test_status = 2
|
rerror("Non-flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.byte2mib(test_in, false)) + "')")
|
||||||
test_message = "Non-flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.byte2mib(test_in, false)) + "')"
|
|
||||||
return
|
return
|
||||||
|
|
||||||
if core_test.misc.byte2mib(test_in, true) != test_out_flat:
|
if core_test.misc.byte2mib(test_in, true) != test_out_flat:
|
||||||
test_status = 2
|
rerror("Flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.byte2mib(test_in, true)) + "')")
|
||||||
test_message = "Flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.byte2mib(test_in, true)) + "')"
|
|
||||||
return
|
return
|
||||||
|
|
||||||
test_status = 0
|
rok()
|
||||||
|
|
||||||
# mib2byte
|
# mib2byte
|
||||||
func test_mib2byte() -> void:
|
func test_mib2byte() -> void:
|
||||||
|
@ -33,16 +31,14 @@ func test_mib2byte() -> void:
|
||||||
var test_out_flat: float = test_out
|
var test_out_flat: float = test_out
|
||||||
|
|
||||||
if core_test.misc.mib2byte(test_in, false) != test_out:
|
if core_test.misc.mib2byte(test_in, false) != test_out:
|
||||||
test_status = 2
|
rerror("Non-flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.mib2byte(test_in, false)) + "')")
|
||||||
test_message = "Non-flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.mib2byte(test_in, false)) + "')"
|
|
||||||
return
|
return
|
||||||
|
|
||||||
if core_test.misc.mib2byte(test_in, true) != test_out_flat:
|
if core_test.misc.mib2byte(test_in, true) != test_out_flat:
|
||||||
test_status = 2
|
rerror("Flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.mib2byte(test_in, true)) + "')")
|
||||||
test_message = "Flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.mib2byte(test_in, true)) + "')"
|
|
||||||
return
|
return
|
||||||
|
|
||||||
test_status = 0
|
rok()
|
||||||
|
|
||||||
# mib2gib
|
# mib2gib
|
||||||
func test_mib2gib() -> void:
|
func test_mib2gib() -> void:
|
||||||
|
@ -55,16 +51,14 @@ func test_mib2gib() -> void:
|
||||||
var test_out_flat: float = 1.0
|
var test_out_flat: float = 1.0
|
||||||
|
|
||||||
if core_test.misc.mib2gib(test_in, false) != test_out:
|
if core_test.misc.mib2gib(test_in, false) != test_out:
|
||||||
test_status = 2
|
rerror("Non-flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.mib2gib(test_in, false)) + "')")
|
||||||
test_message = "Non-flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.mib2gib(test_in, false)) + "')"
|
|
||||||
return
|
return
|
||||||
|
|
||||||
if core_test.misc.mib2gib(test_in, true) != test_out_flat:
|
if core_test.misc.mib2gib(test_in, true) != test_out_flat:
|
||||||
test_status = 2
|
rerror("Flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.mib2gib(test_in, true)) + "')")
|
||||||
test_message = "Flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.mib2gib(test_in, true)) + "')"
|
|
||||||
return
|
return
|
||||||
|
|
||||||
test_status = 0
|
rok()
|
||||||
|
|
||||||
# gib2mib
|
# gib2mib
|
||||||
func test_gib2mib() -> void:
|
func test_gib2mib() -> void:
|
||||||
|
@ -77,16 +71,14 @@ func test_gib2mib() -> void:
|
||||||
var test_out_flat: float = 1500.0
|
var test_out_flat: float = 1500.0
|
||||||
|
|
||||||
if core_test.misc.gib2mib(test_in, false) != test_out:
|
if core_test.misc.gib2mib(test_in, false) != test_out:
|
||||||
test_status = 2
|
rerror("Non-flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.gib2mib(test_in, false)) + "')")
|
||||||
test_message = "Non-flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.gib2mib(test_in, false)) + "')"
|
|
||||||
return
|
return
|
||||||
|
|
||||||
if core_test.misc.gib2mib(test_in, true) != test_out_flat:
|
if core_test.misc.gib2mib(test_in, true) != test_out_flat:
|
||||||
test_status = 2
|
rerror("Flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.gib2mib(test_in, true)) + "')")
|
||||||
test_message = "Flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.gib2mib(test_in, true)) + "')"
|
|
||||||
return
|
return
|
||||||
|
|
||||||
test_status = 0
|
rok()
|
||||||
|
|
||||||
# format_stringarray
|
# format_stringarray
|
||||||
func test_format_stringarray() -> void:
|
func test_format_stringarray() -> void:
|
||||||
|
@ -98,11 +90,10 @@ func test_format_stringarray() -> void:
|
||||||
var test_out: String = "StarOpenSource, JeremyStarTM & Contributors"
|
var test_out: String = "StarOpenSource, JeremyStarTM & Contributors"
|
||||||
|
|
||||||
if core_test.misc.format_stringarray(test_in) != test_out:
|
if core_test.misc.format_stringarray(test_in) != test_out:
|
||||||
test_status = 2
|
rerror("Test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.format_stringarray(test_in)) + "')")
|
||||||
test_message = "Test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.format_stringarray(test_in)) + "')"
|
|
||||||
return
|
return
|
||||||
|
|
||||||
test_status = 0
|
rok()
|
||||||
|
|
||||||
# format_stringarray (chaotic)
|
# format_stringarray (chaotic)
|
||||||
func test_format_stringarray_chaotic() -> void:
|
func test_format_stringarray_chaotic() -> void:
|
||||||
|
@ -114,11 +105,10 @@ func test_format_stringarray_chaotic() -> void:
|
||||||
var test_out: String = "aaaaStarOpenSourcebbbb$#!TaaaaJeremyStarTMbbbb :3 aaaaContributorsbbbb"
|
var test_out: String = "aaaaStarOpenSourcebbbb$#!TaaaaJeremyStarTMbbbb :3 aaaaContributorsbbbb"
|
||||||
|
|
||||||
if core_test.misc.format_stringarray(test_in, "aaaa", "bbbb", "$#!T", " :3 ") != test_out:
|
if core_test.misc.format_stringarray(test_in, "aaaa", "bbbb", "$#!T", " :3 ") != test_out:
|
||||||
test_status = 2
|
rerror("Test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.format_stringarray(test_in)) + "')")
|
||||||
test_message = "Test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.format_stringarray(test_in)) + "')"
|
|
||||||
return
|
return
|
||||||
|
|
||||||
test_status = 0
|
rok()
|
||||||
|
|
||||||
# array_to_stringarray & stringarray_to_array
|
# array_to_stringarray & stringarray_to_array
|
||||||
func test_array_stringarray_conversion() -> void:
|
func test_array_stringarray_conversion() -> void:
|
||||||
|
@ -130,11 +120,10 @@ func test_array_stringarray_conversion() -> void:
|
||||||
var test_out: Array[String] = ["StarOpenSource", "JeremyStarTM", "Contributors"]
|
var test_out: Array[String] = ["StarOpenSource", "JeremyStarTM", "Contributors"]
|
||||||
|
|
||||||
if core_test.misc.stringarray_to_array(core_test.misc.array_to_stringarray(test_in)) != test_out:
|
if core_test.misc.stringarray_to_array(core_test.misc.array_to_stringarray(test_in)) != test_out:
|
||||||
test_status = 2
|
rerror("Test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.stringarray_to_array(core_test.misc.array_to_stringarray(test_in))) + "')")
|
||||||
test_message = "Test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.stringarray_to_array(core_test.misc.array_to_stringarray(test_in))) + "')"
|
|
||||||
return
|
return
|
||||||
|
|
||||||
test_status = 0
|
rok()
|
||||||
|
|
||||||
# get_center
|
# get_center
|
||||||
func test_get_center() -> void:
|
func test_get_center() -> void:
|
||||||
|
@ -147,8 +136,7 @@ func test_get_center() -> void:
|
||||||
var test_out: Vector2 = Vector2(test_in_parent.x/2-test_in_child.x/2, test_in_parent.y/2-test_in_child.y/2)
|
var test_out: Vector2 = Vector2(test_in_parent.x/2-test_in_child.x/2, test_in_parent.y/2-test_in_child.y/2)
|
||||||
|
|
||||||
if core_test.misc.get_center(test_in_parent, test_in_child) != test_out:
|
if core_test.misc.get_center(test_in_parent, test_in_child) != test_out:
|
||||||
test_status = 2
|
rerror("Test did not return the right value (in (parent) '" + str(test_in_parent) + "', in (child) '" + str(test_in_child) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.stringarray_to_array(core_test.misc.get_center(test_in_parent, test_in_child))) + "')")
|
||||||
test_message = "Test did not return the right value (in (parent) '" + str(test_in_parent) + "', in (child) '" + str(test_in_child) + "', expected '" + str(test_out) + "', got '" + str(core_test.misc.stringarray_to_array(core_test.misc.get_center(test_in_parent, test_in_child))) + "')"
|
|
||||||
return
|
return
|
||||||
|
|
||||||
test_status = 0
|
rok()
|
||||||
|
|
Loading…
Reference in a new issue