Files
Bubberstation/code/modules/unit_tests/cargo_selling.dm
FalloutFalcon 060d4a65ba valid_subtypes proc (#93541)
## About The Pull Request
discussed in #93439, a generic proc for getting a list of all types
minus abstract types.
applies this to most instances of a for loop that currently filters out
abstract types

it SHOULD be a nothing burger for performance, however I have not bench
marked the difference. (also testing, there is a total of 7 calls in
init to it)
2025-10-28 12:49:18 -05:00

43 lines
1.8 KiB
Plaintext

/// Makes sure exports work and things can be sold
/datum/unit_test/cargo_selling
/obj/item/cargo_unit_test_container
/obj/item/cargo_unit_test_container/Initialize(mapload)
. = ..()
new /obj/item/cargo_unit_test_content(src)
/obj/item/cargo_unit_test_content
/datum/export/cargo_unit_test_container
cost = PAYCHECK_LOWER
export_types = list(/obj/item/cargo_unit_test_container)
/datum/export/cargo_unit_test_content
cost = PAYCHECK_COMMAND
export_types = list(/obj/item/cargo_unit_test_content)
/datum/unit_test/cargo_selling/Run()
for(var/datum/export/subtype as anything in valid_subtypesof(/datum/export))
if(subtype::k_recovery_time < SSprocessing.wait)
TEST_FAIL("[subtype] should have k_recovery time >= [SSprocessing.wait]")
var/datum/export/sell = new subtype
if(!length(sell.export_types))
TEST_FAIL("[subtype] has no export types")
qdel(sell)
var/obj/item/cargo_unit_test_container/box = allocate(/obj/item/cargo_unit_test_container)
var/obj/item/cargo_unit_test_container/box_skip_content = allocate(/obj/item/cargo_unit_test_container)
var/datum/export_report/report_one = export_item_and_contents(box, apply_elastic = FALSE)
if(isnull(report_one))
TEST_FAIL("called 'export_item_and_contents', but no export report was returned.")
var/value = counterlist_sum(report_one.total_value)
TEST_ASSERT_EQUAL(value, PAYCHECK_LOWER + PAYCHECK_COMMAND, "'export_item_and_contents' value didn't match expected value")
var/datum/export_report/report_two = export_single_item(box_skip_content, apply_elastic = FALSE)
if(isnull(report_two))
TEST_FAIL("called 'export_single_item', but no export report was returned.")
value = counterlist_sum(report_two.total_value)
TEST_ASSERT_EQUAL(value, PAYCHECK_LOWER, "'export_single_item' value didn't match expected value")