[MIRROR] Unit tests for heretic knowledge (#1751)

* Unit tests for heretic knowledge (#55022)

* Unit tests for heretic knowledge

Co-authored-by: EdgeLordExe <42111655+EdgeLordExe@users.noreply.github.com>
This commit is contained in:
SkyratBot
2020-11-21 07:31:04 +01:00
committed by GitHub
co-authored by EdgeLordExe
parent e8468462ea
commit 8e554e846d
4 changed files with 27 additions and 3 deletions
+1
View File
@@ -29,6 +29,7 @@
#include "component_tests.dm"
#include "confusion.dm"
#include "emoting.dm"
#include "heretic_knowledge.dm"
#include "keybinding_init.dm"
#include "machine_disassembly.dm"
#include "medical_wounds.dm"
@@ -0,0 +1,21 @@
/// This test checks all heretic knowledge nodes - excluding the ones which are unreachable on purpose - and ensures players can reach them in game.
/// If it finds a node that is unreachable, it throws an error.
/datum/unit_test/heretic_knowledge/Run()
///List of all knowledge excluding the unreachable base types.
var/list/blacklist = list(/datum/eldritch_knowledge/spell,/datum/eldritch_knowledge/curse,/datum/eldritch_knowledge/final,/datum/eldritch_knowledge/summon)
var/list/all_possible_knowledge = subtypesof(/datum/eldritch_knowledge) - blacklist
var/list/list_to_check = GLOB.heretic_start_knowledge.Copy()
var/i = 0
while(i < length(list_to_check))
var/datum/eldritch_knowledge/eldritch_knowledge = allocate(list_to_check[++i])
for(var/next_knowledge in eldritch_knowledge.next_knowledge)
if(next_knowledge in list_to_check)
continue
list_to_check += next_knowledge
if(length(all_possible_knowledge) != length(all_possible_knowledge & list_to_check))
var/list/unreachables = all_possible_knowledge - list_to_check
for(var/X in unreachables)
var/datum/eldritch_knowledge/eldritch_knowledge = X
Fail("[initial(eldritch_knowledge.name)] is unreachable by players! Add it to the blacklist in /code/modules/unit_tests/heretic_knowledge.dm if it is purposeful!")