Remove stupid core_test variable and return value

I somehow fucked up and thought that the 'core' variable in unitbase.gd is used for some other stuff and therefore assigned it a new variable called 'core_test'. Seems like I was wrong however and slipped up the code I wrote just days before. Anyway, fixed this slip up, have a nice day :)
This commit is contained in:
JeremyStar™ 2024-03-31 16:20:34 +02:00
parent 25c4667a05
commit 32b82c8f5b
3 changed files with 51 additions and 54 deletions

View file

@ -17,26 +17,26 @@ 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
core_test = await load_framework(config) await load_framework(config)
# Load module # Load module
var module: CoreBaseModule = CoreBaseModule.new() var module: CoreBaseModule = CoreBaseModule.new()
module.set_script(load("res://tests/test_resources/custom_module.gd")) module.set_script(load("res://tests/test_resources/custom_module.gd"))
# Register module # Register module
core_test.register_custom_module("test_module", "tests/test_resources/custom_module.gd", module) core.register_custom_module("test_module", "tests/test_resources/custom_module.gd", module)
await 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":
rerror("Module did not register") rerror("Module did not register")
return return
elif core_test.get_node_or_null("Custom Modules/test_module") == null: elif core.get_node_or_null("Custom Modules/test_module") == null:
rerror("Could not find module node") rerror("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.get_custom_module("test_module")
if module_get == null: if module_get == null:
rerror("Got null from get_custom_module method") rerror("Got null from get_custom_module method")
return return
@ -50,11 +50,11 @@ func test_custom_module_support() -> void:
return return
# Unregister module # Unregister module
core_test.unregister_custom_module("test_module") core.unregister_custom_module("test_module")
await wait_process_time() await wait_process_time()
# Check if unregistered # Check if unregistered
if core_test.get_node_or_null("Custom Modules/test_module") == null: if core.get_node_or_null("Custom Modules/test_module") == null:
rok("Successfully registered, got, used and unregistered a custom module") rok("Successfully registered, got, used and unregistered a custom module")
return return
@ -63,23 +63,23 @@ func test_reload_config() -> void:
var config: CoreConfiguration = CoreConfiguration.new() var config: CoreConfiguration = CoreConfiguration.new()
# Init CORE # Init CORE
core_test = await load_framework() 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_test.reload_configuration(config) core.reload_configuration(config)
await wait_process_time() await wait_process_time()
# Check config # Check config
if core_test.config != config: if core.config != config:
rerror("Got invalid node from config variable") rerror("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.logger.config_colored != false or core.logger.config_level != CoreTypes.LoggerLevel.NONE or core.logui.background.visible != false:
rerror("Configuration did not apply all values correctly") rerror("Configuration did not apply all values correctly")
return return
@ -87,17 +87,17 @@ func test_reload_config() -> void:
func test_formatted_string() -> void: func test_formatted_string() -> void:
# Init CORE # Init CORE
core_test = await load_framework() 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_test.get_version_semantic() var test_semantic: Array[int] = core.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_test.version_type): match(core.version_type):
CoreTypes.VersionType.RELEASE: CoreTypes.VersionType.RELEASE:
test_type = "Release" test_type = "Release"
test_type_technical = "r" test_type_technical = "r"
@ -111,18 +111,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_test.is_devmode(): test_devmode = "Enabled" if core.is_devmode(): test_devmode = "Enabled"
else: test_devmode = "Disabled" else: test_devmode = "Disabled"
# test_headless # test_headless
if core_test.config.headless: test_headless = "Enabled" if core.config.headless: test_headless = "Enabled"
else: test_headless = "Disabled" else: test_headless = "Disabled"
# test_custommodules # test_custommodules
if core_test.config.custom_modules: test_custommodules = "Enabled" if core.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_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.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"
# Compare # Compare
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) + "')") if await core.get_formatted_string(test_raw) != test_formatted: rerror("Test did not return the right value (in '" + test_raw + "', expected '" + test_formatted + "', got '" + await core.get_formatted_string(test_raw) + "')")
else: rok() else: rok()

View file

@ -3,19 +3,19 @@ extends 'res://tests/unitbase.gd'
# byte2mib # byte2mib
func test_byte2mib() -> void: func test_byte2mib() -> void:
# Init CORE # Init CORE
core_test = await load_framework() 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_test.misc.byte2mib(test_in, false) != test_out: if core.misc.byte2mib(test_in, false) != test_out:
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)) + "')") rerror("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)) + "')")
return return
if core_test.misc.byte2mib(test_in, true) != test_out_flat: if core.misc.byte2mib(test_in, true) != test_out_flat:
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)) + "')") rerror("Flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core.misc.byte2mib(test_in, true)) + "')")
return return
rok() rok()
@ -23,19 +23,19 @@ func test_byte2mib() -> void:
# mib2byte # mib2byte
func test_mib2byte() -> void: func test_mib2byte() -> void:
# Init CORE # Init CORE
core_test = await load_framework() 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_test.misc.mib2byte(test_in, false) != test_out: if core.misc.mib2byte(test_in, false) != test_out:
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)) + "')") rerror("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)) + "')")
return return
if core_test.misc.mib2byte(test_in, true) != test_out_flat: if core.misc.mib2byte(test_in, true) != test_out_flat:
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)) + "')") rerror("Flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core.misc.mib2byte(test_in, true)) + "')")
return return
rok() rok()
@ -43,19 +43,19 @@ func test_mib2byte() -> void:
# mib2gib # mib2gib
func test_mib2gib() -> void: func test_mib2gib() -> void:
# Init CORE # Init CORE
core_test = await load_framework() 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_test.misc.mib2gib(test_in, false) != test_out: if core.misc.mib2gib(test_in, false) != test_out:
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)) + "')") rerror("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)) + "')")
return return
if core_test.misc.mib2gib(test_in, true) != test_out_flat: if core.misc.mib2gib(test_in, true) != test_out_flat:
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)) + "')") rerror("Flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core.misc.mib2gib(test_in, true)) + "')")
return return
rok() rok()
@ -63,19 +63,19 @@ func test_mib2gib() -> void:
# gib2mib # gib2mib
func test_gib2mib() -> void: func test_gib2mib() -> void:
# Init CORE # Init CORE
core_test = await load_framework() 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_test.misc.gib2mib(test_in, false) != test_out: if core.misc.gib2mib(test_in, false) != test_out:
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)) + "')") rerror("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)) + "')")
return return
if core_test.misc.gib2mib(test_in, true) != test_out_flat: if core.misc.gib2mib(test_in, true) != test_out_flat:
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)) + "')") rerror("Flat test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core.misc.gib2mib(test_in, true)) + "')")
return return
rok() rok()
@ -83,14 +83,14 @@ func test_gib2mib() -> void:
# format_stringarray # format_stringarray
func test_format_stringarray() -> void: func test_format_stringarray() -> void:
# Init CORE # Init CORE
core_test = await load_framework() 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_test.misc.format_stringarray(test_in) != test_out: if core.misc.format_stringarray(test_in) != test_out:
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)) + "')") rerror("Test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core.misc.format_stringarray(test_in)) + "')")
return return
rok() rok()
@ -98,14 +98,14 @@ 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
core_test = await load_framework() 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_test.misc.format_stringarray(test_in, "aaaa", "bbbb", "$#!T", " :3 ") != test_out: if core.misc.format_stringarray(test_in, "aaaa", "bbbb", "$#!T", " :3 ") != test_out:
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)) + "')") rerror("Test did not return the right value (in '" + str(test_in) + "', expected '" + str(test_out) + "', got '" + str(core.misc.format_stringarray(test_in)) + "')")
return return
rok() rok()
@ -113,14 +113,14 @@ 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
core_test = await load_framework() 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_test.misc.stringarray_to_array(core_test.misc.array_to_stringarray(test_in)) != test_out: if core.misc.stringarray_to_array(core.misc.array_to_stringarray(test_in)) != test_out:
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))) + "')") rerror("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))) + "')")
return return
rok() rok()
@ -128,15 +128,15 @@ func test_array_stringarray_conversion() -> void:
# get_center # get_center
func test_get_center() -> void: func test_get_center() -> void:
# Init CORE # Init CORE
core_test = await load_framework() 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_test.misc.get_center(test_in_parent, test_in_child) != test_out: if core.misc.get_center(test_in_parent, test_in_child) != test_out:
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))) + "')") 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.misc.stringarray_to_array(core.misc.get_center(test_in_parent, test_in_child))) + "')")
return return
rok() rok()

View file

@ -5,21 +5,18 @@ var core: Core
# Used during testing # Used during testing
var callback: String = "" var callback: String = ""
var core_test: Core
# Unload framework after each test # Unload framework after each test
func after_each() -> void: func after_each() -> void:
callback = "" callback = ""
core_test = null
await unload_framework() await unload_framework()
# Framework management # Framework management
func load_framework(config: CoreConfiguration = CoreConfiguration.new()) -> Core: func load_framework(config: CoreConfiguration = CoreConfiguration.new()) -> void:
core = Core.new(config) core = Core.new(config)
get_tree().root.add_child(core) get_tree().root.add_child(core)
await get_tree().process_frame await get_tree().process_frame
await core.complete_init() await core.complete_init()
return core
func unload_framework() -> void: func unload_framework() -> void:
if is_framework_loaded(): if is_framework_loaded():