Module:ar-translit/testcases

Definition from Wiktionary, the free dictionary
Jump to navigation Jump to search

This is the unit-testing module for Module:ar-translit.

2 tests failed. (refresh)

Text Expected Actual Differs at
test_translit_arabic:
Passed اَلْعَرَبِيَّة‏ al-ʿarabiyya al-ʿarabiyya
Passed اَلْعَرَبِيَّة. al-ʿarabiyya. al-ʿarabiyya.
Passed لِلْكِتَاب lilkitāb lilkitāb
Passed لِلتَّأْكِيد (nil) (nil) N/A
Passed لِلَّبَنِ lillabani lillabani
Passed لِللَّبَنِ (nil) (nil) N/A
Passed شْنِيتْزَل šnītzal šnītzal
Passed عُظْمَى ʿuẓmā ʿuẓmā
Passed إِحْدَى ʾiḥdā ʾiḥdā
Passed بِٱلتَّأْكِيد bi-t-taʾkīd bi-t-taʾkīd
Passed بِالتَّأْكِيد bi-t-taʾkīd bi-t-taʾkīd
Passed بِالتَأْكِيد bi-t-taʾkīd bi-t-taʾkīd
Passed بِالكِتَاب bi-l-kitāb bi-l-kitāb
Passed بِالْكِتَاب bi-l-kitāb bi-l-kitāb
Passed اَللُّغَةُ ٱلْعَرَبِيَّةُ al-luḡatu l-ʿarabiyyatu al-luḡatu l-ʿarabiyyatu
Passed اَللُّغَةُ الْعَرَبِيَّةُ al-luḡatu l-ʿarabiyyatu al-luḡatu l-ʿarabiyyatu
Passed نَسُوا nasū nasū
Passed رَمَوْا ramaw ramaw
Passed عَصًا ʿaṣan ʿaṣan
Passed هُدًى hudan hudan
Passed عَصاً ʿaṣan ʿaṣan
Passed هُذىً huḏan huḏan
Passed كاتِب kātib kātib
Passed كُتّاب kuttāb kuttāb
Passed إلاه ʾilāh ʾilāh
Passed كاتب (nil) (nil) N/A
Passed رَبّ rabb rabb
Passed نَوَاةٌ nawātun nawātun
Passed اَلشَّدَّة aš-šadda aš-šadda
Passed شَدَّة الشَكْل šadda(t) aš-šakl šadda(t) aš-šakl
Passed مُعَادَاة muʿādāh muʿādāh
Passed مِرْآة mirʾāh mirʾāh
Passed صلاح (nil) (nil) N/A
Passed اِيبَ ība ība
Passed دِيُون diyūn diyūn
Passed دُوِين duwīn duwīn
Passed الَّذِي allaḏī allaḏī
Failed رَأَيْتُ ابْنَهُ raʾaytu bnahu (nil) N/A
Passed رَأَيْتُ ٱبْنَهُ raʾaytu bnahu raʾaytu bnahu
Passed ڪُفُوًا kufuwan kufuwan
Failed أَحَدٌ ٱللّٰهُ ٱلصَّمَدُ ʾaḥaduni llāhu ṣ-ṣamadu ʾaḥadun llāhu ṣ-ṣamadu 8

-- 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ʾḵīd'
		{ 'لِلَّبَنِ', '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" },
		{ 'هُدًى', "hudan" },
		-- 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" },
		{ 'أَحَدٌ ٱللّٰهُ ٱلصَّمَدُ', "ʾaḥaduni llāhu ṣ-ṣamadu" },
	}
	
	self:iterate(examples, "do_test_translit")
end
 
return tests