Module:sh-IPA/testcases

local tests = require("Module:UnitTests")

local to_IPA = require("Module:sh-IPA").to_IPA local decompose = mw.ustring.toNFD local ugsub = mw.ustring.gsub

local diacritic = "[" .. decompose("ȁàȃáāã"):gsub("a", "") .. "]"

local function make_entry_name(text) return ugsub(decompose(text), "([aeiourаеиоур])" .. diacritic, "%1") end

local function link(text, script) return ' ' .. text .. ' ' end

local function tag(text, script) return ' ' .. text .. ' ' end

local function show_link_and_respelling(entry, respelling, script) return link(entry, script) .. (respelling and " (" .. tag(respelling, script) .. ")" or "") end

local options = { display = function(text) return ' ' .. text .. ' '	end }

function tests:check(Cyrillic, Latin, IPA, Cyrillic_respelling, Latin_respelling) local IPA1, IPA2 = to_IPA(Cyrillic_respelling or Cyrillic), to_IPA(Latin_respelling or Latin) if IPA1 == IPA2 then self:equals(show_link_and_respelling(Cyrillic, Cyrillic_respelling, "Cyrl")				.. " " .. show_link_and_respelling(Latin, Latin_respelling, "Latn"),				IPA1, IPA, options) else self:equals(show_link_and_respelling(Cyrillic, Cyrillic_respelling, "Cyrl"),				IPA1, IPA, options) self:equals(show_link_and_respelling(Latin, Latin_respelling, "Latn"),				IPA2, IPA, options) end end

function tests:test local examples = { "Words chosen at random", { "аеробиоло̀гија", "aerobiològija", "/aerobiolǒɡija/" }, { "аба̀жӯр", "abàžūr", "/abǎʒuːr/" }, { "ђа̏вољӣ", "đȁvoljī", "/d͡ʑâʋoʎiː/" }, { "адсо̀рпцӣјскӣ", "adsòrpcījskī", "/adsǒrpt͡siːjskiː/" }, { "адвентѝстичкӣ", "adventìstičkī", "/adʋentǐstit͡ʃkiː/" }, { "о̀риз", "òriz", "/ǒriz/" }, { "а̏баџија", "ȁbadžija", "/âbad͡ʒija/" }, { "грје̏шка", "grjȅška", "/ɡrjêʃka/" }, { "сло̀вӣнскӣ", "slòvīnskī", "/slǒʋiːnskiː/" }, { "ју̏трошњӣ", "jȕtrošnjī", "/jûtroʃɲiː/" }, { "ћа̏ћа", "ćȁća", "/t͡ɕât͡ɕa/" }, { "Аборѝџиница", "Aborìdžinica", "/aborǐd͡ʒinit͡sa/" }, "False digraphs", { "наджи́вјети", "nadžívjeti", "/nadʒǐːʋjeti/", "над'жи́вјети", "nad'žívjeti", }, { "надја̀чати", "nadjàčati", "/nadjǎt͡ʃati/" }, "Syllabic sonorants", { "цр̑н", "cȓn", "/t͡sr̩̂ːn/" }, { "вр́ба", "vŕba", "/ʋř̩ːba/" }, { "р̀ђати", "r̀đati", "/ř̩d͡ʑati/" }, { "зар̀ђати", "zar̀đati", "/zař̩d͡ʑati/" }, { "брзѝна", "brzìna", "/br̩zǐna/" }, { "маса̀кр", "masàkr", "/masǎkr̩/" }, { "бицѝкл", "bicìkl", "/bit͡sǐkl̩/" }, { "кловн", "klovn", "/kloʋn̩/" }, --not sure of pitch accent { "жа̏нр", "žȁnr", "/ʒânr̩/" }, { "кре̏мљ", "krȅmlj", "/krêmʎ̩/" }, "Montenegrin letters", { "с́у̏тра", "śȕtra", "/ɕûtra/" }, "Torlakian", { "аба́ити", "abáiti", "/aˈbaiti/" }, { "понаѕр́нѕити", "ponadzŕndziti", "/ponaˈdzr̩ndziti/" }, { "кьт", "kăt", "/kət/" }, }	self:iterate(examples, "check") end

return tests