Jump to content

Module:Mw lang/testcases

විකිපීඩියා වෙතින්
-- Unit tests for [[Module:Mw lang]]. Click talk page to run tests.
local p = require('Module:UnitTests')

local function compare_by_keys(a, b)
	return a[1] < b[1]
end

local function get_all_languages()
	return mw.language.fetchLanguageNames("en", "all")
end

function p:test_code_from_name()
	language_tables = {}
	for language_code, language_name in pairs(get_all_languages()) do
		local entry = {}
		table.insert(entry, language_name)
		table.insert(entry, language_code)
		table.insert(language_tables, entry)
	end

	table.sort(language_tables, compare_by_keys)

    self:preprocess_equals_preprocess_many(
    	'{{#invoke:Mw lang|code_from_name|', '}}', '', '',
		language_tables, 
		{nowiki=false}
	)
end

function p:test_name_from_code()
	language_tables = {}
	for language_code, language_name in pairs(get_all_languages()) do
		local entry = {}
		table.insert(entry, language_code)
		table.insert(entry, language_name)
		table.insert(language_tables, entry)
	end

	table.sort(language_tables, compare_by_keys)

    self:preprocess_equals_preprocess_many(
    	'{{#invoke:Mw lang|name_from_code|', '}}', '', '',
		language_tables, 
		{nowiki=false}
	)
end

return p
"https://si.wikipedia.org/w/index.php?title=Module:Mw_lang/testcases&oldid=583777" වෙතින් සම්ප්‍රවේශනය කෙරිණි