See also the script-specific tests for Pali declension in the Bengali, Brahmi, Burmese, Chakma, Devanagari, Khmer, Lao, Sinhalese, Tai Tham and Thai scripts. Their results are not included in the result summary given here.
16 of 18 tests failed. (refresh)
Text | Expected | Actual | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
{{pi-decl-noun|assa|a|g=m}} | Declension table of "assa" (masculine)
| Declension table of "assa" (masculine)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
{{pi-decl-noun|showtr=none|অঙ্গ|a|g=n}} | Declension table of "অঙ্গ" (neuter)
| Declension table of "অঙ্গ" (neuter)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
{{pi-decl-noun|showtr=none|චන්දිමා|ā|g=m}} | Declension table of "චන්දිමා" (masculine)
| Declension table of "චන්දිමා" (masculine)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
{{pi-decl-noun|showtr=none|अम्मा|ā|g=f}} | Declension table of "अम्मा" (feminine)
| Declension table of "अम्मा" (feminine)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
{{pi-decl-noun|showtr=none|ဣသိ|i|g=m}} | Declension table of "ဣသိ" (masculine)
| Declension table of "ဣသိ" (masculine)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
{{pi-decl-noun|showtr=none|ชาติ|i|g=f}} | Declension table of "ชาติ" (feminine)
| Declension table of "ชาติ" (feminine)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
{{pi-decl-noun|showtr=none|ᩋᨠ᩠ᨡᩥ|i|g=n}} | Declension table of "ᩋᨠ᩠ᨡᩥ" (neuter)
| Declension table of "ᩋᨠ᩠ᨡᩥ" (neuter)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
{{pi-decl-noun|showtr=none|មានី|ī|g=m}} | Declension table of "មានី" (masculine)
| Declension table of "មានី" (masculine)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
{{pi-decl-noun|nadī|ī|g=f}} | Declension table of "nadī" (feminine)
| Declension table of "nadī" (feminine)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
{{pi-decl-noun|showtr=none|𑀧𑀁𑀲𑀼|u|g=m}} | Declension table of "𑀧𑀁𑀲𑀼" (masculine)
| Declension table of "𑀧𑀁𑀲𑀼" (masculine)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
{{pi-decl-noun|showtr=none|जम्बु|u|g=f}} | Declension table of "जम्बु" (feminine)
| Declension table of "जम्बु" (feminine)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
{{pi-decl-noun|showtr=none|জত্তু|u|g=n}} | Declension table of "জত্তু" (neuter)
| Declension table of "জত্তু" (neuter)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
{{pi-decl-noun|sayambhū|ū|g=m}} | Declension table of "sayambhū" (masculine)
| Declension table of "sayambhū" (masculine)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
{{pi-decl-noun|vadhū|ū|g=f}} | Declension table of "vadhū" (feminine)
| Declension table of "vadhū" (feminine)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
{{pi-decl-noun|kattar|ar|g=m}} | Declension table of "kattar" (masculine)
| Declension table of "kattar" (masculine)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
{{pi-decl-noun|kathin|in|g=m}} | Declension table of "kathin" (masculine)
| Declension table of "kathin" (masculine)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
{{pi-decl-noun|kathin|in|g=m}} | Declension table of "kathin" (masculine)
| Declension table of "kathin" (masculine)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
{{pi-decl-noun|kathin|in|g=n}} | Declension table of "kathin" (neuter)
| Declension table of "kathin" (neuter)
|
local tests = require('Module:UnitTests')
local links = require("Module:links")
local lang = require("Module:languages").getByCode("pi")
local m_scripts = require("Module:scripts")
local m_decl_noun = require('Module:pi-decl/noun')
local gsub = mw.ustring.gsub
local match = mw.ustring.match
local sub = mw.ustring.sub
local u = mw.ustring.char
local genders = {
= "masculine", = "feminine", = "neuter",
}
local rows = {
"Nominative (first)", "Accusative (second)", "Instrumental (third)", "Dative (fourth)",
"Ablative (fifth)", "Genitive (sixth)", "Locative (seventh)", "Vocative (calling)",
}
local endings = {
= {
-- key Latn Thai Deva Beng Mymr Lana Laoo Khmr Sinh Brah
= { "ā", "า", "ा", "आ", "া", "আ", "ါ", "ာ", "ᩣ", "ᩤ", "າ", "ា", u(0x17A4), "ා", "ආ", "𑀸", "𑀆" },
= { "i", "ิ", "ि", "इ", "ি", "ই", "ိ", "ဣ", "ᩥ", "ᩍ", "ິ", "ិ", "ឥ", "ි", "ඉ", "𑀺", "𑀇" },
= { "ī", "ี", "ी", "ई", "ী", "ঈ", "ီ", "ဤ", "ᩦ", "ᩎ", "ີ", "ី", "ឦ", "ී", "ඊ", "𑀻", "𑀈" },
= { "u", "ุ", "ु", "उ", "ু", "উ", "ု", "ဥ", "ᩩ", "ᩏ", "ຸ", "ុ", "ឧ", "ු", "උ", "𑀼", "𑀉" },
= { "ū", "ู", "ू", "ऊ", "ূ", "ঊ", "ူ", "ဦ", "ᩪ", "ᩐ", "ູ", "ូ", "ឨ", "ឩ", "ූ", "ඌ", "𑀽", "𑀊" },
},
= {
-- key Latn Thai Deva Beng Mymr Lana Laoo Khmr Sinh Brah
= { "ar", "รฺ", "र्", "র্", "ရ်", "ᩁ᩺", "ᩁ᩼", "ຣ໌", "ຣ຺", "រ៑", "ර්", "𑀭𑁆" },
= { "as", "สฺ", "स्", "স্", "သ်", "ᩈ᩺", "ᩈ᩼", "ສ໌", "ສ຺", "ស៑", "ස්", "𑀲𑁆" },
= { "an", "นฺ", "न्", "ন্", "န်", "ᨶ᩺", "ᨶ᩼", "ນ໌", "ນ຺", "ន៑", "න්", "𑀦𑁆" },
= { "in", } -- Only simple for Roman script.
},
}
function tests.detectEnding(stem)
local oneLetter = sub(stem, -1)
for key, arr in pairs(endings.one) do
for _, val in ipairs(arr) do
if oneLetter == val then
return key
end
end
end
local twoLetters = sub(stem, -2)
for key, arr in pairs(endings.two) do
for _, val in ipairs(arr) do
if twoLetters == val then
return key
end
end
end
return "a"
end
function tests.joinSuffix(stem, suffixes)
local output = ""
local term
for _,suffix in ipairs(suffixes) do
if match(suffix, "^⌫⌫") then --backspace
term = sub(stem, 1, -3) .. sub(suffix, 3, -1)
elseif match(suffix, "^⌫") then --backspace
term = sub(stem, 1, -2) .. sub(suffix, 2, -1)
else
term = stem .. suffix
end
if scriptCode == "Thai" then
term = gsub(term, "(.)↶()", "%2%1") --swap
--term = gsub(term, "", "%1" .. u(0xFE00)) *currently no font supports
end
if scriptCode == "Mymr" then
term = gsub(term, "င္", "င်္")
term = gsub(term, "(င်္)()(ေ?)ာ", "%1%2%3ါ")
term = gsub(term, "္", { = "ျ", = "ြ" }) --these not need tall aa
term = gsub(term, "^()(ေ?)ာ", "%1%2ါ")
term = gsub(term, "()()(ေ?)ာ", "%1%2%3ါ")
term = gsub(term, "()(္)(ေ?)ာ", "%1%2%3ါ")
term = gsub(term, "္", { = "ွ", = "ှ" })
term = gsub(term, "ဉ္ဉ", "ည")
term = gsub(term, "သ္သ", "ဿ")
--term = gsub(term, "", "%1" .. u(0xFE00)) *currently no font supports
end
if scriptCode == "Lana" then
term = gsub(term, "ᨦ᩠", "ᩘ")
term = gsub(term, "^()(ᩮ?)ᩣ", "%1%2ᩤ")
term = gsub(term, "()()(ᩮ?)ᩣ", "%1%2%3ᩤ")
term = gsub(term, "()(᩠)(ᩮ?)ᩣ", "%1%2%3ᩤ")
term = gsub(term, "᩠", { = "ᩕ", = "ᩖ" })
term = gsub(term, "()᩠ᨮ", "%1ᩛ")
term = gsub(term, "()᩠ᨻ", "%1ᩛ")
term = gsub(term, "ᩈ᩠ᩈ", "ᩔ")
end
if output ~= "" then
output = output .. " <small style=\"color:888\">or</small> "
end
output = output .. links.full_link({lang = lang, sc = currentScript, term = term, tr='-'})
end
return output
end
function tests.show(frame)
local args = frame:getParent().args
local PAGENAME = mw.title.getCurrentTitle().text
local stem = args or args or PAGENAME
currentScript = lang:findBestScript(stem)
scriptCode = currentScript:getCode()
local ending = args or args or tests.detectEnding(stem)
local g = args or args or args -- for each gender only
if not g then
error("A gender is required to display proper declensions.")
end
local pattern = require("Module:pi-decl/noun/" .. scriptCode) or nil
local selectedPattern = pattern
local output = '<div class="NavFrame" style="min-width:30%"><div class="NavHead" style="background:#d9ebff">Declension table of "' .. stem .. '" (' .. genders .. ')</div><div class="NavContent">'
output = output .. '<table class="inflection-table" style="background:#F9F9F9;text-align:center;width:100%"><tr><th style="background:#eff7ff">Case \\ Number</th><th style="background:#eff7ff">Singular</th><th style="background:#eff7ff">Plural</th></tr>'
for i,v in ipairs(rows) do
output = output .. "<tr><td style=\"background-color:#eff7ff;\">" .. v .. "</td>"
output = output .. "<td>" .. tests.joinSuffix(stem, selectedPattern) .. "</td>"
output = output .. "<td>" .. tests.joinSuffix(stem, selectedPattern) .. "</td>"
output = output .. "</tr>"
end
output = output .. "</table></div></div>"
return output
end
function tests:test_big_bang()
--]
--preprocess_equals(text, expected, options)
tests:preprocess_equals_preprocess('{{pi-decl-noun|assa|a|g=m}}', '{{pi-decl-noun/test1|assa|a|g=m}}') -- , {=1})
tests:preprocess_equals_preprocess('{{pi-decl-noun|showtr=none|অঙ্গ|a|g=n}}', '{{pi-decl-noun/test1|অঙ্গ|a|g=n}}') -- , {=1})
tests:preprocess_equals_preprocess('{{pi-decl-noun|showtr=none|චන්දිමා|ā|g=m}}', '{{pi-decl-noun/test1|චන්දිමා|ā|g=m}}') -- , {=1})
tests:preprocess_equals_preprocess('{{pi-decl-noun|showtr=none|अम्मा|ā|g=f}}', '{{pi-decl-noun/test1|अम्मा|ā|g=f}}') -- , {=1})
tests:preprocess_equals_preprocess('{{pi-decl-noun|showtr=none|ဣသိ|i|g=m}}', '{{pi-decl-noun/test1|ဣသိ|i|g=m}}') -- , {=1})
tests:preprocess_equals_preprocess('{{pi-decl-noun|showtr=none|ชาติ|i|g=f}}', '{{pi-decl-noun/test1|ชาติ|i|g=f}}') -- , {=1})
tests:preprocess_equals_preprocess('{{pi-decl-noun|showtr=none|ᩋᨠ᩠ᨡᩥ|i|g=n}}', '{{pi-decl-noun/test1|ᩋᨠ᩠ᨡᩥ|i|g=n}}') -- , {=1})
tests:preprocess_equals_preprocess('{{pi-decl-noun|showtr=none|មានី|ī|g=m}}', '{{pi-decl-noun/test1|មានី|ī|g=m}}') -- , {=1})
tests:preprocess_equals_preprocess('{{pi-decl-noun|nadī|ī|g=f}}', '{{pi-decl-noun/test1|nadī|ī|g=f}}') -- , {=1})
tests:preprocess_equals_preprocess('{{pi-decl-noun|showtr=none|𑀧𑀁𑀲𑀼|u|g=m}}', '{{pi-decl-noun/test1|𑀧𑀁𑀲𑀼|u|g=m}}') -- , {=1})
tests:preprocess_equals_preprocess('{{pi-decl-noun|showtr=none|जम्बु|u|g=f}}', '{{pi-decl-noun/test1|जम्बु|u|g=f}}') -- , {=1})
tests:preprocess_equals_preprocess('{{pi-decl-noun|showtr=none|জত্তু|u|g=n}}', '{{pi-decl-noun/test1|জত্তু|u|g=n}}') -- , {=1})
tests:preprocess_equals_preprocess('{{pi-decl-noun|sayambhū|ū|g=m}}', '{{pi-decl-noun/test1|sayambhū|ū|g=m}}') -- , {=1})
tests:preprocess_equals_preprocess('{{pi-decl-noun|vadhū|ū|g=f}}', '{{pi-decl-noun/test1|vadhū|ū|g=f}}') -- , {=1})
tests:preprocess_equals_preprocess('{{pi-decl-noun|kattar|ar|g=m}}', '{{pi-decl-noun/test1|kattar|ar|g=m}}') -- , {=1})
tests:preprocess_equals_preprocess('{{pi-decl-noun|kathin|in|g=m}}', '{{pi-decl-noun/test1|kathin|in|g=m}}') -- , {=1})
-- Check masculine -in and -ī are equivalent, and neuter -in and -i
tests:preprocess_equals_preprocess('{{pi-decl-noun|kathin|in|g=m}}',
'{{pi-decl-noun|kathī|ī|g=m|label=kathin}}') -- , {=1})
tests:preprocess_equals_preprocess('{{pi-decl-noun|kathin|in|g=n}}',
'{{pi-decl-noun|kathi|i|g=n|label=kathin}}') -- , {=1})
end
local spaceJoin = function(vals)
output = ""
for i, v in ipairs(vals) do
if output == "" then
output = v
else
output = output.." "..v
end
end
return output
end
-- Argument is either a list of script codes or a single script code.
function tests:script_consistency_test(script_list, option)
local scripts
if type(script_list) == 'table' then
scripts = script_list
else -- Assume string
scripts = {script_list}
end
-- The words must not have exercised options in spellings.
local words = {{"buddha", "m"}, {"kaññā", "f"}, {"aṅga", "n"}, -- buddha and aṅga will need replacing.
{"aggi", "m"}, {"bodhi", "f"}, {"aṭṭhi", "n"},
{"bandhu", "m"}, {"dhenu", "f"}, {"cakkhu", "n"},
{"balī", "m"}, {"yakkhī", "f"}, {"viññū", "m"}, {"sassū", "f"},
{"candimā", "m"}, {"kattar", "m"}, {"sotas", "n"}, {"attan", "m"}, {"kathin", "m"},
{"pacant", "m"}, {"gacchant", "n"}, {"desent", "m"}, {"desent", "n"},
{"karont", "m"}, {"karont", "n"},
{"bhagavant", "m"}, {"saravant", "n"}, {"āyasmant", "m"}, {"āyasmant", "n"},
}
local caseFormList, mergedList = {}, {}
local scrCaseFormList, scrMergedList = {}, {}
local xCaseFormList, xMergedList = {}, {}
local m_xlit = require("Module:pi-Latn-translit")
local latEnd, latPat
local script, sword, scrEnd, scrPat
local errcnt = 0
local analysis = ""
for wi, wv in ipairs(words) do
latEnd = m_decl_noun.detectEnding(wv, nil)
latPat = m_decl_noun.getSuffixes("Latn", latEnd, wv)
for i = 1, 16 do
caseFormList = m_decl_noun.joinSuffix("Latn", wv, latPat)
mergedList = m_decl_noun.orJoin(m_scripts.getByCode("Latn"), caseFormList)
end
for _, sv in ipairs(scripts) do
script = m_scripts.getByCode(sv)
sword = m_xlit.tr(wv, sv, option)
scrEnd = m_decl_noun.detectEnding(sword, option)
scrPat = m_decl_noun.getSuffixes(sv, scrEnd, wv, option)
if scrPat then
for i = 1, 16 do
scrCaseFormList = m_decl_noun.joinSuffix(sv, sword, scrPat)
scrMergedList = m_decl_noun.orJoin(script, scrCaseFormList, option)
xCaseFormList = {}
for ai, av in ipairs(caseFormList) do
xCaseFormList = m_xlit.tr(av, sv, option)
end
xMergedList = m_decl_noun.orJoin(script, xCaseFormList, option)
-- equals(name, actual, expected, options)
local ic, ino
ic, ino = math.modf((i+1)/2)
local number
if ino == 0 then
number = " s."
else
number = " pl."
end
if scrMergedList == xMergedList then
tests:equals(sword.." "..rows..number, scrMergedList, xMergedList)
else -- comment doesn't work easily.
tests:equals(sword.." "..rows..number,
scrMergedList.."<br>Roman script: "..mergedList,
xMergedList)
end
end
else
tests:equals(sword, "No paradigm for "..wv, "")
end
end
end
tests:heading("'Expected' is Roman script with inflexions converted to other script.")
end
-- To reinstate the following as a test, remove 'dont_' from the name! The testing has been delegated to the
-- individual scripts' test cases.
function tests:dont_test_consistency() -- Check that different scripts have the same endings.
local scripts = {"Beng", "Brah", "Deva", "Khmr", "Lana", "Laoo", "Mymr", "Sinh", "Thai"}
tests:script_consistency_test(scripts)
local dual = {"Laoo", "Thai"}
tests:script_consistency_test(dual)
end
function tests.remove_noun_tests()
tests.test_big_bang = nil
tests.test_consistency = nil
end
return tests