Módulo:Lang/tests/ISO 639-3-2 name from tag

Este módulo no tiene página de documentación[crear]
local p = require('Módulo:UnitTests')

--[[--------------------------< 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()
	local name_from_tag = require('Módulo:Lang')._name_from_tag				-- use Module:Lang to create the 'expected results'
	local complete = {}
	local iana_data = mw.loadData('Módulo:Lang/data/iana languages').active	    -- use the iana data
	local iana_data_es = mw.loadData('Módulo:Lang/data/iana languages translation').active	    -- use the iana data
	for k,v in pairs(iana_data) do complete[k] = v end
	for k,v in pairs(iana_data_es) do complete[k] = v end
	local code_mask = "^[j-p]%l%l"												-- used to limit number of tests
	local tpats = {}															-- collect test patterns here
	for code in pairs(complete) do												-- list of names not needed here
		local pattern = {}														-- here we assemble the test pattern for <code>
		if code:find(code_mask) then											-- if code within limits (three-character codes)
			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
	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_3_2()
	local test_patterns = test_patterns_get()
	self:preprocess_equals_preprocess_many('{{#invoke:Lang/zona de pruebas|name_from_tag|', '}}', '', '', test_patterns, {nowiki=1})
end

return p