local t = require('Modul:UnitTests')
local mut = require('Modul:lang')
function t:test_01_has_language()
self:equals('mut.hasLanguage("sv")', mut.hasLanguage("sv"), true)
self:equals('mut.hasLanguage("xx")', mut.hasLanguage("xx"), false)
self:equals('mut.hasLanguage("xyz")', mut.hasLanguage("xyz"), false)
end
function t:test_02_get_code_reverse_query()
self:equals('mut.getCode("sv")', mut.getCode("sv"), "xx") -- språkkod tillåts ej här
self:equals('mut.getCode("sV")', mut.getCode("sV"), "xx") -- språkkod tillåts ej här
self:equals('mut.getCode("svenska")', mut.getCode("svenska"), "sv")
self:equals('mut.getCode("Svenska")', mut.getCode("Svenska"), "sv")
self:equals('mut.getCode("Älvdalska")', mut.getCode("Älvdalska"), "ovd")
self:equals('mut.getCode("ESPERANTO")', mut.getCode("ESPERANTO"), "eo")
self:equals('mut.getCode("norska")', mut.getCode("norska"), "xx") -- koden "h-nor" är reserverad för etymologi
self:equals('mut.getCode("norska","alsoetym")', mut.getCode("norska","alsoetym"), "h-nor")
self:equals('mut.getCode("samiska","onlyetym")', mut.getCode("samiska","onlyetym"), "h-smi")
self:equals('mut.getCode("engelska","onlyetym")', mut.getCode("engelska","onlyetym"), "xx")
end
function t:test_03_get_language()
self:equals('mut.getLanguage("sv")', mut.getLanguage("sv"), "svenska")
self:equals('mut.getLanguage("sV")', mut.getLanguage("sV"), "okänt språk")
self:equals('mut.getLanguage("svenska")', mut.getLanguage("svenska"), "okänt språk")
self:equals('mut.getLanguage("Svenska")', mut.getLanguage("Svenska"), "okänt språk")
self:equals('mut.getLanguage("ovd")', mut.getLanguage("ovd"), "älvdalska")
self:equals('mut.getLanguageUCFirst("ovd")', mut.getLanguageUCFirst("ovd"), "Älvdalska")
self:equals('mut.getLanguage("nn")', mut.getLanguage("nn"), "nynorska")
self:equals('mut.getLanguage("h-nor")', mut.getLanguage("h-nor"), "okänt språk") -- koden "h-nor" är reserverad för etymologi
self:equals('mut.getLanguage("h-nor","alsoetym")', mut.getLanguage("h-nor","alsoetym"), "norska")
end
function t:test_04_get_script()
--self:equals('mut.getScriptCode("ar")', mut.getScriptCode("ar"), "arab") --inaktiverar tills denna funktion är redo att tas i bruk
--self:equals('mut.getScriptCode("xx")', mut.getScriptCode("xx"), "")
--self:equals('mut.getScriptCode("notfound")', mut.getScriptCode("notfound"), "")
end
function t:test_05_get_sort_rules()
self:equals_deep('mut.getSortRules("sv")', mut.getSortRules("sv"), {"å>z~", "ä>z¡", "ö>z°", "ü>y", "æ>z¡", "ø>z°"})
self:equals_deep('mut.getSortRules("xx")', mut.getSortRules("xx"), {})
self:equals_deep('mut.getSortRules("notfound")', mut.getSortRules("notfound"), {})
end
function t:test_06_is_obviously_invalid()
self:equals('mut.isObviouslyInvalid("sv")', mut.isObviouslyInvalid("sv"), false)
self:equals('mut.isObviouslyInvalid("Sv")', mut.isObviouslyInvalid("Sv"), true)
self:equals('mut.isObviouslyInvalid("jav")', mut.isObviouslyInvalid("jav"), false)
self:equals('mut.isObviouslyInvalid("ido")', mut.isObviouslyInvalid("ido"), true)
self:equals('mut.isObviouslyInvalid("xx")', mut.isObviouslyInvalid("xx"), true)
self:equals('mut.isObviouslyInvalid("--")', mut.isObviouslyInvalid("--"), false)
self:equals('mut.isObviouslyInvalid("a")', mut.isObviouslyInvalid("a"), true)
self:equals('mut.isObviouslyInvalid("zh-min-nan")', mut.isObviouslyInvalid("zh-min-nan"), false)
self:equals('mut.isObviouslyInvalid("zh-min+nan")', mut.isObviouslyInvalid("zh-min+nan"), true)
self:equals('mut.isObviouslyInvalid("zh-min-n-n")', mut.isObviouslyInvalid("zh-min-n-n"), true)
self:equals('mut.isObviouslyInvalid("zuh-min-nan")', mut.isObviouslyInvalid("zuh-min-nan"), true)
self:equals('mut.isObviouslyInvalid("h-smi")', mut.isObviouslyInvalid("h-smi"), false)
self:equals('mut.isObviouslyInvalid("lak")', mut.isObviouslyInvalid("lak"), false)
self:equals('mut.isObviouslyInvalid("spanska")', mut.isObviouslyInvalid("spanska"), true)
self:equals('mut.isObviouslyInvalid("indonesiska")', mut.isObviouslyInvalid("indonesiska"), true)
end
function t:test_07_get_entry_name()
self:equals('mut.getEntryName("ab", "а-бҳәа́")', mut.getEntryName("ab", "а-бҳәа́"), "а-бҳәа")
self:equals('mut.getEntryName("la", "abdērītānus")', mut.getEntryName("la", "abdērītānus"), "abderitanus")
self:equals('mut.getEntryName("lt", "abãtė")', mut.getEntryName("lt", "abãtė"), "abatė")
self:equals('mut.getEntryName("lt", "abažū̃ras")', mut.getEntryName("lt", "abažū̃ras"), "abažūras")
self:equals('mut.getEntryName("se", "boaš\'šu")', mut.getEntryName("se", "boaš'šu"), "boaššu")
self:equals('mut.getEntryName("ru", "автомотри́са")', mut.getEntryName("ru", "автомотри́са"), "автомотриса")
self:equals('mut.getEntryName("sr", "ја̏се̄н")', mut.getEntryName("sr", "ја̏се̄н"), "јасен")
self:equals('mut.getEntryName("zu", "dlâla")', mut.getEntryName("zu", "dlâla"), "dlala")
self:equals('mut.getEntryName("zu", "ī́sele")', mut.getEntryName("zu", "ī́sele"), "isele")
end
function t:test_08_get_entry_name_rtl()
self:equals('mut.getEntryName("ur", "آدرنیہ,")', mut.getEntryName("ur", "آدرنیہ"), "آدرنیہ")
self:equals('mut.getEntryName("ur", "آزمودہ,")', mut.getEntryName("ur", "آزمودہ"), "آزمودہ")
self:equals('mut.getEntryName("ur", "آشچریہ,")', mut.getEntryName("ur", "آشچریہ"), "آشچریہ")
self:equals('mut.getEntryName("he", "אֵין")', mut.getEntryName("he", "אֵין"), "אין")
self:equals('mut.getEntryName("he", "אֵינְסוֹף")', mut.getEntryName("he", "אֵינְסוֹף"), "אינסוף")
self:equals('mut.getEntryName("he", "יֵשׁ")', mut.getEntryName("he", "יֵשׁ"), "יש")
self:equals('mut.getEntryName("he", "עֶצֶם")', mut.getEntryName("he", "עֶצֶם"), "עצם")
self:equals('mut.getEntryName("he", "אִם וְרַק אִם")', mut.getEntryName("he", "אִם וְרַק אִם"), "אם ורק אם")
self:equals('mut.getEntryName("ar", "أَرِسْطُو")', mut.getEntryName("ar", "أَرِسْطُو"), "أرسطو")
self:equals('mut.getEntryName("ar", "إِبِيقُورِيّ")', mut.getEntryName("ar", "إِبِيقُورِيّ"), "إبيقوري")
self:equals('mut.getEntryName("ar", "اِخْتِيَار")', mut.getEntryName("ar", "اِخْتِيَار"), "اختيار")
self:equals('mut.getEntryName("ar", "تَعَدُّدُ الْقُدَماءِ")', mut.getEntryName("ar", "تَعَدُّدُ الْقُدَماءِ"), "تعدد القدماء")
self:equals('mut.getEntryName("ar", "تَنْوِير")', mut.getEntryName("ar", "تَنْوِير"), "تنوير")
end
return t