-- Le but est d'abord d'assurer le même comportement que eo-rég. On verra pour la suite plus tard.
local tests = require('Module:UnitTests')
local eo = require('Module:eo-flexions')
function tests:test_get_ns_on_nouns()
local args = {
['pomo'] = {},
['pomon'] = {},
['pomoj'] = {},
['pomojn'] = {}
}
local testcases = {
['pomo'] = 'pomo',
['pomoj'] = 'pomo',
['pomon'] = 'pomo',
['pomojn'] = 'pomo'
}
for mot, args_ in pairs(args) do
ns = testcases[mot]
result = eo.get_ns(mot)
self:equals(mot, result, ns)
end
end
function tests:test_get_ns_on_adjectives()
local args = {
['verda'] = {},
['verdan'] = {},
['verdaj'] = {},
['verdajn'] = {},
}
local testcases = {
['verda'] = 'verda',
['verdaj'] = 'verda',
['verdan'] = 'verda',
['verdajn'] = 'verda'
}
for mot, args_ in pairs(args) do
ns = testcases[mot]
result = eo.get_ns(mot)
self:equals(mot, result, ns)
end
end
function tests:test_get_empty_prons_forms()
local args = {
[''] = {},
}
local testcases = {
[''] = {
['sing_nom'] = '',
['plur_nom'] = '',
['sing_acc'] = '',
['plur_acc'] = ''
}
}
local forms = {}
for mot, args_ in pairs(args) do
flexions = testcases[mot]
forms = eo.get_forms(mot)
for key, value in pairs(flexions) do
self:equals(mot, forms[key], value)
end
end
end
function tests:test_get_one_word_forms()
local args = {
['pomo'] = {},
['pomojn'] = {},
['verda'] = {},
['verdajn'] = {}
}
local testcases = {
['pomo'] = {
['sing_nom'] = 'pomo',
['plur_nom'] = 'pomoj',
['sing_acc'] = 'pomon',
['plur_acc'] = 'pomojn'
},
['pomojn'] = {
['sing_nom'] = 'pomo',
['plur_nom'] = 'pomoj',
['sing_acc'] = 'pomon',
['plur_acc'] = 'pomojn'
},
['verda'] = {
['sing_nom'] = 'verda',
['plur_nom'] = 'verdaj',
['sing_acc'] = 'verdan',
['plur_acc'] = 'verdajn'
},
['verdajn'] = {
['sing_nom'] = 'verda',
['plur_nom'] = 'verdaj',
['sing_acc'] = 'verdan',
['plur_acc'] = 'verdajn'
}
}
local forms = {}
for mot, args_ in pairs(args) do
flexions = testcases[mot]
forms = eo.get_forms(mot, args_)
for key, value in pairs(flexions) do
self:equals(mot, forms[key], value)
end
end
end
function tests:test_get_locution_forms()
local args = {
['verda pomo'] = {},
['ĉi tiu'] = {
['dern'] = ''
}
}
local testcases = {
['verda pomo'] = {
['sing_nom'] = 'verda pomo',
['plur_nom'] = 'verdaj pomoj',
['sing_acc'] = 'verdan pomon',
['plur_acc'] = 'verdajn pomojn'
},
['ĉi tiu'] = {
['sing_nom'] = 'ĉi tiu',
['plur_nom'] = 'ĉi tiuj',
['sing_acc'] = 'ĉi tiun',
['plur_acc'] = 'ĉi tiujn'
}
}
local forms = {}
for mot, args_ in pairs(args) do
flexions = testcases[mot]
forms = eo.get_forms(mot, args_)
for key, value in pairs(flexions) do
self:equals(mot, forms[key], value)
end
end
end
function tests:test_custom_word_forms()
local args = {
['zzz'] = {
['name'] = 'pomo'
},
['zzz'] = {
['ns'] = 'pomo'
},
['pomo'] = {
[3] = 'verda pomon'
}
}
local testcases = {
['zzz'] = {
['sing_nom'] = 'pomo',
['plur_nom'] = 'pomoj',
['sing_acc'] = 'pomon',
['plur_acc'] = 'pomojn'
},
['pomo'] = {
['sing_nom'] = 'pomo',
['plur_nom'] = 'pomoj',
['sing_acc'] = 'verda pomon',
['plur_acc'] = 'pomojn'
}
}
local forms = {}
for mot, args_ in pairs(args) do
flexions = testcases[mot]
forms = eo.get_forms(mot, args_)
for key, value in pairs(flexions) do
self:equals(mot, forms[key], value)
end
end
end
function tests:test_pronunciations()
local args = {
['pomo'] = {
[1] = 'po.mo'
},
['pomo'] = {
['pron'] = 'po.mo'
},
['pomo'] = {
['pron1'] = 'po.mo'
},
['verda'] = {
[1] = 'ˈver.da',
['pron4'] = 'ˈtest'
},
['gefianĉoj'] = {
['pron'] = 'ɡe.fi.ˈan.t͡ʃoj'
}
}
local testcases = {
['pomo'] = {
['sing_nom'] = 'po.mo',
['plur_nom'] = 'po.moj',
['sing_acc'] = 'po.mon',
['plur_acc'] = 'po.mojn'
},
['verda'] = {
['sing_nom'] = 'ˈver.da',
['plur_nom'] = 'ˈver.daj',
['sing_acc'] = 'ˈver.dan',
['plur_acc'] = 'ˈtest'
},
['gefianĉoj'] = {
['plur_nom'] = 'ɡe.fi.ˈan.t͡ʃoj',
['plur_acc'] = 'ɡe.fi.ˈan.t͡ʃojn'
}
}
local forms = {}
for mot, args_ in pairs(args) do
flexions = testcases[mot]
forms = eo.get_pronunciations(args_)
for key, value in pairs(flexions) do
self:equals(mot, forms[key], value)
end
end
end
function tests:test_locution_pronunciations()
local args = {
['verda pomo'] = {
[1] = 'ˈver.da po.mo'
},
['ĉi tiu'] = {
['pron'] = 't͡ʃi ˈti.u',
['dern'] = ''
}
}
local testcases = {
['verda pomo'] = {
['sing_nom'] = 'ˈver.da po.mo',
['plur_nom'] = 'ˈver.daj po.moj',
['sing_acc'] = 'ˈver.dan po.mon',
['plur_acc'] = 'ˈver.dajn po.mojn'
},
['ĉi tiu'] = {
['sing_nom'] = 't͡ʃi ˈti.u',
['plur_nom'] = 't͡ʃi ˈti.uj',
['sing_acc'] = 't͡ʃi ˈti.un',
['plur_acc'] = 't͡ʃi ˈti.ujn'
}
}
local forms = {}
for mot, args_ in pairs(args) do
flexions = testcases[mot]
forms = eo.get_pronunciations(args_)
for key, value in pairs(flexions) do
self:equals(mot, forms[key], value)
end
end
end
return tests