<commit_before>/// Checks that the length of the initial contents of a closet doesn't exceed its storage capacity.
/// Also checks that nothing inside that isn't immediate is a steal objective.
/datum/unit_test/closets

/datum/unit_test/closets/Run()
	var/list/all_closets = subtypesof(/obj/structure/closet)
	//Supply pods. They are sent, crashed, opened and never closed again. They also cause exceptions in nullspace.
	all_closets -= typesof(/obj/structure/closet/supplypod)

	for(var/closet_type in all_closets)
		var/obj/structure/closet/closet = allocate(closet_type)

		// Copy is necessary otherwise closet.contents - immediate_contents returns an empty list
		var/list/immediate_contents = closet.contents.Copy()

		closet.PopulateContents()
		var/contents_len = length(closet.contents)

		if(contents_len > closet.storage_capacity)
			TEST_FAIL("Initial Contents of [closet.type] ([contents_len]) exceed its storage capacity ([closet.storage_capacity]).")

		for (var/obj/item/item in closet.contents - immediate_contents)
			if (item.type in GLOB.steal_item_handler.objectives_by_path)
				TEST_FAIL("[closet_type] contains a steal objective [item.type] in PopulateContents(). Move it to populate_contents_immediate().")
<commit_msg>Fixes a closet harddel (#69889)<commit_after>/// Checks that the length of the initial contents of a closet doesn't exceed its storage capacity.
/// Also checks that nothing inside that isn't immediate is a steal objective.
/datum/unit_test/closets

/datum/unit_test/closets/Run()
	var/list/all_closets = subtypesof(/obj/structure/closet)
	//Supply pods. They are sent, crashed, opened and never closed again. They also cause exceptions in nullspace.
	all_closets -= typesof(/obj/structure/closet/supplypod)

	for(var/closet_type in all_closets)
		var/obj/structure/closet/closet = allocate(closet_type)
		if(istype(closet_type, /obj/structure/closet/emcloset) && QDELETED(closet)) // this is here because the emcloset subtype has a chance of returning a qdel hint on initialize
			continue

		// Copy is necessary otherwise closet.contents - immediate_contents returns an empty list
		var/list/immediate_contents = closet.contents.Copy()
		closet.PopulateContents()
		var/contents_len = length(closet.contents)

		if(contents_len > closet.storage_capacity)
			TEST_FAIL("Initial Contents of [closet.type] ([contents_len]) exceed its storage capacity ([closet.storage_capacity]).")

		for (var/obj/item/item in closet.contents - immediate_contents)
			if (item.type in GLOB.steal_item_handler.objectives_by_path)
				TEST_FAIL("[closet_type] contains a steal objective [item.type] in PopulateContents(). Move it to populate_contents_immediate().")

{'fraction_non_alphanumeric': 0.09732540861812779, 'fraction_numerical': 0.0018573551263001485, 'mean_word_length': 4.879912663755459, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7371554', 'n_tokens_mistral': 856, 'n_tokens_neox': 797, 'n_words': 235}