Módulo:Lang/tests/ISO 639 sobrescritos y en desuso tag from name

Este módulo no tiene página de documentación[crear]
local p = require('Módulo:UnitTests')
local lang_data =  mw.loadData('Módulo:Lang/data'); -- language name override and transliteration tool-tip tables

--[[--------------------------< T E S T _ P A T T E R N S _ G E T >--------------------------------------------

build a table of test patterns where each entry in the table is a table with two members:
	{"<name>", "<tag>"}

]]

local function override_test_patterns_get()
	local tpats = {}															-- collect test patterns here
	for tag, names in pairs (lang_data.override) do
		local pattern = {};														-- here we assemble the test pattern for <name>
		table.insert (pattern, names[1]);								-- add first <name> only to the pattern
		table.insert (pattern, tag);									-- add the 'expected result' <tag>
		table.insert (tpats, pattern);										-- accumulate in list of patterns
	end

	local function comp (a, b)													-- local function used by table.sort()
		return a[2] < b[2];														-- ascending sort by code (because test limits are by code)
	end
	
	table.sort (tpats, comp);													-- make the list pretty
	return tpats;																-- and done
end

local function dep_test_patterns_get()
	local tpats = {}															-- collect test patterns here
	for tag, names in pairs (lang_data.lang_name_table.lang_dep) do
		local pattern = {};														-- here we assemble the test pattern for <name>
		if lang_data.override[tag] then
			table.insert (pattern, lang_data.override[tag][1]);					-- add first <name> only to the pattern
			table.insert (pattern, tag);									-- add the 'expected result' <tag>
		elseif lang_data.lang_name_table.lang_es_dep[tag] then
			table.insert (pattern, lang_data.lang_name_table.lang_es_dep[tag][1]);					-- add first <name> only to the pattern
			table.insert (pattern, tag);									-- add the 'expected result' <tag>
		else
			table.insert (pattern, names[1]);								-- add first <name> only to the pattern
			table.insert (pattern, tag);									-- add the 'expected result' <tag>
		end
		table.insert (tpats, pattern);										-- accumulate in list of patterns
	end

	local function comp (a, b)													-- local function used by table.sort()
		return a[2] < b[2];														-- ascending sort by code (because test limits are by code)
	end
	
	table.sort (tpats, comp);													-- make the list pretty
	return tpats;																-- and done
end




--[[--------------------------< T E S T _ T A G _ F R O M _ N A M E >------------------------------------------
]]

function p:test_tag_from_name_iso_639_deprecated()
	local test_patterns = dep_test_patterns_get()
	self:preprocess_equals_preprocess_many('{{#invoke:Lang/zona de pruebas|tag_from_name|', '}}', '', '', test_patterns, {nowiki=1})
end

function p:test_tag_from_name_iso_639_override()
	local test_patterns = override_test_patterns_get()
	self:preprocess_equals_preprocess_many('{{#invoke:Lang/zona de pruebas|tag_from_name|', '}}', '', '', test_patterns, {nowiki=1})
end

return p