-- Unit tests for . Click talk page to run tests.local p = require('Module:UnitTests')local m_Language = require('Module:Wikt-lang')local name_from_tag = require('Module:Lang/sandbox')._name_from_tag
function p:test_1_link self:preprocess_equals_preprocess_many('', '', ,)end
local function test_patterns_get(main) local data = require('Module:Wikt-lang/data/sandbox') local language_codes =
if main then for code, values in pairs(data["languages"]) do table.insert(language_codes,) end
else for code, redirect_code in pairs(data["redirects"]) do local redirect_name if data["languages"][redirect_code] and data["languages"][redirect_code].name then redirect_name = data["languages"][redirect_code].name else redirect_name = name_from_tag if not redirect_name or redirect_name:find("error") then redirect_name = mw.language.fetchLanguageName(redirect_code, 'en') end end table.insert(language_codes,) end end
local function comp(a, b) return a[1] < b[1] end
table.sort(language_codes, comp) return language_codesend
function p:test_2_link local wiktionary_test_patterns = test_patterns_get(true) local name_from_tag = require('Module:Lang')._name_from_tag local full_test_patterns =
for i = 1, #wiktionary_test_patterns do local code = wiktionary_test_patterns[i][1] table.insert(full_test_patterns,) end self:preprocess_equals_preprocess_many('', '', full_test_patterns,)end
function p:test_3_link_redirects local wiktionary_test_patterns = test_patterns_get(false) local name_from_tag = require('Module:Lang')._name_from_tag local full_test_patterns =
for i = 1, #wiktionary_test_patterns do local code = wiktionary_test_patterns[i][1] table.insert(full_test_patterns,) end self:preprocess_equals_preprocess_many('', '', full_test_patterns,)end
function p:test_4_compare_language_names local wiktionary_test_patterns = test_patterns_get(true) local name_from_tag = require('Module:Lang')._name_from_tag local full_test_patterns =
for i = 1, #wiktionary_test_patterns do local code = wiktionary_test_patterns[i][1] local en_wiki_name = name_from_tag local wiktionary_name = wiktionary_test_patterns[i][2] if wiktionary_name then table.insert(full_test_patterns,) end end
self:preprocess_equals_many(, , full_test_patterns,)end
function p:test_5_compare_language_names_redirects local wiktionary_test_patterns = test_patterns_get(false) local name_from_tag = require('Module:Lang')._name_from_tag local full_test_patterns =
for i = 1, #wiktionary_test_patterns do local code = wiktionary_test_patterns[i][1] local wiktionary_name = wiktionary_test_patterns[i][2] local redirect_code = wiktionary_test_patterns[i][3]
local en_wiki_name = name_from_tag local en_wiki_redirect_name = name_from_tag(
)
table.insert(full_test_patterns,) end
self:preprocess_equals_many(, , full_test_patterns,)end
return p