mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-10 09:42:29 +00:00
[MIRROR] Unit tests for default hydroponic seed gene setups [MDB IGNORE] (#13671)
* Unit tests for default hydroponic seed gene setups (#67029) Adds a unit test that ensures the default list of genes for all plants is a valid setup. * Unit tests for default hydroponic seed gene setups Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com>
This commit is contained in:
@@ -100,6 +100,7 @@
|
|||||||
#include "holidays.dm"
|
#include "holidays.dm"
|
||||||
#include "hydroponics_harvest.dm"
|
#include "hydroponics_harvest.dm"
|
||||||
#include "hydroponics_self_mutations.dm"
|
#include "hydroponics_self_mutations.dm"
|
||||||
|
#include "hydroponics_validate_genes.dm"
|
||||||
#include "keybinding_init.dm"
|
#include "keybinding_init.dm"
|
||||||
#include "load_map_security.dm"
|
#include "load_map_security.dm"
|
||||||
#include "machine_disassembly.dm"
|
#include "machine_disassembly.dm"
|
||||||
|
|||||||
31
code/modules/unit_tests/hydroponics_validate_genes.dm
Normal file
31
code/modules/unit_tests/hydroponics_validate_genes.dm
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
/// Unit test to ensure plants don't have multiple of a plant type at once by default.
|
||||||
|
/datum/unit_test/hydroponics_validate_genes
|
||||||
|
|
||||||
|
/datum/unit_test/hydroponics_validate_genes/Run()
|
||||||
|
var/list/all_seeds = subtypesof(/obj/item/seeds)
|
||||||
|
|
||||||
|
for(var/seed in all_seeds)
|
||||||
|
var/obj/item/seeds/instantiated_seed = new seed()
|
||||||
|
|
||||||
|
var/all_trait_ids_we_have = NONE
|
||||||
|
for(var/datum/plant_gene/trait/trait_gene in instantiated_seed.genes)
|
||||||
|
// Check if our seed is blacklisted from this trait.
|
||||||
|
for(var/blacklisted_type in trait_gene.seed_blacklist)
|
||||||
|
if(!istype(instantiated_seed, blacklisted_type))
|
||||||
|
continue
|
||||||
|
TEST_FAIL("[instantiated_seed] - [instantiated_seed.type] has a gene which blacklists its type. (Bad gene: [trait_gene] - [trait_gene.type])")
|
||||||
|
|
||||||
|
// Check if we already have a trait id from another trait.
|
||||||
|
if(all_trait_ids_we_have & trait_gene.trait_ids)
|
||||||
|
TEST_FAIL("[instantiated_seed] - [instantiated_seed.type] has an invalid default gene configuration. (Found on: [trait_gene] - [trait_gene.type])")
|
||||||
|
|
||||||
|
all_trait_ids_we_have |= trait_gene.trait_ids
|
||||||
|
|
||||||
|
// Check if we have duplicate traits.
|
||||||
|
for(var/datum/plant_gene/trait/other_trait_gene in instantiated_seed.genes - trait_gene)
|
||||||
|
// Have to check for type exact, since subtypes may be valid with one another.
|
||||||
|
if(trait_gene.type != other_trait_gene.type)
|
||||||
|
continue
|
||||||
|
TEST_FAIL("[instantiated_seed] - [instantiated_seed.type] has a duplicate gene. (Duped gene: [trait_gene] - [trait_gene.type])")
|
||||||
|
|
||||||
|
qdel(instantiated_seed)
|
||||||
Reference in New Issue
Block a user