မေႃႇၵျူး:km-pron/testcases
Documentation for this module may be created at မေႃႇၵျူး:km-pron/testcases/doc
local tests = require('Module:UnitTests')
local km_pron = require('Module:km-pron')
local test_data = require('Module:km-pron/testcases/data')
local function tag_IPA(IPA) return '<span class="IPA">' .. IPA .. '</span>' end
local function tag_khmer(Khmer) return '<span class="Khmr" lang="km">' .. Khmer .. '</span>' end
local function link(khmer, respelling)
return tag_khmer("[[" .. khmer .. "#Khmer|" .. khmer .. "]]") ..
(respelling and " <small>(respelling: " .. tag_khmer(respelling) .. ")</small>" or "")
end
function tests:do_test_syllabify(khmer, syllabified, respelling)
self:equals(link(khmer, respelling), tag_khmer(km_pron.syllabify(respelling or khmer)), tag_khmer(syllabified))
end
function tests:do_test_ipa(khmer, pronunciation, respelling)
self:equals(link(khmer, respelling), tag_IPA(km_pron.convert(respelling or khmer, "ipa")), tag_IPA(pronunciation))
end
function tests:do_test_transcript(khmer, transcription, respelling)
self:equals(link(khmer, respelling), tag_IPA(km_pron.convert(respelling or khmer, "tc")), tag_IPA(transcription))
end
function tests:test_syllabify()
for _, data in pairs(test_data) do
self:do_test_syllabify(data.word, data.syllabified, data.respelling)
end
end
function tests:test_ipa()
for _, data in pairs(test_data) do
self:do_test_ipa(data.word, data.ipa, data.respelling)
end
end
function tests:test_transcript()
for _, data in pairs(test_data) do
self:do_test_transcript(data.word, data.transcription, data.respelling)
end
end
return tests