unit tests (#17749)

This commit is contained in:
Charlie
2022-05-09 14:56:02 +01:00
committed by GitHub
parent 9963500fc5
commit 5f800f57df
4 changed files with 36 additions and 5 deletions
+5 -3
View File
@@ -66,7 +66,7 @@ GLOBAL_LIST_INIT(uplink_items, subtypesof(/datum/uplink_item))
var/name = "item name"
var/category = "item category"
var/desc = "Item Description"
var/reference = "Item Reference"
var/reference = null
var/item = null
var/cost = 0
var/last = 0 // Appear last
@@ -314,7 +314,7 @@ GLOBAL_LIST_INIT(uplink_items, subtypesof(/datum/uplink_item))
/datum/uplink_item/jobspecific/pickpocketgloves
name = "Pickpocket's Gloves"
desc = "A pair of sleek gloves to aid in pickpocketing. While wearing these, you can loot your target without them knowing. Pickpocketing puts the item directly into your hand."
reference = "PG"
reference = "PPG"
item = /obj/item/clothing/gloves/color/black/thief
cost = 6
job = list("Assistant")
@@ -1061,6 +1061,7 @@ GLOBAL_LIST_INIT(uplink_items, subtypesof(/datum/uplink_item))
/datum/uplink_item/explosives/detomatix/nuclear
desc = "When inserted into a personal digital assistant, this cartridge gives you five opportunities to detonate PDAs of crewmembers who have their message feature enabled. The concussive effect from the explosion will knock the recipient out for a short period, and deafen them for longer. It has a chance to detonate your PDA. This version comes with a program to toggle your nuclear shuttle blast doors remotely."
item = /obj/item/cartridge/syndicate/nuclear
reference = "DEPCN"
excludefrom = list()
gamemodes = list(/datum/game_mode/nuclear)
@@ -1075,6 +1076,7 @@ GLOBAL_LIST_INIT(uplink_items, subtypesof(/datum/uplink_item))
/datum/uplink_item/explosives/grenadier
name = "Grenadier's belt"
desc = "A belt containing 26 lethally dangerous and destructive grenades."
reference = "GRB"
item = /obj/item/storage/belt/grenade/full
cost = 30
surplus = 0
@@ -1534,7 +1536,7 @@ GLOBAL_LIST_INIT(uplink_items, subtypesof(/datum/uplink_item))
name = "Dropwall generator box"
desc = "A box of 5 dropwall shield generators, which can be used to make temporary directional shields that block projectiles, thrown objects, and reduce explosions. Configure the direction before throwing."
item = /obj/item/storage/box/syndie_kit/dropwall
reference = "ESD"
reference = "DWG"
cost = 10
gamemodes = list(/datum/game_mode/nuclear)
+2 -2
View File
@@ -4,7 +4,7 @@
var/spell_type = null
var/desc = ""
var/category = "Offensive"
var/log_name = "XX" //What it shows up as in logs
var/log_name = null //What it shows up as in logs
var/cost = 2
var/refundable = TRUE
var/obj/effect/proc_holder/spell/S = null //Since spellbooks can be used by only one person anyway we can track the actual spell
@@ -289,7 +289,7 @@
/datum/spellbook_entry/charge
name = "Charge"
spell_type = /obj/effect/proc_holder/spell/charge
log_name = "CH"
log_name = "CHG"
category = "Assistance"
cost = 1
+1
View File
@@ -7,6 +7,7 @@
#include "crafting_lists.dm"
#include "log_format.dm"
#include "map_templates.dm"
#include "purchase_reference_test.dm"
#include "reagent_id_typos.dm"
#include "rustg_version.dm"
#include "spawn_humans.dm"
@@ -0,0 +1,28 @@
// tests if there are duplicate or null refs/lognames for uplink items and spellbook items respectively
/datum/unit_test/uplink_refs/Run()
var/list/uplink_refs = list()
for(var/datum/uplink_item/I as anything in subtypesof(/datum/uplink_item))
if(isnull(initial(I.item)))
continue //don't test them if they don't have an item
var/uplink_ref = initial(I.reference)
if(isnull(uplink_ref))
Fail("uplink item [initial(I.name)] has no reference")
continue
if(uplink_ref in uplink_refs)
Fail("uplink reference [uplink_ref] is used multiple times")
uplink_refs += uplink_ref
/datum/unit_test/spellbook_refs/Run()
var/list/spell_refs = list()
var/list/blacklist = list(/datum/spellbook_entry/summon,
/datum/spellbook_entry/item,
/datum/spellbook_entry/loadout,)
for(var/datum/spellbook_entry/entry as anything in subtypesof(/datum/spellbook_entry) - blacklist)
var/spell_ref = initial(entry.log_name)
if(isnull(spell_ref))
Fail("spellbook entry [initial(entry.name)] has no reference")
continue
if(spell_ref in spell_refs)
Fail("spellbook reference [spell_ref] is used multiple times")
spell_refs += spell_ref