From d01e7242a5accc8942f3ff5da1c0d517008bbdf0 Mon Sep 17 00:00:00 2001 From: Penelope Haze Date: Tue, 21 Jan 2025 13:24:26 -0500 Subject: [PATCH] Simplify unit test dummy mob creation --- code/unit_tests/equipment_tests.dm | 31 +++++++++++++----------------- code/unit_tests/mob_tests.dm | 4 +--- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/code/unit_tests/equipment_tests.dm b/code/unit_tests/equipment_tests.dm index 25146ab9251..65224802150 100644 --- a/code/unit_tests/equipment_tests.dm +++ b/code/unit_tests/equipment_tests.dm @@ -1,42 +1,37 @@ /datum/unit_test/vision_glasses name = "EQUIPMENT: Vision Template" template = /datum/unit_test/vision_glasses - var/mob/living/human/H = null + var/mob/living/human/subject = null var/expectation = SEE_INVISIBLE_NOLIGHTING var/glasses_type = null async = 1 /datum/unit_test/vision_glasses/start_test() - var/list/test = create_test_mob_with_mind(get_safe_turf(), /mob/living/human) - if(isnull(test)) - fail("Check Runtimed in Mob creation") - - if(test["result"] == FAILURE) - fail(test["msg"]) - async = 0 - return 0 - - H = locate(test["mobref"]) - H.equip_to_slot(new glasses_type(H), slot_glasses_str) + subject = new(get_safe_turf(), SPECIES_HUMAN) // force human so default map species doesn't mess with anything + subject.equip_to_slot(new glasses_type(subject), slot_glasses_str) return 1 /datum/unit_test/vision_glasses/check_result() - if(isnull(H) || H.life_tick < 2) + if(isnull(subject) || subject.life_tick < 2) return 0 - if(isnull(H.get_equipped_item(slot_glasses_str))) + if(isnull(subject.get_equipped_item(slot_glasses_str))) fail("Mob doesn't have glasses on") - H.handle_vision() // Because Life has a client check that bypasses updating vision + subject.handle_vision() // Because Life has a client check that bypasses updating vision - if(H.see_invisible == expectation) - pass("Mob See invisible is [H.see_invisible]") + if(subject.see_invisible == expectation) + pass("Mob See invisible is [subject.see_invisible]") else - fail("Mob See invisible is [H.see_invisible] / expected [expectation]") + fail("Mob See invisible is [subject.see_invisible] / expected [expectation]") return 1 +/datum/unit_test/vision_glasses/teardown_test() + QDEL_NULL(subject) + . = ..() + /datum/unit_test/vision_glasses/NVG name = "EQUIPMENT: NVG see_invis" glasses_type = /obj/item/clothing/glasses/night diff --git a/code/unit_tests/mob_tests.dm b/code/unit_tests/mob_tests.dm index cb0c1ffd480..3ebfdcd6357 100644 --- a/code/unit_tests/mob_tests.dm +++ b/code/unit_tests/mob_tests.dm @@ -58,9 +58,7 @@ // ============================================================================ -var/global/default_mobloc = null - -/proc/create_test_mob_with_mind(var/turf/mobloc, var/mobtype = /mob/living/human) +/datum/unit_test/mob_damage/proc/create_test_mob_with_mind(var/turf/mobloc, var/mobtype = /mob/living/human) var/list/test_result = list("result" = FAILURE, "msg" = "", "mobref" = null) if(!mobloc)