Yiɣi chaŋ yɛligu maŋamaŋa puuni

Module:Mw lang/testcases

Diyila Dagbani Wikipedia

Documentation for this module may be created at Module:Mw lang/testcases/doc

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