Update testing
- Update besseretests to latest commit - tests/utils.gd was nuked, all tests now extend tests/unitbase.gd
This commit is contained in:
parent
32e09ea296
commit
a74ebecf6b
4 changed files with 76 additions and 89 deletions
2
dist/submodules/besseretests
vendored
2
dist/submodules/besseretests
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit 6dda982c466af2d3d55639405995e5a4ab4f4316
|
Subproject commit 642c3a62a9c2abeb1d3b61d4d4639db75bc02d4a
|
|
@ -1,58 +1,46 @@
|
||||||
extends BessereTestsTest
|
extends 'res://tests/unitbase.gd'
|
||||||
|
|
||||||
# Callbacks
|
|
||||||
var callback: String = ""
|
|
||||||
|
|
||||||
# Utils
|
|
||||||
var utils: Node = CoreTestUtils.new()
|
|
||||||
|
|
||||||
func before_all() -> void: add_child(utils)
|
|
||||||
func after_all() -> void: remove_child(utils)
|
|
||||||
|
|
||||||
# Unload framework after each test
|
|
||||||
func after_each() -> void: utils.unload_framework()
|
|
||||||
|
|
||||||
# Initialization test
|
# Initialization test
|
||||||
func test_initialization() -> void:
|
func test_initialization() -> void:
|
||||||
# Init CORE
|
# Init CORE
|
||||||
await utils.load_framework()
|
await load_framework()
|
||||||
|
|
||||||
# Check
|
# Check
|
||||||
if !utils.is_framework_loaded():
|
if !is_framework_loaded():
|
||||||
test_status = 2
|
test_status = 2
|
||||||
test_message = "utils.is_framework_loaded() returned 'false'"
|
test_message = "is_framework_loaded() returned 'false'"
|
||||||
return
|
return
|
||||||
|
|
||||||
test_status = 0
|
test_status = 0
|
||||||
test_message = "Framework did initialize correctly"
|
test_message = ""
|
||||||
|
|
||||||
# Custom module support
|
# Custom module support
|
||||||
func test_custom_module_support() -> void:
|
func test_custom_module_support() -> void:
|
||||||
# Init CORE
|
# Init CORE
|
||||||
var config: CoreConfiguration = CoreConfiguration.new()
|
var config: CoreConfiguration = CoreConfiguration.new()
|
||||||
config.custom_modules = true
|
config.custom_modules = true
|
||||||
var core: Core = await utils.load_framework(config)
|
var core_test: Core = await load_framework(config)
|
||||||
|
|
||||||
# Load module
|
# Load module
|
||||||
var module: CoreBaseModule = CoreBaseModule.new()
|
var module: CoreBaseModule = CoreBaseModule.new()
|
||||||
module.set_script(load("res://tests/custom_module.gd"))
|
module.set_script(load("res://tests/custom_module.gd"))
|
||||||
|
|
||||||
# Register module
|
# Register module
|
||||||
core.register_custom_module("test_module", module)
|
core_test.register_custom_module("test_module", module)
|
||||||
await utils.wait_process_time()
|
await wait_process_time()
|
||||||
|
|
||||||
# Check if registered
|
# Check if registered
|
||||||
if callback != "_initialize" and callback != "_pull_config":
|
if callback != "_initialize" and callback != "_pull_config":
|
||||||
test_status = 2
|
test_status = 2
|
||||||
test_message = "Module did not register"
|
test_message = "Module did not register"
|
||||||
return
|
return
|
||||||
elif core.get_node_or_null("Custom Modules/test_module") == null:
|
elif core_test.get_node_or_null("Custom Modules/test_module") == null:
|
||||||
test_status = 2
|
test_status = 2
|
||||||
test_message = "Could not find module node"
|
test_message = "Could not find module node"
|
||||||
return
|
return
|
||||||
|
|
||||||
# Get module
|
# Get module
|
||||||
var module_get: CoreBaseModule = core.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
|
test_status = 2
|
||||||
test_message = "Got null from get_custom_module method"
|
test_message = "Got null from get_custom_module method"
|
||||||
|
@ -69,11 +57,11 @@ func test_custom_module_support() -> void:
|
||||||
return
|
return
|
||||||
|
|
||||||
# Unregister module
|
# Unregister module
|
||||||
core.unregister_custom_module("test_module")
|
core_test.unregister_custom_module("test_module")
|
||||||
await utils.wait_process_time()
|
await wait_process_time()
|
||||||
|
|
||||||
# Check if unregistered
|
# Check if unregistered
|
||||||
if core.get_node_or_null("Custom Modules/test_module") == null:
|
if core_test.get_node_or_null("Custom Modules/test_module") == null:
|
||||||
test_status = 0
|
test_status = 0
|
||||||
test_message = "Successfully registered, got, used and unregistered a custom module"
|
test_message = "Successfully registered, got, used and unregistered a custom module"
|
||||||
return
|
return
|
||||||
|
@ -83,44 +71,44 @@ func test_reload_config() -> void:
|
||||||
var config: CoreConfiguration = CoreConfiguration.new()
|
var config: CoreConfiguration = CoreConfiguration.new()
|
||||||
|
|
||||||
# Init CORE
|
# Init CORE
|
||||||
var core: Core = await utils.load_framework()
|
var core_test: Core = await load_framework()
|
||||||
|
|
||||||
# Update some keys and reload
|
# Update some keys and reload
|
||||||
config.logger_colored = false
|
config.logger_colored = false
|
||||||
config.logger_level = CoreTypes.LoggerLevel.NONE
|
config.logger_level = CoreTypes.LoggerLevel.NONE
|
||||||
config.logui_enabled = false
|
config.logui_enabled = false
|
||||||
|
|
||||||
core.reload_configuration(config)
|
core_test.reload_configuration(config)
|
||||||
await utils.wait_process_time()
|
await wait_process_time()
|
||||||
|
|
||||||
# Check config
|
# Check config
|
||||||
if core.config != config:
|
if core_test.config != config:
|
||||||
test_status = 2
|
test_status = 2
|
||||||
test_message = "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.logger.config_colored != false or core.logger.config_level != CoreTypes.LoggerLevel.NONE or core.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
|
test_status = 2
|
||||||
test_message = "Configuration did not apply all values correctly"
|
test_message = "Configuration did not apply all values correctly"
|
||||||
return
|
return
|
||||||
|
|
||||||
test_status = 0
|
test_status = 0
|
||||||
test_message = "Framework applied all modified keys correctly"
|
test_message = ""
|
||||||
|
|
||||||
func test_formatted_string() -> void:
|
func test_formatted_string() -> void:
|
||||||
# Init CORE
|
# Init CORE
|
||||||
var core: Core = await utils.load_framework()
|
var core_test: Core = await load_framework()
|
||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
var test_type: String
|
var test_type: String
|
||||||
var test_type_technical: String
|
var test_type_technical: String
|
||||||
var test_semantic: Array[int] = core.get_version_semantic()
|
var test_semantic: Array[int] = core_test.get_version_semantic()
|
||||||
var test_devmode: String
|
var test_devmode: String
|
||||||
var test_headless: String
|
var test_headless: String
|
||||||
var test_custommodules: String
|
var test_custommodules: String
|
||||||
# test_type & test_type_technical
|
# test_type & test_type_technical
|
||||||
match(core.version_type):
|
match(core_test.version_type):
|
||||||
CoreTypes.VersionType.RELEASE:
|
CoreTypes.VersionType.RELEASE:
|
||||||
test_type = "Release"
|
test_type = "Release"
|
||||||
test_type_technical = "r"
|
test_type_technical = "r"
|
||||||
|
@ -134,18 +122,18 @@ func test_formatted_string() -> void:
|
||||||
test_type = "Alpha"
|
test_type = "Alpha"
|
||||||
test_type_technical = "a"
|
test_type_technical = "a"
|
||||||
# test_devmode
|
# test_devmode
|
||||||
if core.is_devmode(): test_devmode = "Enabled"
|
if core_test.is_devmode(): test_devmode = "Enabled"
|
||||||
else: test_devmode = "Disabled"
|
else: test_devmode = "Disabled"
|
||||||
# test_headless
|
# test_headless
|
||||||
if core.config.headless: test_headless = "Enabled"
|
if core_test.config.headless: test_headless = "Enabled"
|
||||||
else: test_headless = "Disabled"
|
else: test_headless = "Disabled"
|
||||||
# test_custommodules
|
# test_custommodules
|
||||||
if core.config.custom_modules: test_custommodules = "Enabled"
|
if core_test.config.custom_modules: test_custommodules = "Enabled"
|
||||||
else: test_custommodules = "Disabled"
|
else: test_custommodules = "Disabled"
|
||||||
|
|
||||||
var test_raw: String = "version=%version% typerelease=%version_type% semantic=%version_semantic% type=%type% type_technical=%type_technical% devmode=%devmode% headless=%headless% custommodules=%custommodules% HELLO TEST! #TransRightsAreHumanRights"
|
var test_raw: String = "version=%version% typerelease=%version_type% semantic=%version_semantic% type=%type% type_technical=%type_technical% devmode=%devmode% headless=%headless% custommodules=%custommodules% HELLO TEST! #TransRightsAreHumanRights"
|
||||||
var test_formatted: String = "version=" + str(core.version_version) + " typerelease=" + str(core.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.get_formatted_string(test_raw) != test_formatted: test_status = 2
|
if await core_test.get_formatted_string(test_raw) != test_formatted: test_status = 2
|
||||||
else: test_status = 0
|
else: test_status = 0
|
||||||
|
|
|
@ -1,35 +1,23 @@
|
||||||
extends BessereTestsTest
|
extends 'res://tests/unitbase.gd'
|
||||||
|
|
||||||
# Callbacks
|
|
||||||
var callback: String = ""
|
|
||||||
|
|
||||||
# Utils
|
|
||||||
var utils: Node = CoreTestUtils.new()
|
|
||||||
|
|
||||||
func before_all() -> void: add_child(utils)
|
|
||||||
func after_all() -> void: remove_child(utils)
|
|
||||||
|
|
||||||
# Unload framework after each test
|
|
||||||
func after_each() -> void: utils.unload_framework()
|
|
||||||
|
|
||||||
# byte2mib
|
# byte2mib
|
||||||
func test_byte2mib() -> void:
|
func test_byte2mib() -> void:
|
||||||
# Init CORE
|
# Init CORE
|
||||||
var core: Core = await utils.load_framework()
|
var core_test: Core = await load_framework()
|
||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
var test_in: int = 51758516
|
var test_in: int = 51758516
|
||||||
var test_out: float = 49.36076736450195
|
var test_out: float = 49.36076736450195
|
||||||
var test_out_flat: float = 49.0
|
var test_out_flat: float = 49.0
|
||||||
|
|
||||||
if core.misc.byte2mib(test_in, false) != test_out:
|
if core_test.misc.byte2mib(test_in, false) != test_out:
|
||||||
test_status = 2
|
test_status = 2
|
||||||
test_message = "Non-flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core.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.misc.byte2mib(test_in, true) != test_out_flat:
|
if core_test.misc.byte2mib(test_in, true) != test_out_flat:
|
||||||
test_status = 2
|
test_status = 2
|
||||||
test_message = "Flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core.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
|
test_status = 0
|
||||||
|
@ -37,21 +25,21 @@ func test_byte2mib() -> void:
|
||||||
# mib2byte
|
# mib2byte
|
||||||
func test_mib2byte() -> void:
|
func test_mib2byte() -> void:
|
||||||
# Init CORE
|
# Init CORE
|
||||||
var core: Core = await utils.load_framework()
|
var core_test: Core = await load_framework()
|
||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
var test_in: float = 49.36076736450195
|
var test_in: float = 49.36076736450195
|
||||||
var test_out: float = 51758516.0
|
var test_out: float = 51758516.0
|
||||||
var test_out_flat: float = test_out
|
var test_out_flat: float = test_out
|
||||||
|
|
||||||
if core.misc.mib2byte(test_in, false) != test_out:
|
if core_test.misc.mib2byte(test_in, false) != test_out:
|
||||||
test_status = 2
|
test_status = 2
|
||||||
test_message = "Non-flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core.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.misc.mib2byte(test_in, true) != test_out_flat:
|
if core_test.misc.mib2byte(test_in, true) != test_out_flat:
|
||||||
test_status = 2
|
test_status = 2
|
||||||
test_message = "Flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core.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
|
test_status = 0
|
||||||
|
@ -59,21 +47,21 @@ func test_mib2byte() -> void:
|
||||||
# mib2gib
|
# mib2gib
|
||||||
func test_mib2gib() -> void:
|
func test_mib2gib() -> void:
|
||||||
# Init CORE
|
# Init CORE
|
||||||
var core: Core = await utils.load_framework()
|
var core_test: Core = await load_framework()
|
||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
var test_in: float = 1500
|
var test_in: float = 1500
|
||||||
var test_out: float = 1.46484375
|
var test_out: float = 1.46484375
|
||||||
var test_out_flat: float = 1.0
|
var test_out_flat: float = 1.0
|
||||||
|
|
||||||
if core.misc.mib2gib(test_in, false) != test_out:
|
if core_test.misc.mib2gib(test_in, false) != test_out:
|
||||||
test_status = 2
|
test_status = 2
|
||||||
test_message = "Non-flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core.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.misc.mib2gib(test_in, true) != test_out_flat:
|
if core_test.misc.mib2gib(test_in, true) != test_out_flat:
|
||||||
test_status = 2
|
test_status = 2
|
||||||
test_message = "Flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core.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
|
test_status = 0
|
||||||
|
@ -81,21 +69,21 @@ func test_mib2gib() -> void:
|
||||||
# gib2mib
|
# gib2mib
|
||||||
func test_gib2mib() -> void:
|
func test_gib2mib() -> void:
|
||||||
# Init CORE
|
# Init CORE
|
||||||
var core: Core = await utils.load_framework()
|
var core_test: Core = await load_framework()
|
||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
var test_in: float = 1.46484375
|
var test_in: float = 1.46484375
|
||||||
var test_out: float = 1500.0
|
var test_out: float = 1500.0
|
||||||
var test_out_flat: float = 1500.0
|
var test_out_flat: float = 1500.0
|
||||||
|
|
||||||
if core.misc.gib2mib(test_in, false) != test_out:
|
if core_test.misc.gib2mib(test_in, false) != test_out:
|
||||||
test_status = 2
|
test_status = 2
|
||||||
test_message = "Non-flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core.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.misc.gib2mib(test_in, true) != test_out_flat:
|
if core_test.misc.gib2mib(test_in, true) != test_out_flat:
|
||||||
test_status = 2
|
test_status = 2
|
||||||
test_message = "Flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core.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
|
test_status = 0
|
||||||
|
@ -103,15 +91,15 @@ func test_gib2mib() -> void:
|
||||||
# format_stringarray
|
# format_stringarray
|
||||||
func test_format_stringarray() -> void:
|
func test_format_stringarray() -> void:
|
||||||
# Init CORE
|
# Init CORE
|
||||||
var core: Core = await utils.load_framework()
|
var core_test: Core = await load_framework()
|
||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
var test_in: Array[String] = ["StarOpenSource", "JeremyStarTM", "Contributors"]
|
var test_in: Array[String] = ["StarOpenSource", "JeremyStarTM", "Contributors"]
|
||||||
var test_out: String = "StarOpenSource, JeremyStarTM & Contributors"
|
var test_out: String = "StarOpenSource, JeremyStarTM & Contributors"
|
||||||
|
|
||||||
if core.misc.format_stringarray(test_in) != test_out:
|
if core_test.misc.format_stringarray(test_in) != test_out:
|
||||||
test_status = 2
|
test_status = 2
|
||||||
test_message = "Test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core.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
|
test_status = 0
|
||||||
|
@ -119,15 +107,15 @@ func test_format_stringarray() -> void:
|
||||||
# format_stringarray (chaotic)
|
# format_stringarray (chaotic)
|
||||||
func test_format_stringarray_chaotic() -> void:
|
func test_format_stringarray_chaotic() -> void:
|
||||||
# Init CORE
|
# Init CORE
|
||||||
var core: Core = await utils.load_framework()
|
var core_test: Core = await load_framework()
|
||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
var test_in: Array[String] = ["StarOpenSource", "JeremyStarTM", "Contributors"]
|
var test_in: Array[String] = ["StarOpenSource", "JeremyStarTM", "Contributors"]
|
||||||
var test_out: String = "aaaaStarOpenSourcebbbb$#!TaaaaJeremyStarTMbbbb :3 aaaaContributorsbbbb"
|
var test_out: String = "aaaaStarOpenSourcebbbb$#!TaaaaJeremyStarTMbbbb :3 aaaaContributorsbbbb"
|
||||||
|
|
||||||
if core.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
|
test_status = 2
|
||||||
test_message = "Test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core.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
|
test_status = 0
|
||||||
|
@ -135,15 +123,15 @@ func test_format_stringarray_chaotic() -> void:
|
||||||
# array_to_stringarray & stringarray_to_array
|
# array_to_stringarray & stringarray_to_array
|
||||||
func test_array_stringarray_conversion() -> void:
|
func test_array_stringarray_conversion() -> void:
|
||||||
# Init CORE
|
# Init CORE
|
||||||
var core: Core = await utils.load_framework()
|
var core_test: Core = await load_framework()
|
||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
var test_in: Array = ["StarOpenSource", "JeremyStarTM", "Contributors"]
|
var test_in: Array = ["StarOpenSource", "JeremyStarTM", "Contributors"]
|
||||||
var test_out: Array[String] = ["StarOpenSource", "JeremyStarTM", "Contributors"]
|
var test_out: Array[String] = ["StarOpenSource", "JeremyStarTM", "Contributors"]
|
||||||
|
|
||||||
if core.misc.stringarray_to_array(core.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
|
test_status = 2
|
||||||
test_message = "Test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core.misc.stringarray_to_array(core.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
|
test_status = 0
|
||||||
|
@ -151,16 +139,16 @@ func test_array_stringarray_conversion() -> void:
|
||||||
# get_center
|
# get_center
|
||||||
func test_get_center() -> void:
|
func test_get_center() -> void:
|
||||||
# Init CORE
|
# Init CORE
|
||||||
var core = await utils.load_framework()
|
var core_test = await load_framework()
|
||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
var test_in_parent: Vector2 = Vector2(5919.591, 6815.9514)
|
var test_in_parent: Vector2 = Vector2(5919.591, 6815.9514)
|
||||||
var test_in_child: Vector2 = Vector2(69.69, 666.0)
|
var test_in_child: Vector2 = Vector2(69.69, 666.0)
|
||||||
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.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
|
test_status = 2
|
||||||
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.misc.stringarray_to_array(core.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
|
test_status = 0
|
||||||
|
|
|
@ -1,8 +1,16 @@
|
||||||
extends Node
|
extends BessereTestsTest
|
||||||
class_name CoreTestUtils
|
|
||||||
|
|
||||||
|
# Callbacks
|
||||||
|
var callback: String = ""
|
||||||
|
|
||||||
|
# CORE
|
||||||
var core: Core
|
var core: Core
|
||||||
|
|
||||||
|
# Unload framework after each test
|
||||||
|
func after_each() -> void:
|
||||||
|
callback = ""
|
||||||
|
await unload_framework()
|
||||||
|
|
||||||
# Framework management
|
# Framework management
|
||||||
func load_framework(config: CoreConfiguration = CoreConfiguration.new()) -> Core:
|
func load_framework(config: CoreConfiguration = CoreConfiguration.new()) -> Core:
|
||||||
core = Core.new(config)
|
core = Core.new(config)
|
||||||
|
@ -12,8 +20,11 @@ func load_framework(config: CoreConfiguration = CoreConfiguration.new()) -> Core
|
||||||
return core
|
return core
|
||||||
|
|
||||||
func unload_framework() -> void:
|
func unload_framework() -> void:
|
||||||
if is_framework_loaded(): get_tree().root.remove_child(core)
|
if is_framework_loaded():
|
||||||
core = null
|
await core.cleanup()
|
||||||
|
get_tree().root.remove_child.call_deferred(core)
|
||||||
|
core = null
|
||||||
|
await get_tree().process_frame
|
||||||
|
|
||||||
func is_framework_loaded() -> bool: return get_node_or_null("/root/CORE") != null
|
func is_framework_loaded() -> bool: return get_node_or_null("/root/CORE") != null
|
||||||
|
|
Loading…
Reference in a new issue