Module:IPA/testcases
Jump to navigation
Jump to search
Documentation for this module may be created at Module:IPA/testcases/documentation
local tests = require('Module:UnitTests')
local m_IPA = require('Module:IPA/X-SAMPA')
local testcases = {
-- [ XSAMPA ] = IPA ;
-- en: [[dictionary]]
['/"dIkS@n(@)r\\i/' ] = '/ˈdɪkʃən(ə)ɹi/' ;
['/"dIkS@nEr\\i/' ] = '/ˈdɪkʃənɛɹi/' ;
-- en: [[battleship]]
['["b{tl=SIp]' ] = '[ˈbætl̩ʃɪp]' ;
-- en: [[murder]]
['["m3`d@`]' ] = '[ˈmɝdɚ]' ;
-- en: [[dazzle]]
['/"d{zl=/' ] = '/ˈdæzl̩/' ;
--[=[ en: [[change]]
['/ʧeɪnʤ/' ] = '/t͡ʃeInd͡ʒ/' ; ]=]
-- en: [[change]]
['/t__SeInd__Z/' ] = '/t͡ʃeɪnd͡ʒ/' ;
-- uk: [[Україна]]
['/ukrA"jInA/' ] = '/ukrɑˈjɪnɑ/' ;
-- fa: [[نوروز]]
['[n{u_^"4o:z]' ] = '[næu̯ˈɾoːz]' ;
['[nou_^"4u:z]' ] = '[nou̯ˈɾuːz]' ;
['[no:"4u:z]' ] = '[noːˈɾuːz]' ;
['[n{u_^"48:z]' ] = '[næu̯ˈɾɵːz]' ;
-- cmn: [[新年]]
['[s\\In__T__TniEn__M__T]' ] = '[ɕɪn˥˥niɛn˧˥]' ;
-- yue: [[唔]]
['[N=__B__L]' ] = '[ŋ̍˩˨]' ;
-- ga: [[báid]], [[bád]]
['[b_GA:d_j]' ] = '[bˠɑːdʲ]' ;
['[b_GA:d_d_G]' ] = '[bˠɑːd̪ˠ]' ;
-- nl: [[crème]]
['/krE(:)m/' ] = '/krɛ(ː)m/' ;
}
local function format_ipa(ipa)
return '<span class="IPA" lang="">' .. ipa .. '</span>'
end
local function format_xsampa(xsampa)
return '<code>' .. xsampa .. '</code>'
end
function tests:test_convert_xsampa_to_ipa()
for xsampa, ipa in pairs(testcases) do
self:equals(
format_xsampa(xsampa),
m_IPA.XSAMPA_to_IPA(xsampa),
ipa,
{ display = format_ipa }
)
end
end
function tests:test_convert_ipa_to_xsampa()
for xsampa, ipa in pairs(testcases) do
self:equals(
format_ipa(ipa),
format_xsampa(m_IPA.IPA_to_XSAMPA(ipa)),
format_xsampa(xsampa),
{ display = format_ipa }
)
end
end
function tests:test_roundtrip_ipa()
for xsampa, ipa in pairs(testcases) do
self:equals(
format_ipa(ipa),
m_IPA.XSAMPA_to_IPA(m_IPA.IPA_to_XSAMPA(ipa)),
ipa,
{ display = format_ipa }
)
end
end
function tests:test_roundtrip_xsampa()
for xsampa, ipa in pairs(testcases) do
self:equals(
format_xsampa(xsampa),
m_IPA.IPA_to_XSAMPA(m_IPA.XSAMPA_to_IPA(xsampa)),
xsampa,
{ display = format_xsampa }
)
end
end
return tests