Files
Aurora.3/code/unit_tests/vueui_tests.dm
Fluffy a4f8285686 Refactor of, and more, unit tests (#16065)
* Initial experiment

* holy shit the pain of this rabbit hole

* F

* F

* F

* F

* FFF

* FFFF

* FFFFFFFFF

* FFFFFFFFFF

* FF

* ffffff

* ffffffff

* F^F

* FFFFFF

* F

* Robusted

* F

* Some readability, hopefully

* Fear

* Aurora was a mistake

* Horrors beyond our comprehension

* Use the appropriate macro across the tests

* Brah

* FF

* Mute janitors robusting the ling

* Frail doctors revealing to be more trained than a KGB sleeper agent when the crew armory opens

* FFFFFFF

* gujbjh

* Shitcode, shitcode everywhere

* Pain

* Cursed codebase

* Fix AI mask qdel, SQL tests to macro

* Attempt at github grouping

* Take two

* Brah

* Maybe this looks better

* Different formatting

* FFS

* Visuals

* pain

* FFFFF

* hyuh

* fgdsgd

* igyguybujgb

* Just calling the parent here

* dsfs

* fdsaf

* Move more pieces to use the macros

* Finish moving to macro

* gah

* Changelog, some touchups

* Fix another found runtime

* GDI
2023-04-03 10:47:31 +00:00

66 lines
1.9 KiB
Plaintext

/datum/unit_test/vueui_monitors_watch_vars
name = "VueUI: Var Monitors Have Populated Watch Lists"
/datum/unit_test/vueui_monitors_watch_vars/start_test()
var/list/to_test = subtypesof(/datum/vueui_var_monitor)
var/count_failed = 0
for (var/path in to_test)
var/datum/vueui_var_monitor/VM = new path()
if (!VM.var_holders || !VM.var_holders.len)
TEST_FAIL("VueUI var monitor has an empty var_holders list: [VM.type].")
count_failed++
if (count_failed)
TEST_FAIL("\[[count_failed]\] VueUI var monitors without var holders discovered.")
else
TEST_PASS("All VueUI var monitors have var holders.")
return TRUE
/datum/unit_test/vueui_monitors_have_valid_watchers
name = "VueUI: Var Monitors Have Valid Keys"
/datum/unit_test/vueui_monitors_have_valid_watchers/start_test()
var/list/to_test = subtypesof(/datum/vueui_var_monitor)
var/count_failed = 0
for (var/path in to_test)
var/datum/vueui_var_monitor/VM = new path()
var/datum/subject = null
try
subject = new VM.subject_type()
catch ()
TEST_FAIL("VueUI var monitor subject runtimed while being spawned. Monitor: [VM.type].")
count_failed++
continue
if (!is_subject_valid(VM, subject))
count_failed++
if (count_failed)
TEST_FAIL("\[[count_failed]\] VueUI var monitors have invalid var watches.")
else
TEST_PASS("All VueUI var monitors have valid var watchers.")
return TRUE
/datum/unit_test/vueui_monitors_have_valid_watchers/proc/is_subject_valid(datum/vueui_var_monitor/VM, datum/subject)
. = TRUE
for (var/_iter in VM.var_holders)
var/datum/vueui_var_holder/VH = _iter
if (!VH.source_key || !VH.data_key)
TEST_FAIL("VueUI var monitor has no source or data key: [VM.type].")
. = FALSE
continue
if (!(VH.source_key in subject.vars))
TEST_FAIL("VueUI var monitor is watching a var '[VH.source_key]' not found on the subject: [VM.type]. Subject: [subject.type].")
. = FALSE
continue