Files
Bubberstation/code/__DEFINES/unit_tests.dm
Gandalf f2b328e14a Post Mirror Grounding (#21034)
* PT1 MAP RESET

* Lints

* [MDB Ignore] Adds a unit test for typepaths that are required to be mapped onto each station map (#74985)

Inspired by #74967 and #68459 , and the fact that Tramstation regresses
very often -

Adds a unit test, `required_map_items`, which ensures that certain
typepaths which should definitely be mapped onto every map is mapped
onto every map

It can also be used to ensure that items which should not be mapped in
multiple times are not, among other things.

I included a few examples -
- Min 1, max inf of each head of staff stamps
- Min 1, max 1 departmental order consoles
- Min 1, max inf comms console
- Min 1, max 1 Pun Pun
- Min 1, max 1 Poly
- Min 1, max 1 Ian

If, in the future, a mapper decides they (for some reason) do not want a
certain previously-required item on their map, the test can be adjusted
such that it allows excluding or something, but currently it should be
for items which require conscious thought about.

I attempted to make this a linter before realizing two things
1. Someone might make a spawner which spawns the items, or they might
get placed in a locker, in any case this accounts for everything on init
2. Linters run on every map, non-station maps included

So I went with a test

Why is it always the CMO stamp?

Not necessary (unless I find a map missing something, then this will be
updated)

* yay

* Update VoidRaptor.dmm

* Update blackmesa.dmm

* wew

* New sand and water sprites (ported from Bay) (#75254)

* e

* Update AntagInfoClock.tsx

* Update LimbsPage.tsx

* Update area_spawn_entries.dm

* Update LimbsPage.tsx

---------

Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com>
2023-05-10 01:24:11 +00:00

51 lines
2.0 KiB
Plaintext

/// Are tests enabled with no focus?
/// Use this when performing test assertions outside of a unit test,
/// since a focused test means that you're trying to run a test quickly.
/// If a parameter is provided, will check if the focus is on that test name.
/// For example, PERFORM_ALL_TESTS(log_mapping) will only run if either
/// no test is focused, or the focus is log_mapping.
#ifdef UNIT_TESTS
// Bit of a trick here, if focus isn't passed in then it'll check for /datum/unit_test/, which is never the case.
#define PERFORM_ALL_TESTS(focus...) (isnull(GLOB.focused_tests) || (/datum/unit_test/##focus in GLOB.focused_tests))
#else
// UNLINT necessary here so that if (PERFORM_ALL_TESTS()) works
#define PERFORM_ALL_TESTS(...) UNLINT(FALSE)
#endif
/// ASSERT(), but it only actually does anything during unit tests
#ifdef UNIT_TESTS
#define TEST_ONLY_ASSERT(test, explanation) if(!(test)) {CRASH(explanation)}
#else
#define TEST_ONLY_ASSERT(test, explanation)
#endif
/**
* Used for registering typepaths of item to be tracked as a "required map item"
* This is used to ensure that that all station maps have certain items mapped in that they should have
* Or that people aren't mapping in an excess of items that they shouldn't be
* (For example, all map should only ever have 1 Pun Pun)
*
* Min is inclusive, Max is inclusive (so 1, 1 means min of 1, max of 1, or only 1 allowed)
*
* This should only be used in Initialize(). And don't forget to update the unit test with the type itself!
*/
#ifdef UNIT_TESTS
#define REGISTER_REQUIRED_MAP_ITEM(min, max) \
do { \
if(mapload) { \
var/turf/spawn_turf = get_turf(src); \
if(is_station_level(spawn_turf?.z || 0)) { \
var/datum/required_item/existing_value = GLOB.required_map_items[type]; \
if(isnull(existing_value)) { \
var/datum/required_item/new_value = new(type, min, max); \
GLOB.required_map_items[type] = new_value; \
} else { \
existing_value.total_amount += 1; \
}; \
}; \
}; \
} while (FALSE)
#else
#define REGISTER_REQUIRED_MAP_ITEM(min, max)
#endif