Module:ar-translit/testcases

From Wiktionary, the free dictionary
Jump to navigation Jump to search

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

3 of 45 tests failed. (refresh)

TextExpectedActualDiffers at
test_translit_arabic:
Passedاَلْعَرَبِيَّة‏al-ʕarabiyyaal-ʕarabiyya
Passedاَلْعَرَبِيَّة.al-ʕarabiyya.al-ʕarabiyya.
Passedلِلْكِتَابlilkitāblilkitāb
Passedلِلتَّأْكِيد(nil)(nil)N/A
Passedلِلَّبَنِlillabanilillabani
Passedلِللَّبَنِ(nil)(nil)N/A
Passedشْنِيتْزَلšnītzalšnītzal
Passedعُظْمَىʕuẓmāʕuẓmā
Passedإِحْدَىʔiḥdāʔiḥdā
Passedخَطَإٍḵaṭaʔinḵaṭaʔin
Passedبِٱلتَّأْكِيدbi-t-taʔkīdbi-t-taʔkīd
Passedبِالتَّأْكِيدbi-t-taʔkīdbi-t-taʔkīd
Passedبِالتَأْكِيدbi-t-taʔkīdbi-t-taʔkīd
Passedبِالكِتَابbi-l-kitābbi-l-kitāb
Passedبِالْكِتَابbi-l-kitābbi-l-kitāb
Passedاَللُّغَةُ ٱلْعَرَبِيَّةُal-luḡatu l-ʕarabiyyatual-luḡatu l-ʕarabiyyatu
Passedاَللُّغَةُ الْعَرَبِيَّةُal-luḡatu l-ʕarabiyyatual-luḡatu l-ʕarabiyyatu
Passedنَسُواnasūnasū
Passedرَمَوْاramawramaw
Failedدَعَوُا اللّٰهَdaʕawu llāha(nil)N/A
Passedعَصًاʕaṣanʕaṣan
Passedهُدًىhudanhudan
Passedعَصاًʕaṣanʕaṣan
Passedهُدىًhudanhudan
Passedكاتِبkātibkātib
Passedكُتّابkuttābkuttāb
Passedإلاهʔilāhʔilāh
Passedكاتب(nil)(nil)N/A
Passedرَبّrabbrabb
Passedنَوَاةٌnawātunnawātun
Passedاَلشَّدَّةaš-šaddaaš-šadda
Passedشَدَّة الشَكْلšadda(t) aš-šaklšadda(t) aš-šakl
Passedمُعَادَاةmuʕādāhmuʕādāh
Passedمِرْآةmirʔāhmirʔāh
Passedصلاح(nil)(nil)N/A
Passedاِيبَībaība
Passedدِيُونdiyūndiyūn
Passedدُوِينduwīnduwīn
Passedالَّذِيallaḏīallaḏī
Failedرَأَيْتُ ابْنَهُraʔaytu bnahu(nil)N/A
Passedرَأَيْتُ ٱبْنَهُraʔaytu bnahuraʔaytu bnahu
Passedڪُفُوًاkufuwankufuwan
Failedأَحَدٌ ٱللّٰهُ ٱلصَّمَدُʔaḥaduni llāhu ṣ-ṣamaduʔaḥadun llāhu ṣ-ṣamadu8
Passedحُووِلَḥūwilaḥūwila
Passedدُوَيْبَّةduwaybbaduwaybba

-- 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