From Wikipedia, the free encyclopedia

local p = require('Module:UnitTests')



--[[--------------------------< 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:

	{"<code>", "<cat name according to Module:Lang>"}



]]



local function test_patterns_get()

	local cat_from_tag = require('Module:Lang')._category_from_tag				-- use Module:Lang to create the 'expected results'

	local iana_data = mw.loadData('Module:Language/data/iana languages').active -- use the iana data

	local code_mask = '^[i-n]%l%l'												-- used to limit number of tests

	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>

		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, cat_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 a1 < b1														-- ascending sort by code

	end

	

	table.sort(tpats, comp)													-- make the list pretty

	return tpats																-- and done

end



--[[--------------------------< T E S T _ C A T E G O R Y _ F R O M _ T A G >----------------------------------

]]



function p:test_category_from_tag_iso_639_3_2()

	local test_patterns = test_patterns_get()

	self:preprocess_equals_preprocess_many('{{#invoke:Lang/sandbox|category_from_tag|', '}}', '', '', test_patterns, {nowiki=1})

end;



return p
From Wikipedia, the free encyclopedia

local p = require('Module:UnitTests')



--[[--------------------------< 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:

	{"<code>", "<cat name according to Module:Lang>"}



]]



local function test_patterns_get()

	local cat_from_tag = require('Module:Lang')._category_from_tag				-- use Module:Lang to create the 'expected results'

	local iana_data = mw.loadData('Module:Language/data/iana languages').active -- use the iana data

	local code_mask = '^[i-n]%l%l'												-- used to limit number of tests

	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>

		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, cat_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 a1 < b1														-- ascending sort by code

	end

	

	table.sort(tpats, comp)													-- make the list pretty

	return tpats																-- and done

end



--[[--------------------------< T E S T _ C A T E G O R Y _ F R O M _ T A G >----------------------------------

]]



function p:test_category_from_tag_iso_639_3_2()

	local test_patterns = test_patterns_get()

	self:preprocess_equals_preprocess_many('{{#invoke:Lang/sandbox|category_from_tag|', '}}', '', '', test_patterns, {nowiki=1})

end;



return p

Videos

Youtube | Vimeo | Bing

Websites

Google | Yahoo | Bing

Encyclopedia

Google | Yahoo | Bing

Facebook