Files
Bubberstation/code/modules/unit_tests/orderable_items.dm
SkyratBot aa8d114bff [MIRROR] Wraps all instances of invoking Fail() into the TEST_FAIL Macro [MDB IGNORE] (#19384)
* Wraps all instances of invoking Fail() into the TEST_FAIL Macro (#73407)

We shouldn't really be invoking the proc itself because then we don't
pass along the failing line/file to our consumers, let's use the macro
in all instances that really need it.

I noticed people were invoking the `Fail()` proc directly rather than
using `TEST_FAIL` instead, so they weren't getting those neat
annotations on their failing code because we never passed along the
failing line/file to actually apply those annotations. That's silly. We
don't even return on `TEST_FAIL` either, so there's no reason to not do
this (only upsides wahoo).

* Wraps all instances of invoking Fail() into the TEST_FAIL Macro

* Correct macro in opfor unit test

---------

Co-authored-by: san7890 <the@san7890.com>
Co-authored-by: Tastyfish <crazychris32@gmail.com>
2023-02-16 19:41:29 -05:00

25 lines
1.1 KiB
Plaintext

/// Makes sure that no orderable items have dynamic descriptions, if they
/// don't explicitly set a description.
/// Also makes sure 2 orderable items don't sell the same thing.
/datum/unit_test/orderable_items
/datum/unit_test/orderable_items/Run()
var/list/all_paths = list()
for (var/datum/orderable_item/orderable_item as anything in subtypesof(/datum/orderable_item))
if(isnull(initial(orderable_item.item_path))) // don't check if they're not actual orderable items
continue
if (!isnull(initial(orderable_item.desc))) //don't check if they have a custom description
continue
var/item_path = initial(orderable_item.item_path)
var/obj/item/item_instance = allocate(item_path)
var/initial_desc = initial(item_instance.desc)
if(item_path in all_paths)
TEST_FAIL("[orderable_item] is purchasable under two different orderable_item types,")
all_paths += item_path
if (item_instance.desc != initial_desc)
TEST_FAIL("[orderable_item] has an item ([item_path]) that has a dynamic description. [item_instance.desc] (dynamic description) != [initial_desc] (initial description)")