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

De Wikipedia, la enciclopedia libre
Este módulo no tiene página de documentación[crear]
local p = require('Módulo:UnitTests')
local data = mw.loadData('Módulo:Lang/data')

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

Crea una lista con los patrones de pruebas en la que cada entrada es a su vez otra lista con dos elementos:
	{"<code>", "<nombre del idioma según Módulo:Lang>"}

]]

local function test_patterns_get(iana_data)
	local name_from_tag = require('Módulo:Lang')._name_from_tag				-- use Module:Lang to create the 'expected results'
	local tpats = {}															-- collect test patterns here
	for code in pairs(iana_data) do												-- list of names not needed here
		local pattern = {}														-- here we assemble the test pattern for <code>
		table.insert(pattern, code)												-- add it to the pattern
		table.insert(pattern, name_from_tag ({code}))							-- call module:lang and add the 'expected results' for code to pattern
		table.insert(tpats, pattern)											-- accumulate in list of patterns
	end

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


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

function p:test_name_from_tag_iso_639_deprecated()
	local test_patterns = test_patterns_get(data.lang_name_table.lang_dep)
	self:preprocess_equals_preprocess_many('{{#invoke:Lang/zona de pruebas|name_from_tag|', '}}', '', '', test_patterns, {nowiki=1})
end

function p:test_name_from_tag_iso_639_override()
	local test_patterns = test_patterns_get(data.override)
	self:preprocess_equals_preprocess_many('{{#invoke:Lang/zona de pruebas|name_from_tag|', '}}', '', '', test_patterns, {nowiki=1})
end

return p