Force LF line endings with gitattributes and convert repo (#52266)

Co-authored-by: Aleksej Komarov <stylemistake@gmail.com>
This commit is contained in:
jdawg1290
2020-07-16 03:02:40 +03:00
committed by GitHub
co-authored by Aleksej Komarov
parent 39e8bd721f
commit 62676e72a8
1133 changed files with 266492 additions and 266454 deletions
+32 -32
View File
@@ -1,32 +1,32 @@
//include unit test files in this module in this ifdef
//Keep this sorted alphabetically
#ifdef UNIT_TESTS
/// Asserts that a condition is true
/// If the condition is not true, fails the test
#define TEST_ASSERT(assertion, reason) if (!(assertion)) { return Fail("Assertion failed: [reason || "No reason"]") }
/// Asserts that the two parameters passed are equal, fails otherwise
/// Optionally allows an additional message in the case of a failure
#define TEST_ASSERT_EQUAL(a, b, message) if ((a) != (b)) { return Fail("Expected [a] to be equal to [b].[message ? " [message]" : ""]") }
#include "anchored_mobs.dm"
#include "bespoke_id.dm"
#include "card_mismatch.dm"
#include "chain_pull_through_space.dm"
#include "component_tests.dm"
#include "outfit_sanity.dm"
#include "plantgrowth_tests.dm"
#include "reagent_id_typos.dm"
#include "reagent_recipe_collisions.dm"
#include "siunit.dm"
#include "spawn_humans.dm"
#include "species_whitelists.dm"
#include "subsystem_init.dm"
#include "surgeries.dm"
#include "timer_sanity.dm"
#include "unit_test.dm"
#undef TEST_ASSERT
#undef TEST_ASSERT_EQUAL
#endif
//include unit test files in this module in this ifdef
//Keep this sorted alphabetically
#ifdef UNIT_TESTS
/// Asserts that a condition is true
/// If the condition is not true, fails the test
#define TEST_ASSERT(assertion, reason) if (!(assertion)) { return Fail("Assertion failed: [reason || "No reason"]") }
/// Asserts that the two parameters passed are equal, fails otherwise
/// Optionally allows an additional message in the case of a failure
#define TEST_ASSERT_EQUAL(a, b, message) if ((a) != (b)) { return Fail("Expected [a] to be equal to [b].[message ? " [message]" : ""]") }
#include "anchored_mobs.dm"
#include "bespoke_id.dm"
#include "card_mismatch.dm"
#include "chain_pull_through_space.dm"
#include "component_tests.dm"
#include "outfit_sanity.dm"
#include "plantgrowth_tests.dm"
#include "reagent_id_typos.dm"
#include "reagent_recipe_collisions.dm"
#include "siunit.dm"
#include "spawn_humans.dm"
#include "species_whitelists.dm"
#include "subsystem_init.dm"
#include "surgeries.dm"
#include "timer_sanity.dm"
#include "unit_test.dm"
#undef TEST_ASSERT
#undef TEST_ASSERT_EQUAL
#endif
+9 -9
View File
@@ -1,9 +1,9 @@
/datum/unit_test/anchored_mobs/Run()
var/list/L = list()
for(var/i in typesof(/mob))
var/mob/M = i
if(initial(M.anchored))
L += "[i]"
if(!L.len)
return //passed!
Fail("The following mobs are defined as anchored. This is incompatible with the new move force/resist system and needs to be revised.: [L.Join(" ")]")
/datum/unit_test/anchored_mobs/Run()
var/list/L = list()
for(var/i in typesof(/mob))
var/mob/M = i
if(initial(M.anchored))
L += "[i]"
if(!L.len)
return //passed!
Fail("The following mobs are defined as anchored. This is incompatible with the new move force/resist system and needs to be revised.: [L.Join(" ")]")
@@ -1,62 +1,62 @@
/datum/unit_test/chain_pull_through_space
var/turf/open/space/space_tile
var/turf/claimed_tile
var/mob/living/carbon/human/alice
var/mob/living/carbon/human/bob
var/mob/living/carbon/human/charlie
/datum/unit_test/chain_pull_through_space/New()
..()
// Create a space tile that goes to another z-level
claimed_tile = run_loc_bottom_left
space_tile = new(locate(run_loc_bottom_left.x, run_loc_bottom_left.y, run_loc_bottom_left.z))
space_tile.destination_x = 100
space_tile.destination_y = 100
space_tile.destination_z = 5
// Create our list of humans, all adjacent to one another
alice = new(locate(run_loc_bottom_left.x + 2, run_loc_bottom_left.y, run_loc_bottom_left.z))
alice.name = "Alice"
bob = new(locate(run_loc_bottom_left.x + 3, run_loc_bottom_left.y, run_loc_bottom_left.z))
bob.name = "Bob"
charlie = new(locate(run_loc_bottom_left.x + 4, run_loc_bottom_left.y, run_loc_bottom_left.z))
charlie.name = "Charlie"
/datum/unit_test/chain_pull_through_space/Destroy()
space_tile.copyTurf(claimed_tile)
qdel(alice)
qdel(bob)
qdel(charlie)
return ..()
/datum/unit_test/chain_pull_through_space/Run()
// Alice pulls Bob, who pulls Charlie
// Normally, when Alice moves forward, the rest follow
alice.start_pulling(bob)
bob.start_pulling(charlie)
// Walk normally to the left, make sure we're still a chain
alice.Move(locate(run_loc_bottom_left.x + 1, run_loc_bottom_left.y, run_loc_bottom_left.z))
if (bob.x != run_loc_bottom_left.x + 2)
return Fail("During normal move, Bob was not at the correct x ([bob.x])")
if (charlie.x != run_loc_bottom_left.x + 3)
return Fail("During normal move, Charlie was not at the correct x ([charlie.x])")
// We're going through the space turf now that should teleport us
alice.Move(run_loc_bottom_left)
if (alice.z != space_tile.destination_z)
return Fail("Alice did not teleport to the destination z-level. Current location: ([alice.x], [alice.y], [alice.z])")
if (bob.z != space_tile.destination_z)
return Fail("Bob did not teleport to the destination z-level. Current location: ([bob.x], [bob.y], [bob.z])")
if (!bob.Adjacent(alice))
return Fail("Bob is not adjacent to Alice. Bob is at [bob.x], Alice is at [alice.x]")
if (charlie.z != space_tile.destination_z)
return Fail("Charlie did not teleport to the destination z-level. Current location: ([charlie.x], [charlie.y], [charlie.z])")
if (!charlie.Adjacent(bob))
return Fail("Charlie is not adjacent to Bob. Charlie is at [charlie.x], Bob is at [bob.x]")
/datum/unit_test/chain_pull_through_space
var/turf/open/space/space_tile
var/turf/claimed_tile
var/mob/living/carbon/human/alice
var/mob/living/carbon/human/bob
var/mob/living/carbon/human/charlie
/datum/unit_test/chain_pull_through_space/New()
..()
// Create a space tile that goes to another z-level
claimed_tile = run_loc_bottom_left
space_tile = new(locate(run_loc_bottom_left.x, run_loc_bottom_left.y, run_loc_bottom_left.z))
space_tile.destination_x = 100
space_tile.destination_y = 100
space_tile.destination_z = 5
// Create our list of humans, all adjacent to one another
alice = new(locate(run_loc_bottom_left.x + 2, run_loc_bottom_left.y, run_loc_bottom_left.z))
alice.name = "Alice"
bob = new(locate(run_loc_bottom_left.x + 3, run_loc_bottom_left.y, run_loc_bottom_left.z))
bob.name = "Bob"
charlie = new(locate(run_loc_bottom_left.x + 4, run_loc_bottom_left.y, run_loc_bottom_left.z))
charlie.name = "Charlie"
/datum/unit_test/chain_pull_through_space/Destroy()
space_tile.copyTurf(claimed_tile)
qdel(alice)
qdel(bob)
qdel(charlie)
return ..()
/datum/unit_test/chain_pull_through_space/Run()
// Alice pulls Bob, who pulls Charlie
// Normally, when Alice moves forward, the rest follow
alice.start_pulling(bob)
bob.start_pulling(charlie)
// Walk normally to the left, make sure we're still a chain
alice.Move(locate(run_loc_bottom_left.x + 1, run_loc_bottom_left.y, run_loc_bottom_left.z))
if (bob.x != run_loc_bottom_left.x + 2)
return Fail("During normal move, Bob was not at the correct x ([bob.x])")
if (charlie.x != run_loc_bottom_left.x + 3)
return Fail("During normal move, Charlie was not at the correct x ([charlie.x])")
// We're going through the space turf now that should teleport us
alice.Move(run_loc_bottom_left)
if (alice.z != space_tile.destination_z)
return Fail("Alice did not teleport to the destination z-level. Current location: ([alice.x], [alice.y], [alice.z])")
if (bob.z != space_tile.destination_z)
return Fail("Bob did not teleport to the destination z-level. Current location: ([bob.x], [bob.y], [bob.z])")
if (!bob.Adjacent(alice))
return Fail("Bob is not adjacent to Alice. Bob is at [bob.x], Alice is at [alice.x]")
if (charlie.z != space_tile.destination_z)
return Fail("Charlie did not teleport to the destination z-level. Current location: ([charlie.x], [charlie.y], [charlie.z])")
if (!charlie.Adjacent(bob))
return Fail("Charlie is not adjacent to Bob. Charlie is at [charlie.x], Bob is at [bob.x]")
+12 -12
View File
@@ -1,12 +1,12 @@
/datum/unit_test/component_duping/Run()
var/list/bad_dms = list()
var/list/bad_dts = list()
for(var/t in typesof(/datum/component))
var/datum/component/comp = t
if(!isnum(initial(comp.dupe_mode)))
bad_dms += t
var/dupe_type = initial(comp.dupe_type)
if(dupe_type && !ispath(dupe_type))
bad_dts += t
if(length(bad_dms) || length(bad_dts))
Fail("Components with invalid dupe modes: ([bad_dms.Join(",")]) ||| Components with invalid dupe types: ([bad_dts.Join(",")])")
/datum/unit_test/component_duping/Run()
var/list/bad_dms = list()
var/list/bad_dts = list()
for(var/t in typesof(/datum/component))
var/datum/component/comp = t
if(!isnum(initial(comp.dupe_mode)))
bad_dms += t
var/dupe_type = initial(comp.dupe_type)
if(dupe_type && !ispath(dupe_type))
bad_dts += t
if(length(bad_dms) || length(bad_dts))
Fail("Components with invalid dupe modes: ([bad_dms.Join(",")]) ||| Components with invalid dupe types: ([bad_dts.Join(",")])")
+50 -50
View File
@@ -1,50 +1,50 @@
#define CHECK_OUTFIT_SLOT(outfit_key, slot_name) if (outfit.##outfit_key) { \
H.equip_to_slot_or_del(new outfit.##outfit_key(H), ##slot_name, TRUE); \
/* We don't check the result of equip_to_slot_or_del because it returns false for random jumpsuits, as they delete themselves on init */ \
if (!H.get_item_by_slot(##slot_name)) { \
Fail("[outfit.name]'s [#outfit_key] is invalid!"); \
} \
}
/datum/unit_test/outfit_sanity/Run()
var/mob/living/carbon/human/H = allocate(/mob/living/carbon/human)
for (var/outfit_type in subtypesof(/datum/outfit))
// Only make one human and keep undressing it because it's much faster
for (var/obj/item/I in H.get_equipped_items(include_pockets = TRUE))
qdel(I)
var/datum/outfit/outfit = new outfit_type
outfit.pre_equip(H, TRUE)
CHECK_OUTFIT_SLOT(uniform, ITEM_SLOT_ICLOTHING)
CHECK_OUTFIT_SLOT(suit, ITEM_SLOT_OCLOTHING)
CHECK_OUTFIT_SLOT(back, ITEM_SLOT_BACK)
CHECK_OUTFIT_SLOT(belt, ITEM_SLOT_BELT)
CHECK_OUTFIT_SLOT(gloves, ITEM_SLOT_GLOVES)
CHECK_OUTFIT_SLOT(shoes, ITEM_SLOT_FEET)
CHECK_OUTFIT_SLOT(head, ITEM_SLOT_HEAD)
CHECK_OUTFIT_SLOT(mask, ITEM_SLOT_MASK)
CHECK_OUTFIT_SLOT(neck, ITEM_SLOT_NECK)
CHECK_OUTFIT_SLOT(ears, ITEM_SLOT_EARS)
CHECK_OUTFIT_SLOT(glasses, ITEM_SLOT_EYES)
CHECK_OUTFIT_SLOT(id, ITEM_SLOT_ID)
CHECK_OUTFIT_SLOT(suit_store, ITEM_SLOT_SUITSTORE)
CHECK_OUTFIT_SLOT(l_pocket, ITEM_SLOT_LPOCKET)
CHECK_OUTFIT_SLOT(r_pocket, ITEM_SLOT_RPOCKET)
if (outfit.backpack_contents || outfit.box)
var/list/backpack_contents = outfit.backpack_contents?.Copy()
if (outfit.box)
if (!backpack_contents)
backpack_contents = list()
backpack_contents.Insert(1, outfit.box)
backpack_contents[outfit.box] = 1
for (var/path in backpack_contents)
var/number = backpack_contents[path] || 1
for (var/_ in 1 to number)
if (!H.equip_to_slot_or_del(new path(H), ITEM_SLOT_BACKPACK, TRUE))
Fail("[outfit.name]'s backpack_contents are invalid! Couldn't add [path] to backpack.")
#undef CHECK_OUTFIT_SLOT
#define CHECK_OUTFIT_SLOT(outfit_key, slot_name) if (outfit.##outfit_key) { \
H.equip_to_slot_or_del(new outfit.##outfit_key(H), ##slot_name, TRUE); \
/* We don't check the result of equip_to_slot_or_del because it returns false for random jumpsuits, as they delete themselves on init */ \
if (!H.get_item_by_slot(##slot_name)) { \
Fail("[outfit.name]'s [#outfit_key] is invalid!"); \
} \
}
/datum/unit_test/outfit_sanity/Run()
var/mob/living/carbon/human/H = allocate(/mob/living/carbon/human)
for (var/outfit_type in subtypesof(/datum/outfit))
// Only make one human and keep undressing it because it's much faster
for (var/obj/item/I in H.get_equipped_items(include_pockets = TRUE))
qdel(I)
var/datum/outfit/outfit = new outfit_type
outfit.pre_equip(H, TRUE)
CHECK_OUTFIT_SLOT(uniform, ITEM_SLOT_ICLOTHING)
CHECK_OUTFIT_SLOT(suit, ITEM_SLOT_OCLOTHING)
CHECK_OUTFIT_SLOT(back, ITEM_SLOT_BACK)
CHECK_OUTFIT_SLOT(belt, ITEM_SLOT_BELT)
CHECK_OUTFIT_SLOT(gloves, ITEM_SLOT_GLOVES)
CHECK_OUTFIT_SLOT(shoes, ITEM_SLOT_FEET)
CHECK_OUTFIT_SLOT(head, ITEM_SLOT_HEAD)
CHECK_OUTFIT_SLOT(mask, ITEM_SLOT_MASK)
CHECK_OUTFIT_SLOT(neck, ITEM_SLOT_NECK)
CHECK_OUTFIT_SLOT(ears, ITEM_SLOT_EARS)
CHECK_OUTFIT_SLOT(glasses, ITEM_SLOT_EYES)
CHECK_OUTFIT_SLOT(id, ITEM_SLOT_ID)
CHECK_OUTFIT_SLOT(suit_store, ITEM_SLOT_SUITSTORE)
CHECK_OUTFIT_SLOT(l_pocket, ITEM_SLOT_LPOCKET)
CHECK_OUTFIT_SLOT(r_pocket, ITEM_SLOT_RPOCKET)
if (outfit.backpack_contents || outfit.box)
var/list/backpack_contents = outfit.backpack_contents?.Copy()
if (outfit.box)
if (!backpack_contents)
backpack_contents = list()
backpack_contents.Insert(1, outfit.box)
backpack_contents[outfit.box] = 1
for (var/path in backpack_contents)
var/number = backpack_contents[path] || 1
for (var/_ in 1 to number)
if (!H.equip_to_slot_or_del(new path(H), ITEM_SLOT_BACKPACK, TRUE))
Fail("[outfit.name]'s backpack_contents are invalid! Couldn't add [path] to backpack.")
#undef CHECK_OUTFIT_SLOT
+7 -7
View File
@@ -1,7 +1,7 @@
/datum/unit_test/spawn_humans/Run()
var/locs = block(run_loc_bottom_left, run_loc_top_right)
for(var/I in 1 to 5)
new /mob/living/carbon/human(pick(locs))
sleep(50)
/datum/unit_test/spawn_humans/Run()
var/locs = block(run_loc_bottom_left, run_loc_top_right)
for(var/I in 1 to 5)
new /mob/living/carbon/human(pick(locs))
sleep(50)
+79 -79
View File
@@ -1,79 +1,79 @@
/datum/unit_test/amputation/Run()
var/mob/living/carbon/human/patient = allocate(/mob/living/carbon/human)
var/mob/living/carbon/human/user = allocate(/mob/living/carbon/human)
TEST_ASSERT_EQUAL(patient.get_missing_limbs().len, 0, "Patient is somehow missing limbs before surgery")
var/datum/surgery/amputation/surgery = new(patient, BODY_ZONE_R_ARM, patient.get_bodypart(BODY_ZONE_R_ARM))
var/datum/surgery_step/sever_limb/sever_limb = new
sever_limb.success(user, patient, BODY_ZONE_R_ARM, null, surgery)
TEST_ASSERT_EQUAL(patient.get_missing_limbs().len, 1, "Patient did not lose any limbs")
TEST_ASSERT_EQUAL(patient.get_missing_limbs()[1], BODY_ZONE_R_ARM, "Patient is missing a limb that isn't the one we operated on")
/datum/unit_test/brain_surgery/Run()
var/mob/living/carbon/human/patient = allocate(/mob/living/carbon/human)
patient.gain_trauma_type(BRAIN_TRAUMA_MILD, TRAUMA_RESILIENCE_SURGERY)
patient.setOrganLoss(ORGAN_SLOT_BRAIN, 20)
TEST_ASSERT(patient.has_trauma_type(), "Patient does not have any traumas, despite being given one")
var/mob/living/carbon/human/user = allocate(/mob/living/carbon/human)
var/datum/surgery_step/fix_brain/fix_brain = new
fix_brain.success(user, patient)
TEST_ASSERT(!patient.has_trauma_type(), "Patient kept their brain trauma after brain surgery")
TEST_ASSERT(patient.getOrganLoss(ORGAN_SLOT_BRAIN) < 20, "Patient did not heal their brain damage after brain surgery")
/datum/unit_test/multiple_surgeries/Run()
var/mob/living/carbon/human/user = allocate(/mob/living/carbon/human)
var/mob/living/carbon/human/patient_zero = allocate(/mob/living/carbon/human)
var/mob/living/carbon/human/patient_one = allocate(/mob/living/carbon/human)
var/obj/item/scalpel/scalpel = allocate(/obj/item/scalpel)
var/datum/surgery_step/incise/surgery_step = new
var/datum/surgery/organ_manipulation/surgery_for_zero = new
INVOKE_ASYNC(surgery_step, /datum/surgery_step/proc/initiate, user, patient_zero, BODY_ZONE_CHEST, scalpel, surgery_for_zero)
TEST_ASSERT(surgery_for_zero.step_in_progress, "Surgery on patient zero was not initiated")
var/datum/surgery/organ_manipulation/surgery_for_one = new
// Without waiting for the incision to complete, try to start a new surgery
TEST_ASSERT(!surgery_step.initiate(user, patient_one, BODY_ZONE_CHEST, scalpel, surgery_for_one), "Was allowed to start a second surgery without the rod of asclepius")
TEST_ASSERT(!surgery_for_one.step_in_progress, "Surgery for patient one is somehow in progress, despite not initiating")
user.apply_status_effect(STATUS_EFFECT_HIPPOCRATIC_OATH)
INVOKE_ASYNC(surgery_step, /datum/surgery_step/proc/initiate, user, patient_one, BODY_ZONE_CHEST, scalpel, surgery_for_one)
TEST_ASSERT(surgery_for_one.step_in_progress, "Surgery on patient one was not initiated, despite having rod of asclepius")
/datum/unit_test/tend_wounds/Run()
var/mob/living/carbon/human/patient = allocate(/mob/living/carbon/human)
patient.take_overall_damage(100, 100)
var/mob/living/carbon/human/user = allocate(/mob/living/carbon/human)
// Test that tending wounds actually lowers damage
var/datum/surgery_step/heal/brute/basic/basic_brute_heal = new
basic_brute_heal.success(user, patient, BODY_ZONE_CHEST)
TEST_ASSERT(patient.getBruteLoss() < 100, "Tending brute wounds didn't lower brute damage ([patient.getBruteLoss()])")
var/datum/surgery_step/heal/burn/basic/basic_burn_heal = new
basic_burn_heal.success(user, patient, BODY_ZONE_CHEST)
TEST_ASSERT(patient.getFireLoss() < 100, "Tending burn wounds didn't lower burn damage ([patient.getFireLoss()])")
// Test that wearing clothing lowers heal amount
var/mob/living/carbon/human/naked_patient = allocate(/mob/living/carbon/human)
naked_patient.take_overall_damage(100)
var/mob/living/carbon/human/clothed_patient = allocate(/mob/living/carbon/human)
clothed_patient.equipOutfit(/datum/outfit/job/doctor, TRUE)
clothed_patient.take_overall_damage(100)
basic_brute_heal.success(user, naked_patient, BODY_ZONE_CHEST)
basic_brute_heal.success(user, clothed_patient, BODY_ZONE_CHEST)
TEST_ASSERT(naked_patient.getBruteLoss() < clothed_patient.getBruteLoss(), "Naked patient did not heal more from wounds tending than a clothed patient")
/datum/unit_test/amputation/Run()
var/mob/living/carbon/human/patient = allocate(/mob/living/carbon/human)
var/mob/living/carbon/human/user = allocate(/mob/living/carbon/human)
TEST_ASSERT_EQUAL(patient.get_missing_limbs().len, 0, "Patient is somehow missing limbs before surgery")
var/datum/surgery/amputation/surgery = new(patient, BODY_ZONE_R_ARM, patient.get_bodypart(BODY_ZONE_R_ARM))
var/datum/surgery_step/sever_limb/sever_limb = new
sever_limb.success(user, patient, BODY_ZONE_R_ARM, null, surgery)
TEST_ASSERT_EQUAL(patient.get_missing_limbs().len, 1, "Patient did not lose any limbs")
TEST_ASSERT_EQUAL(patient.get_missing_limbs()[1], BODY_ZONE_R_ARM, "Patient is missing a limb that isn't the one we operated on")
/datum/unit_test/brain_surgery/Run()
var/mob/living/carbon/human/patient = allocate(/mob/living/carbon/human)
patient.gain_trauma_type(BRAIN_TRAUMA_MILD, TRAUMA_RESILIENCE_SURGERY)
patient.setOrganLoss(ORGAN_SLOT_BRAIN, 20)
TEST_ASSERT(patient.has_trauma_type(), "Patient does not have any traumas, despite being given one")
var/mob/living/carbon/human/user = allocate(/mob/living/carbon/human)
var/datum/surgery_step/fix_brain/fix_brain = new
fix_brain.success(user, patient)
TEST_ASSERT(!patient.has_trauma_type(), "Patient kept their brain trauma after brain surgery")
TEST_ASSERT(patient.getOrganLoss(ORGAN_SLOT_BRAIN) < 20, "Patient did not heal their brain damage after brain surgery")
/datum/unit_test/multiple_surgeries/Run()
var/mob/living/carbon/human/user = allocate(/mob/living/carbon/human)
var/mob/living/carbon/human/patient_zero = allocate(/mob/living/carbon/human)
var/mob/living/carbon/human/patient_one = allocate(/mob/living/carbon/human)
var/obj/item/scalpel/scalpel = allocate(/obj/item/scalpel)
var/datum/surgery_step/incise/surgery_step = new
var/datum/surgery/organ_manipulation/surgery_for_zero = new
INVOKE_ASYNC(surgery_step, /datum/surgery_step/proc/initiate, user, patient_zero, BODY_ZONE_CHEST, scalpel, surgery_for_zero)
TEST_ASSERT(surgery_for_zero.step_in_progress, "Surgery on patient zero was not initiated")
var/datum/surgery/organ_manipulation/surgery_for_one = new
// Without waiting for the incision to complete, try to start a new surgery
TEST_ASSERT(!surgery_step.initiate(user, patient_one, BODY_ZONE_CHEST, scalpel, surgery_for_one), "Was allowed to start a second surgery without the rod of asclepius")
TEST_ASSERT(!surgery_for_one.step_in_progress, "Surgery for patient one is somehow in progress, despite not initiating")
user.apply_status_effect(STATUS_EFFECT_HIPPOCRATIC_OATH)
INVOKE_ASYNC(surgery_step, /datum/surgery_step/proc/initiate, user, patient_one, BODY_ZONE_CHEST, scalpel, surgery_for_one)
TEST_ASSERT(surgery_for_one.step_in_progress, "Surgery on patient one was not initiated, despite having rod of asclepius")
/datum/unit_test/tend_wounds/Run()
var/mob/living/carbon/human/patient = allocate(/mob/living/carbon/human)
patient.take_overall_damage(100, 100)
var/mob/living/carbon/human/user = allocate(/mob/living/carbon/human)
// Test that tending wounds actually lowers damage
var/datum/surgery_step/heal/brute/basic/basic_brute_heal = new
basic_brute_heal.success(user, patient, BODY_ZONE_CHEST)
TEST_ASSERT(patient.getBruteLoss() < 100, "Tending brute wounds didn't lower brute damage ([patient.getBruteLoss()])")
var/datum/surgery_step/heal/burn/basic/basic_burn_heal = new
basic_burn_heal.success(user, patient, BODY_ZONE_CHEST)
TEST_ASSERT(patient.getFireLoss() < 100, "Tending burn wounds didn't lower burn damage ([patient.getFireLoss()])")
// Test that wearing clothing lowers heal amount
var/mob/living/carbon/human/naked_patient = allocate(/mob/living/carbon/human)
naked_patient.take_overall_damage(100)
var/mob/living/carbon/human/clothed_patient = allocate(/mob/living/carbon/human)
clothed_patient.equipOutfit(/datum/outfit/job/doctor, TRUE)
clothed_patient.take_overall_damage(100)
basic_brute_heal.success(user, naked_patient, BODY_ZONE_CHEST)
basic_brute_heal.success(user, clothed_patient, BODY_ZONE_CHEST)
TEST_ASSERT(naked_patient.getBruteLoss() < clothed_patient.getBruteLoss(), "Naked patient did not heal more from wounds tending than a clothed patient")
+92 -92
View File
@@ -1,92 +1,92 @@
/*
Usage:
Override /Run() to run your test code
Call Fail() to fail the test (You should specify a reason)
You may use /New() and /Destroy() for setup/teardown respectively
You can use the run_loc_bottom_left and run_loc_top_right to get turfs for testing
*/
GLOBAL_DATUM(current_test, /datum/unit_test)
GLOBAL_VAR_INIT(failed_any_test, FALSE)
GLOBAL_VAR(test_log)
/datum/unit_test
//Bit of metadata for the future maybe
var/list/procs_tested
//usable vars
var/turf/run_loc_bottom_left
var/turf/run_loc_top_right
//internal shit
var/succeeded = TRUE
var/list/allocated
var/list/fail_reasons
/datum/unit_test/New()
allocated = new
run_loc_bottom_left = locate(1, 1, 1)
run_loc_top_right = locate(5, 5, 1)
/datum/unit_test/Destroy()
//clear the test area
for(var/atom/movable/AM in block(run_loc_bottom_left, run_loc_top_right))
qdel(AM)
QDEL_LIST(allocated)
return ..()
/datum/unit_test/proc/Run()
Fail("Run() called parent or not implemented")
/datum/unit_test/proc/Fail(reason = "No reason")
succeeded = FALSE
if(!istext(reason))
reason = "FORMATTED: [reason != null ? reason : "NULL"]"
LAZYADD(fail_reasons, reason)
/// Allocates an instance of the provided type, and places it somewhere in an available loc
/// Instances allocated through this proc will be destroyed when the test is over
/datum/unit_test/proc/allocate(type, ...)
var/list/arguments = args.Copy(2)
if (!arguments.len)
arguments = list(run_loc_bottom_left)
else if (arguments[1] == null)
arguments[1] = run_loc_bottom_left
var/instance = new type(arglist(arguments))
allocated += instance
return instance
/proc/RunUnitTests()
CHECK_TICK
for(var/I in subtypesof(/datum/unit_test))
var/datum/unit_test/test = new I
GLOB.current_test = test
var/duration = REALTIMEOFDAY
test.Run()
duration = REALTIMEOFDAY - duration
GLOB.current_test = null
GLOB.failed_any_test |= !test.succeeded
var/list/log_entry = list("[test.succeeded ? "PASS" : "FAIL"]: [I] [duration / 10]s")
var/list/fail_reasons = test.fail_reasons
qdel(test)
for(var/J in 1 to LAZYLEN(fail_reasons))
log_entry += "\tREASON #[J]: [fail_reasons[J]]"
log_test(log_entry.Join("\n"))
CHECK_TICK
SSticker.force_ending = TRUE
/*
Usage:
Override /Run() to run your test code
Call Fail() to fail the test (You should specify a reason)
You may use /New() and /Destroy() for setup/teardown respectively
You can use the run_loc_bottom_left and run_loc_top_right to get turfs for testing
*/
GLOBAL_DATUM(current_test, /datum/unit_test)
GLOBAL_VAR_INIT(failed_any_test, FALSE)
GLOBAL_VAR(test_log)
/datum/unit_test
//Bit of metadata for the future maybe
var/list/procs_tested
//usable vars
var/turf/run_loc_bottom_left
var/turf/run_loc_top_right
//internal shit
var/succeeded = TRUE
var/list/allocated
var/list/fail_reasons
/datum/unit_test/New()
allocated = new
run_loc_bottom_left = locate(1, 1, 1)
run_loc_top_right = locate(5, 5, 1)
/datum/unit_test/Destroy()
//clear the test area
for(var/atom/movable/AM in block(run_loc_bottom_left, run_loc_top_right))
qdel(AM)
QDEL_LIST(allocated)
return ..()
/datum/unit_test/proc/Run()
Fail("Run() called parent or not implemented")
/datum/unit_test/proc/Fail(reason = "No reason")
succeeded = FALSE
if(!istext(reason))
reason = "FORMATTED: [reason != null ? reason : "NULL"]"
LAZYADD(fail_reasons, reason)
/// Allocates an instance of the provided type, and places it somewhere in an available loc
/// Instances allocated through this proc will be destroyed when the test is over
/datum/unit_test/proc/allocate(type, ...)
var/list/arguments = args.Copy(2)
if (!arguments.len)
arguments = list(run_loc_bottom_left)
else if (arguments[1] == null)
arguments[1] = run_loc_bottom_left
var/instance = new type(arglist(arguments))
allocated += instance
return instance
/proc/RunUnitTests()
CHECK_TICK
for(var/I in subtypesof(/datum/unit_test))
var/datum/unit_test/test = new I
GLOB.current_test = test
var/duration = REALTIMEOFDAY
test.Run()
duration = REALTIMEOFDAY - duration
GLOB.current_test = null
GLOB.failed_any_test |= !test.succeeded
var/list/log_entry = list("[test.succeeded ? "PASS" : "FAIL"]: [I] [duration / 10]s")
var/list/fail_reasons = test.fail_reasons
qdel(test)
for(var/J in 1 to LAZYLEN(fail_reasons))
log_entry += "\tREASON #[J]: [fail_reasons[J]]"
log_test(log_entry.Join("\n"))
CHECK_TICK
SSticker.force_ending = TRUE