Module:Languages/testcases
Jump to navigation
Jump to search
This is the test cases page for the module Module:Languages. Results of the test cases. |
local p = require("Module:UnitTests")
local languages = require("Module:Languages")
function p:test_languageCodes()
self:equals("Main Page", languages.pseudoNamespaceFromTitle(mw.title.new("Main Page")), nil)
end
function p:test_pseudoNamespaceFromTitle()
self:equals("Main Page", languages.pseudoNamespaceFromTitle(mw.title.new("Main Page")), nil)
self:equals("DE:Main Page", languages.pseudoNamespaceFromTitle(mw.title.new("DE:Main Page")), nil)
self:equals("El:Main Page", languages.pseudoNamespaceFromTitle(mw.title.new("El:Main Page")), "El")
self:equals("Gsw:Main Page", languages.pseudoNamespaceFromTitle(mw.title.new("Gsw:Main Page")), "Gsw")
self:equals("Pt-br:Main Page", languages.pseudoNamespaceFromTitle(mw.title.new("Pt-br:Main Page")), "Pt-br")
self:equals("Zh-hant:Main Page", languages.pseudoNamespaceFromTitle(mw.title.new("Zh-hant:Main Page")), "Zh-hant")
self:equals("Talk:Main Page", languages.pseudoNamespaceFromTitle(mw.title.new("Talk:Main Page")), nil)
self:equals("DE talk:Main Page", languages.pseudoNamespaceFromTitle(mw.title.new("DE talk:Main Page")), nil)
self:equals("Talk:El:Main Page", languages.pseudoNamespaceFromTitle(mw.title.new("Talk:El:Main Page")), "El")
self:equals("Key:access", languages.pseudoNamespaceFromTitle(mw.title.new("Key:access")), nil)
self:equals("DE:Key:access", languages.pseudoNamespaceFromTitle(mw.title.new("DE:Key:access")), nil)
self:equals("El:Key:access", languages.pseudoNamespaceFromTitle(mw.title.new("El:Key:access")), "El")
self:equals("Talk:Key:access", languages.pseudoNamespaceFromTitle(mw.title.new("Talk:Key:access")), nil)
self:equals("DE talk:Key:access", languages.pseudoNamespaceFromTitle(mw.title.new("DE talk:Key:access")), nil)
self:equals("Talk:El:Key:access", languages.pseudoNamespaceFromTitle(mw.title.new("Talk:El:Key:access")), "El")
self:equals("POI:White Castle", languages.pseudoNamespaceFromTitle(mw.title.new("POI:White Castle")), nil)
self:equals("DE:POI:White Castle", languages.pseudoNamespaceFromTitle(mw.title.new("DE:POI:White Castle")), nil)
self:equals("El:POI:White Castle", languages.pseudoNamespaceFromTitle(mw.title.new("El:POI:White Castle")), "El")
self:equals("Talk:POI:White Castle", languages.pseudoNamespaceFromTitle(mw.title.new("Talk:POI:White Castle")), nil)
self:equals("DE talk:POI:White Castle", languages.pseudoNamespaceFromTitle(mw.title.new("DE talk:POI:White Castle")), nil)
self:equals("Talk:El:POI:White Castle", languages.pseudoNamespaceFromTitle(mw.title.new("Talk:El:POI:White Castle")), "El")
self:equals("Template:Calendar", languages.pseudoNamespaceFromTitle(mw.title.new("Template:Calendar")), nil)
self:equals("Template:DE:Calendar", languages.pseudoNamespaceFromTitle(mw.title.new("Template:DE:Calendar")), "DE")
self:equals("Template:De:Calendar", languages.pseudoNamespaceFromTitle(mw.title.new("Template:De:Calendar")), "De")
self:equals("Template:El:Calendar", languages.pseudoNamespaceFromTitle(mw.title.new("Template:El:Calendar")), "El")
self:equals("Template talk:Calendar", languages.pseudoNamespaceFromTitle(mw.title.new("Template talk:Calendar")), nil)
self:equals("Template talk:DE:Calendar", languages.pseudoNamespaceFromTitle(mw.title.new("Template talk:DE:Calendar")), "DE")
self:equals("Template talk:De:Calendar", languages.pseudoNamespaceFromTitle(mw.title.new("Template talk:De:Calendar")), "De")
self:equals("Template talk:El:Calendar", languages.pseudoNamespaceFromTitle(mw.title.new("Template talk:El:Calendar")), "El")
end
function p:test_languageFromTitle()
self:equals("Main Page", languages.languageFromTitle(mw.title.new("Main Page")), "en")
self:equals("DE:Main Page", languages.languageFromTitle(mw.title.new("DE:Main Page")), "de")
self:equals("El:Main Page", languages.languageFromTitle(mw.title.new("El:Main Page")), "el")
self:equals("Gsw:Main Page", languages.languageFromTitle(mw.title.new("Gsw:Main Page")), "gsw")
self:equals("Pt-br:Main Page", languages.languageFromTitle(mw.title.new("Pt-br:Main Page")), "pt-br")
self:equals("Zh-hant:Main Page", languages.languageFromTitle(mw.title.new("Zh-hant:Main Page")), "zh-hant")
self:equals("Talk:Main Page", languages.languageFromTitle(mw.title.new("Talk:Main Page")), "en")
self:equals("DE talk:Main Page", languages.languageFromTitle(mw.title.new("DE talk:Main Page")), "de")
self:equals("Talk:El:Main Page", languages.languageFromTitle(mw.title.new("Talk:El:Main Page")), "el")
self:equals("Key:access", languages.languageFromTitle(mw.title.new("Key:access")), "en")
self:equals("DE:Key:access", languages.languageFromTitle(mw.title.new("DE:Key:access")), "de")
self:equals("El:Key:access", languages.languageFromTitle(mw.title.new("El:Key:access")), "el")
self:equals("Talk:Key:access", languages.languageFromTitle(mw.title.new("Talk:Key:access")), "en")
self:equals("DE talk:Key:access", languages.languageFromTitle(mw.title.new("DE talk:Key:access")), "de")
self:equals("Talk:El:Key:access", languages.languageFromTitle(mw.title.new("Talk:El:Key:access")), "el")
self:equals("Template:Calendar", languages.languageFromTitle(mw.title.new("Template:Calendar")), "en")
self:equals("Template:DE:Calendar", languages.languageFromTitle(mw.title.new("Template:DE:Calendar")), "de")
self:equals("Template:De:Calendar", languages.languageFromTitle(mw.title.new("Template:De:Calendar")), "de")
self:equals("Template:El:Calendar", languages.languageFromTitle(mw.title.new("Template:El:Calendar")), "el")
self:equals("Template talk:Calendar", languages.languageFromTitle(mw.title.new("Template talk:Calendar")), "en")
self:equals("Template talk:DE:Calendar", languages.languageFromTitle(mw.title.new("Template talk:DE:Calendar")), "de")
self:equals("Template talk:De:Calendar", languages.languageFromTitle(mw.title.new("Template talk:De:Calendar")), "de")
self:equals("Template talk:El:Calendar", languages.languageFromTitle(mw.title.new("Template talk:El:Calendar")), "el")
end
function p:test_sourceTitleFromTitle()
self:equals("Main Page", languages.sourceTitleFromTitle(mw.title.new("Main Page")).fullText, "Main Page")
self:equals("DE:Main Page", languages.sourceTitleFromTitle(mw.title.new("DE:Main Page")).fullText, "Main Page")
self:equals("El:Main Page", languages.sourceTitleFromTitle(mw.title.new("El:Main Page")).fullText, "Main Page")
self:equals("Talk:Main Page", languages.sourceTitleFromTitle(mw.title.new("Talk:Main Page")).fullText, "Talk:Main Page")
self:equals("DE talk:Main Page", languages.sourceTitleFromTitle(mw.title.new("DE talk:Main Page")).fullText, "Talk:Main Page")
self:equals("Talk:El:Main Page", languages.sourceTitleFromTitle(mw.title.new("Talk:El:Main Page")).fullText, "Talk:Main Page")
self:equals("Key:access", languages.sourceTitleFromTitle(mw.title.new("Key:access")).fullText, "Key:access")
self:equals("DE:Key:access", languages.sourceTitleFromTitle(mw.title.new("DE:Key:access")).fullText, "Key:access")
self:equals("El:Key:access", languages.sourceTitleFromTitle(mw.title.new("El:Key:access")).fullText, "Key:access")
self:equals("Talk:Key:access", languages.sourceTitleFromTitle(mw.title.new("Talk:Key:access")).fullText, "Talk:Key:access")
self:equals("DE talk:Key:access", languages.sourceTitleFromTitle(mw.title.new("DE talk:Key:access")).fullText, "Talk:Key:access")
self:equals("Talk:El:Key:access", languages.sourceTitleFromTitle(mw.title.new("Talk:El:Key:access")).fullText, "Talk:Key:access")
self:equals("Template:Calendar", languages.sourceTitleFromTitle(mw.title.new("Template:Calendar")).fullText, "Template:Calendar")
self:equals("Template:DE:Calendar", languages.sourceTitleFromTitle(mw.title.new("Template:DE:Calendar")).fullText, "Template:Calendar")
self:equals("Template:De:Calendar", languages.sourceTitleFromTitle(mw.title.new("Template:De:Calendar")).fullText, "Template:Calendar")
self:equals("Template:El:Calendar", languages.sourceTitleFromTitle(mw.title.new("Template:El:Calendar")).fullText, "Template:Calendar")
self:equals("Template talk:Calendar", languages.sourceTitleFromTitle(mw.title.new("Template talk:Calendar")).fullText, "Template talk:Calendar")
self:equals("Template talk:DE:Calendar", languages.sourceTitleFromTitle(mw.title.new("Template talk:DE:Calendar")).fullText, "Template talk:Calendar")
self:equals("Template talk:De:Calendar", languages.sourceTitleFromTitle(mw.title.new("Template talk:De:Calendar")).fullText, "Template talk:Calendar")
self:equals("Template:El:Calendar", languages.sourceTitleFromTitle(mw.title.new("Template:El:Calendar")).fullText, "Template:Calendar")
end
function p:test_translationPageName()
local enMainPage = mw.title.new("Main Page")
self:equals("Main Page in English", languages.translationPageName("en", enMainPage), "Main Page")
self:equals("Main Page in German", languages.translationPageName("de", enMainPage), "DE:Main Page")
self:equals("Main Page in Greek", languages.translationPageName("el", enMainPage), "El:Main Page")
local enMainPageTalk = mw.title.new("Talk:Main Page")
self:equals("Talk:Main Page in English", languages.translationPageName("en", enMainPageTalk), "Talk:Main Page")
self:equals("Talk:Main Page in German", languages.translationPageName("de", enMainPageTalk), "DE talk:Main Page")
self:equals("Talk:Main Page in Greek", languages.translationPageName("el", enMainPageTalk), "Talk:El:Main Page")
local enKeyAccess = mw.title.new("Key:access")
self:equals("Key:access in English", languages.translationPageName("en", enKeyAccess), "Key:access")
self:equals("Key:access in German", languages.translationPageName("de", enKeyAccess), "DE:Key:access")
self:equals("Key:access in Greek", languages.translationPageName("el", enKeyAccess), "El:Key:access")
local enKeyAccessTalk = mw.title.new("Talk:Key:access")
self:equals("Talk:Key:access in English", languages.translationPageName("en", enKeyAccessTalk), "Talk:Key:access")
self:equals("Talk:Key:access in German", languages.translationPageName("de", enKeyAccessTalk), "DE talk:Key:access")
self:equals("Talk:Key:access in Greek", languages.translationPageName("el", enKeyAccessTalk), "Talk:El:Key:access")
local enTemplateCalendar = mw.title.new("Template:Calendar")
self:equals("Template:Calendar in English", languages.translationPageName("en", enTemplateCalendar), "Template:Calendar")
self:equals("Template:Calendar in English (simulating language namespaces)", languages.translationPageName("en", enTemplateCalendar, true), "Template:Calendar")
self:equals("Template:Calendar in German", languages.translationPageName("de", enTemplateCalendar), "Template:De:Calendar")
self:equals("Template:Calendar in German (simulating language namespaces)", languages.translationPageName("de", enTemplateCalendar, true), "Template:DE:Calendar")
self:equals("Template:Calendar in Greek", languages.translationPageName("el", enTemplateCalendar), "Template:El:Calendar")
self:equals("Template:Calendar in Greek (simulating language namespaces)", languages.translationPageName("el", enTemplateCalendar, true), "Template:El:Calendar")
local enTemplateCalendarTalk = mw.title.new("Template talk:Calendar")
self:equals("Template talk:Calendar in English", languages.translationPageName("en", enTemplateCalendarTalk), "Template_talk:Calendar")
self:equals("Template talk:Calendar in English (simulating language namespaces)", languages.translationPageName("en", enTemplateCalendarTalk, true), "Template_talk:Calendar")
self:equals("Template talk:Calendar in German", languages.translationPageName("de", enTemplateCalendarTalk), "Template_talk:De:Calendar")
self:equals("Template talk:Calendar in German (simulating language namespaces)", languages.translationPageName("de", enTemplateCalendarTalk, true), "Template_talk:DE:Calendar")
self:equals("Template talk:Calendar in Greek", languages.translationPageName("el", enTemplateCalendarTalk), "Template_talk:El:Calendar")
self:equals("Template talk:Calendar in Greek (simulating language namespaces)", languages.translationPageName("el", enTemplateCalendarTalk, true), "Template_talk:El:Calendar")
end
return p