From bf76be49785b8b79516fd183b74b449dd0e81d9f Mon Sep 17 00:00:00 2001 From: capsaicin <84609863+capsaicinz@users.noreply.github.com> Date: Fri, 22 Apr 2022 21:14:45 -0500 Subject: [PATCH] unit test for /obj/item/stack singular_name (#66378) Checks if all non-blacklisted stack items have singular_name set, because apparently that's pretty important Gives it to a few ones that didn't --- code/game/objects/items/devices/polycircuit.dm | 1 + .../objects/items/stacks/sheets/leather.dm | 2 +- code/game/objects/items/stacks/wrap.dm | 1 + code/modules/unit_tests/_unit_tests.dm | 1 + code/modules/unit_tests/stack_singular_name.dm | 18 ++++++++++++++++++ 5 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 code/modules/unit_tests/stack_singular_name.dm diff --git a/code/game/objects/items/devices/polycircuit.dm b/code/game/objects/items/devices/polycircuit.dm index 2cc170c6060..9dbdbff993d 100644 --- a/code/game/objects/items/devices/polycircuit.dm +++ b/code/game/objects/items/devices/polycircuit.dm @@ -6,6 +6,7 @@ w_class = WEIGHT_CLASS_TINY max_amount = 8 merge_type = /obj/item/stack/circuit_stack + singular_name = "circuit aggregate" var/circuit_type = /obj/item/electronics/airlock var/chosen_circuit = "airlock" diff --git a/code/game/objects/items/stacks/sheets/leather.dm b/code/game/objects/items/stacks/sheets/leather.dm index 931ba901cfb..cb28aeed081 100644 --- a/code/game/objects/items/stacks/sheets/leather.dm +++ b/code/game/objects/items/stacks/sheets/leather.dm @@ -297,7 +297,7 @@ GLOBAL_LIST_INIT(sinew_recipes, list ( \ /obj/item/stack/sheet/animalhide/carp name = "carp scales" desc = "The scaly skin of a space carp. It looks quite beatiful when detached from the foul creature who once wore it." - singular_name = "carp scales" + singular_name = "carp scale" icon_state = "sheet-carp" inhand_icon_state = "sheet-carp" merge_type = /obj/item/stack/sheet/animalhide/carp diff --git a/code/game/objects/items/stacks/wrap.dm b/code/game/objects/items/stacks/wrap.dm index f8bee136e20..21e0910ff39 100644 --- a/code/game/objects/items/stacks/wrap.dm +++ b/code/game/objects/items/stacks/wrap.dm @@ -15,6 +15,7 @@ max_amount = 25 resistance_flags = FLAMMABLE merge_type = /obj/item/stack/wrapping_paper + singular_name = "wrapping paper" /obj/item/stack/wrapping_paper/Initialize(mapload) . = ..() diff --git a/code/modules/unit_tests/_unit_tests.dm b/code/modules/unit_tests/_unit_tests.dm index 740a3927e83..793e54e4364 100644 --- a/code/modules/unit_tests/_unit_tests.dm +++ b/code/modules/unit_tests/_unit_tests.dm @@ -110,6 +110,7 @@ #include "species_config_sanity.dm" #include "species_unique_id.dm" #include "species_whitelists.dm" +#include "stack_singular_name.dm" #include "stomach.dm" #include "strippable.dm" #include "subsystem_init.dm" diff --git a/code/modules/unit_tests/stack_singular_name.dm b/code/modules/unit_tests/stack_singular_name.dm new file mode 100644 index 00000000000..ab1128150a4 --- /dev/null +++ b/code/modules/unit_tests/stack_singular_name.dm @@ -0,0 +1,18 @@ +/** + * Goes through every subtype of /obj/item/stack to check for a singular name, var/singular_name. + * Everything within the blacklist does not need to be tested because it exists to be overriden. + * This test will fail if a subtype of /obj/item/stack is missing a singular name. + */ +/datum/unit_test/stack_singular_name + +/datum/unit_test/stack_singular_name/Run() + var/list/blacklist = list( // all of these are generally parents that exist to be overriden; ex. /obj/item/stack/license_plates exists to branch into /filled and /empty + /obj/item/stack/sheet, + /obj/item/stack/sheet/mineral, + /obj/item/stack/license_plates, + /obj/item/stack/sheet/animalhide, + ) + + for(var/obj/item/stack/stack_check as anything in subtypesof(/obj/item/stack) - blacklist) + if(!initial(stack_check.singular_name)) + Fail("[stack_check] is missing a singular name!")