Modulus:ar-translit/testcases
Appearance
This is the unit-testing module for Module:ar-translit.
1 tests failed. (refresh)
Text | Expected | Actual | Differs at | |
---|---|---|---|---|
Script error during testing: Modulus:ar-translit/testcases:87: attempt to call method 'iterate' (a nil value)stack traceback: [C]: in function 'iterate' Modulus:ar-translit/testcases:87: in function <Modulus:ar-translit/testcases:19> (tail call): ? [C]: in function 'xpcall' Modulus:UnitTests:189: in function <Modulus:UnitTests:161> (tail call): ? mw.lua:527: in function <mw.lua:507> [C]: ? |
-- Unit tests for [[Module:ar-translit]]. Refresh page to run tests.
local tests = require('Module:UnitTests')
local ar_translit = require('Module:ar-translit')
local full_link = require('Module:links').full_link
local ar = require('Module:languages').getByCode('ar')
local rlm = mw.ustring.char(0x200F) -- right-to-left mark
local function link(word)
return full_link{ term = word, lang = ar, tr = "-" }
end
--TO DO
function tests:do_test_translit(arab, roman)
self:equals(link(arab), ar_translit.tr(arab, 'ar', 'Arab'), roman)
end
function tests:test_translit_arabic()
local examples = {
{ "اَلْعَرَبِيَّة" .. rlm, "al-ʿarabiyya" }, -- right-to-left mark is removed
{ "اَلْعَرَبِيَّة.", "al-ʿarabiyya." },
{ 'لِلْكِتَاب', 'lilkitāb' }, -- ideally 'li-l-kitāb'
{ 'لِلتَّأْكِيذ', nil }, -- ideally 'li-t-taʾḵīḏ'
{ 'لِلَّبَنِ', 'lillabani' }, -- ideally 'li-l-labani'; correct spelling
{ 'لِللَّبَنِ', nil }, -- ideally 'li-l-labani; spelling sometimes used
{ 'شْنِيتْزَل', "šnītzal" },
{ 'عُظْمَى', "ʿuẓmā" },
{ 'إِحْدَى', "ʾiḥdā" },
-- cases with bi- prefix plus definite article
{ 'بِٱلتَّأْكِيد', "bi-t-taʾkīd" },
{ 'بِالتَّأْكِيد', "bi-t-taʾkīd" },
{ 'بِالتَأْكِيد', "bi-t-taʾkīd" },
{ 'بِالكِتَاب', "bi-l-kitāb" },
{ 'بِالْكِتَاب', "bi-l-kitāb" },
-- check handling of ʾiʿrāb, hamzatu l-waṣl w/al-, al- w/sun and moon letters
{ 'اَللُّغَةُ ٱلْعَرَبِيَّةُ', "al-luḡatu l-ʿarabiyyatu" },
-- check elision of al- after a vowel
{ 'اَللُّغَةُ الْعَرَبِيَّةُ', "al-luḡatu l-ʿarabiyyatu" },
-- check two kinds of otiose alif in 3rd-masc-plural endings
{ 'نَسُوا', "nasū" },
{ 'رَمَوْا', "ramaw" },
-- check otiose alif and alif maqṣūra after fatḥatan
{ 'عَصًا', "ʿaṣan" },
{ 'هُذًى', "huḏan" },
-- same where fatḥatan wrongly placed over alif or alif maqṣūra
{ 'عَصاً', "ʿaṣan" },
{ 'هُذىً', "huḏan" },
-- infer fatḥa on alif between consonants
{ 'كاتِب', "kātib" },
-- infer fatḥa on alif between consonants when first is marked with shadda
{ 'كُتّاب', "kuttāb" },
-- infer kasra after hamza-under-alif
{ 'إلاه', "ʾilāh" },
-- missing diacritic on t
{ 'كاتب', nil },
-- final shadda on unvocalized consonant
{ 'رَبّ', "rabb" },
-- tā' marbūṭa preceded by alif; don't infer fatḥa
{ 'نَوَاةٌ', "nawātun" },
-- alif-lam w/unvocalized lam + shadda over sun letter; final tāʾ marbūṭa
{ 'اَلشَّدَّة', "aš-šadda" },
-- medial tāʾ marbūṭa
{ 'شَدَّة الشَكْل', "šadda(t) aš-šakl" },
-- alif + tāʾ marbūṭa --> āh
{ 'مُعَادَاة', "muʿādāh" },
-- alif madda + tāʾ marbūṭa --> āh
{ 'مِرْآة', "mirʾāh" },
-- test of h for the constant
{ 'صلاح', nil },
-- initial unhamzated alif + ī
{ 'اِيبَ', "ība" },
-- iyū sequence
{ 'دِيُون', "diyūn" },
-- uwī sequence
{ 'دُوِين', "duwīn" },
-- allaḏī, with al + shadda
{ 'الَّذِي', "allaḏī" },
-- alif al-wasl
{ 'رَأَيْتُ ابْنَهُ', "raʾaytu bnahu" },
{ 'رَأَيْتُ ٱبْنَهُ', "raʾaytu bnahu" },
-- "swash kaf"
{ 'ڪُفُوًا', "kufuwan" },
}
self:iterate(examples, "do_test_translit")
end
return tests