From 14c125f41d0262882d570b31dde89b3fe35d6574 Mon Sep 17 00:00:00 2001 From: MistakeNot4892 Date: Sun, 6 Jun 2021 23:07:42 +1000 Subject: [PATCH] Added unit test to ensure emote key uniqueness. --- code/modules/emotes/definitions/audible.dm | 14 ++++++------ code/modules/emotes/definitions/slimes.dm | 10 ++++----- code/modules/emotes/definitions/visible.dm | 24 ++++++++++---------- code/modules/emotes/emote_mob.dm | 2 +- code/unit_tests/decl_tests.dm | 26 ++++++++++++++++++++++ polaris.dme | 1 + 6 files changed, 52 insertions(+), 25 deletions(-) create mode 100644 code/unit_tests/decl_tests.dm diff --git a/code/modules/emotes/definitions/audible.dm b/code/modules/emotes/definitions/audible.dm index 15f547b9e8..c233cc1ccc 100644 --- a/code/modules/emotes/definitions/audible.dm +++ b/code/modules/emotes/definitions/audible.dm @@ -12,7 +12,7 @@ emote_message_radio_synthetic = emote_message_synthetic_3p /decl/emote/audible/deathgasp_alien - key = "deathgasp" + key = "adeathgasp" emote_message_3p = "lets out a waning guttural screech, green blood bubbling from its maw." /decl/emote/audible/whimper @@ -29,7 +29,7 @@ emote_message_3p = "scretches." /decl/emote/audible/choke - key ="choke" + key = "choke" emote_message_3p = "chokes." conscious = FALSE @@ -63,7 +63,7 @@ emote_message_3p = "boops." /decl/emote/audible/beep - key = "beep" + key = "bbeep" emote_message_3p = "You beep." emote_message_3p = "beeps." emote_sound = 'sound/machines/twobeep.ogg' @@ -133,18 +133,18 @@ emote_message_3p = "grunts." /decl/emote/audible/bug_hiss - key ="hiss" + key = "bhiss" emote_message_3p_target = "hisses at TARGET." emote_message_3p = "hisses." emote_sound = 'sound/voice/BugHiss.ogg' /decl/emote/audible/bug_buzz - key ="buzz" + key = "bbuzz" emote_message_3p = "buzzes its wings." emote_sound = 'sound/voice/BugBuzz.ogg' /decl/emote/audible/bug_chitter - key ="chitter" + key = "chitter" emote_message_3p = "chitters." emote_sound = 'sound/voice/Bug.ogg' @@ -213,7 +213,7 @@ emote_sound = 'sound/voice/teshsqueak.ogg' // Copyright CC BY 3.0 InspectorJ (freesound.org) for the source audio. /decl/emote/audible/teshchirp - key = "chirp" + key = "tchirp" emote_message_1p = "You chirp!" emote_message_3p = "chirps!" emote_message_1p_target = "You chirp at TARGET!" diff --git a/code/modules/emotes/definitions/slimes.dm b/code/modules/emotes/definitions/slimes.dm index bde5b580aa..65f50b069d 100644 --- a/code/modules/emotes/definitions/slimes.dm +++ b/code/modules/emotes/definitions/slimes.dm @@ -12,21 +12,21 @@ return ..() && isslime(user) /decl/emote/slime/pout - key = "pout" + key = "mpout" mood = "pout" /decl/emote/slime/sad - key = "sad" + key = "msad" mood = "sad" /decl/emote/slime/angry - key = "angry" + key = "mangry" mood = "angry" /decl/emote/slime/frown - key = "frown" + key = "mfrown" mood = "mischevous" /decl/emote/slime/smile - key = "smile" + key = "msmile" mood = ":3" diff --git a/code/modules/emotes/definitions/visible.dm b/code/modules/emotes/definitions/visible.dm index fa19ac257a..d37058626d 100644 --- a/code/modules/emotes/definitions/visible.dm +++ b/code/modules/emotes/definitions/visible.dm @@ -1,5 +1,5 @@ /decl/emote/visible - key ="tail" + key = "tail" emote_message_3p = "waves USER_THEIR tail." message_type = VISIBLE_MESSAGE @@ -9,48 +9,48 @@ emote_message_3p = "scratches." /decl/emote/visible/drool - key ="drool" + key = "drool" emote_message_3p = "drools." conscious = FALSE /decl/emote/visible/nod - key ="nod" + key = "nod" emote_message_3p_target = "nods USER_THEIR head at TARGET." emote_message_3p = "nods USER_THEIR head." /decl/emote/visible/sway - key ="sway" + key = "sways" emote_message_3p = "sways around dizzily." /decl/emote/visible/sulk - key ="sulk" + key = "sulk" emote_message_3p = "sulks down sadly." /decl/emote/visible/dance - key ="dance" + key = "dance" check_restraints = TRUE emote_message_3p = "dances around happily." /decl/emote/visible/roll - key ="roll" + key = "roll" check_restraints = TRUE emote_message_3p = "rolls." /decl/emote/visible/shake - key ="shake" + key = "shake" emote_message_3p = "shakes USER_THEIR head." /decl/emote/visible/jump - key ="jump" + key = "jump" emote_message_3p = "jumps!" /decl/emote/visible/shiver - key ="shiver" + key = "shiver" emote_message_3p = "shivers." conscious = FALSE /decl/emote/visible/collapse - key ="collapse" + key = "collapse" emote_message_3p = "collapses!" /decl/emote/visible/collapse/do_extra(var/mob/user) @@ -216,7 +216,7 @@ emote_message_3p = "vibrates!" /decl/emote/visible/deathgasp_robot - key = "deathgasp" + key = "rdeathgasp" emote_message_3p = "shudders violently for a moment, then becomes motionless, USER_THEIR eyes slowly darkening." /decl/emote/visible/handshake diff --git a/code/modules/emotes/emote_mob.dm b/code/modules/emotes/emote_mob.dm index f315fd69c4..f871e11f3e 100644 --- a/code/modules/emotes/emote_mob.dm +++ b/code/modules/emotes/emote_mob.dm @@ -71,7 +71,7 @@ return if(!use_emote.mob_can_use(src)) - to_chat(src, SPAN_WARNING("You cannot use the emote '[act]'. Type say *help for a list of usable emotes.")) + to_chat(src, SPAN_WARNING("You cannot use the emote '[act]'. Type say *help for a list of usable emotes.")) return if(m_type != use_emote.message_type && use_emote.conscious && stat != CONSCIOUS) diff --git a/code/unit_tests/decl_tests.dm b/code/unit_tests/decl_tests.dm new file mode 100644 index 0000000000..4879fa5bc4 --- /dev/null +++ b/code/unit_tests/decl_tests.dm @@ -0,0 +1,26 @@ +/datum/unit_test/emotes_shall_have_unique_keys + name = "DECLS: Emotes Shall Have Unique Keys" + +/datum/unit_test/emotes_shall_have_unique_keys/start_test() + + var/list/keys = list() + var/list/duplicates = list() + + var/list/all_emotes = decls_repository.get_decls_of_subtype(/decl/emote) + for(var/etype in all_emotes) + var/decl/emote/emote = all_emotes[etype] + if(!emote.key) + continue + if(emote.key in keys) + if(!duplicates[emote.key]) + duplicates[emote.key] = list() + duplicates[emote.key] += etype + else + keys += emote.key + + if(length(duplicates)) + fail("[length(duplicates)] emote\s had overlapping keys: [english_list(duplicates)].") + else + pass("All emotes had unique keys.") + + return TRUE diff --git a/polaris.dme b/polaris.dme index f28cafd97a..2b4b99e4b3 100644 --- a/polaris.dme +++ b/polaris.dme @@ -3223,6 +3223,7 @@ #include "code\modules\xenobio\machinery\processor.dm" #include "code\modules\xgm\xgm_gas_data.dm" #include "code\modules\xgm\xgm_gas_mixture.dm" +#include "code\unit_tests\decl_tests.dm" #include "code\unit_tests\language_tests.dm" #include "code\unit_tests\loadout_tests.dm" #include "code\unit_tests\map_tests.dm"