Module:ar-translit/testcases

-- 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 = require("Module:string/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ʔḵīd' { 'لِلَّبَنِ', 'lillabani' }, -- ideally 'li-l-labani'; correct spelling { 'لِللَّبَنِ', nil }, -- ideally 'li-l-labani; spelling sometimes used { 'شْنِيتْزَل', "šnītzal" }, { 'عُظْمَى', "ʕuẓmā" }, { 'إِحْدَى', "ʔiḥdā" }, { 'خَطَإٍ', "ḵaṭaʔin" }, -- 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" }, { 'دَعَوُا اللّٰهَ', "daʕawu llāha" }, -- check otiose alif and alif maqṣūra after fatḥatan { 'عَصًا', "ʕaṣan" }, { 'هُدًى', "hudan" }, -- same where fatḥatan wrongly placed over alif or alif maqṣūra { 'عَصاً', "ʕaṣan" }, { 'هُدىً', "hudan" }, -- 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" }, { 'أَحَدٌ ٱللّٰهُ ٱلصَّمَدُ', "ʔaḥaduni llāhu ṣ-ṣamadu" }, { 'حُووِلَ', "ḥūwila" }, { 'دُوَيْبَّة', "duwaybba" }, }	self:iterate(examples, "do_test_translit") end return tests