Module:fa-cls-translit/testcases

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

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

All tests passed. (refresh)

TextExpectedActualDiffers at
test_translit_persian:
Passedسَرْاَنْجَام‏sar-anjāmsar-anjām
Passedکُروزkurōzkurōz
Passedدَهْdahdah
Passedدَهdada
Passedسُؤَالsu'ālsu'āl
Passedکُرُوزkurūzkurūz
Passedوَاوْwāwwāw
Passedنَوْروزnawrōznawrōz
Passedقَهْوَه‌اِیqahwa-īqahwa-ī
Passedقَهْوَه‌یِیqahwa-yīqahwa-yī
Passedخْوَانْدَنxwāndanxwāndan
Passedخْویشxwēšxwēš
Passedخْوَدxwadxwad
Passedچَامَه‌سَرَایِیčāma-sarāyīčāma-sarāyī
Passedطَنِینtanīntanīn
Passedلِهٰذَاlihāzālihāzā
Passedقَهْرًاqahranqahran
Passedعَصاًasanasan
Passedخَانَهxānaxāna
Passedکورِیَایِ شُمَالِیkōriyā-yi šumālīkōriyā-yi šumālī
Passedضَمَّهzammazamma
Passedضَمِّهْzammihzammih
Passedکِهkiki
Passedکِهْkihkih
Passedاَرْمَنِسْتَانarmanistānarmanistān
Passedبَاکُوbākūbākū
Passedکَسیkasēkasē
Passedبَرَادَرِ بُزُرْگbarādar-i buzurgbarādar-i buzurg
Passedقُرُونِ وُسْطیٰqurūn-i wustāqurūn-i wustā
Passedدَر-آمَدdar-āmaddar-āmad
Passedبَازِیِ شَطْرَنْجbāzī-yi šatranjbāzī-yi šatranj
Passedایرَانِیَانērāniyānērāniyān
Passedسُؤَالsu'ālsu'āl
Passedصُبَاحsubāhsubāh
Passedصُبْحsubhsubh
Passedصُبْهsubhsubh
Passedدُروغ گویْdurōğ gōydurōğ gōy
Passedاوōō
Passedوَwawa
Passedو u u
Passedبَه نَامِ خُدَاba nām-i xudāba nām-i xudā
Passedجَوَانِیjawānījawānī
Passedشَاهْنَامَهšāhnāmašāhnāma
Passedزِنْدَگِیzindagīzindagī
Passedزِنْدَه‌گِیzinda-gīzinda-gī
Passedمیوَهٔ جَاپَانِیmēwa-yi jāpānīmēwa-yi jāpānī
Passedنُویدnuwēdnuwēd
Passedدُخْتَرَْبَچَّهduxtar-baččaduxtar-bačča
Passedکِیَهkiyakiya
Passedکُرُوَاسِیَاkuruwāsiyākuruwāsiyā
Passedمِیَایِینmiyāyīnmiyāyīn
Passedمْیَایینmyāyēnmyāyēn
Passedطِلَّاtillātillā
Passedلیکِنlēkinlēkin
Passedبَچَّهٔ لَطِیفَه کَلَان اَسْتbačča-yi latīfa kalān astbačča-yi latīfa kalān ast
Passedمَعْرُوف و مَجْهُولma'rūf u majhūlma'rūf u majhūl
Passedمَعْرُوف وَ مَجْهُولma'rūf wa majhūlma'rūf wa majhūl
Passedاَرمنستان(nil)(nil)N/A
Passedباکو(nil)(nil)N/A
Passedکسی(nil)(nil)N/A
Passedبرادر بزرگ(nil)(nil)N/A
Passedقرون وسطی(nil)(nil)N/A
Passedوَٱللّٰهwal-lāhwal-lāh
Passedکَسےkasēkasē
Passedکَٹَهkaṭakaṭa
Passedآیَةُ‌اللّٰهāyatu-l-lāhāyatu-l-lāh
Passedفِالْحَالfi-l-hālfi-l-hāl
Passedبویِ تُوbō-yi tūbō-yi tū
Passedبِسْمِ اللّٰهِ الْرَّحْمٰنِ الْرَّحِیمbismi l-lāhi r-rahmāni r-rahīmbismi l-lāhi r-rahmāni r-rahīm
Passedاِیَالَاتِ مُتَّحِدَهiyālāt-i muttahidaiyālāt-i muttahida
Passedدَارُ الخَلَافَهdāru l-xalāfadāru l-xalāfa
Passedاَبُو الهَوْدabū l-hawdabū l-hawd

-- Unit tests for [[Module:fa-cls-translit]]. Refresh page to run tests.
local tests = require('Module:UnitTests')
local fa_translit = require('Module:fa-cls-translit')

local full_link = require('Module:links').full_link
local fa = require('Module:languages').getByCode('fa')

local rlm = require("Module:string/char")(0x200F) -- right-to-left mark

local function link(word)
	return full_link{ term = word, lang = fa, tr = "-" }
end

--TO DO
function tests:do_test_translit(arab, roman)
	self:equals(link(arab), fa_translit.tr(arab, 'fa', 'Persian'), roman)
end

function tests:test_translit_persian()
	local examples = {
		
		{ 'سَرْاَنْجَام' .. rlm, "sar-anjām" },
		{ 'کُروز', "kurōz" },
		{ 'دَهْ', "dah"}, --always "h" near a vowel
		{ 'دَه', "da"}, --always a when theres no vowel
		{ 'سُؤَال', "su'āl" },
		{ 'کُرُوز', "kurūz" }, -- this word is intentionally incorrect
		{ 'وَاوْ', "wāw" },
		{'نَوْروز', "nawrōz"},
		{ 'قَهْوَه‌اِی', "qahwa-ī" }, -- case for ه‌َای as a-'ī can be changed to yī
		{ 'قَهْوَه‌یِی', "qahwa-yī" }, -- case for ه‌یِی as a-'ī
		{'خْوَانْدَن', "xwāndan"}, -- case for خوَا as xwā
		{'خْویش', "xwēš"}, 
		{'خْوَد', "xwad"}, -- case for خو as xo (Iranian Persian) and xwad (Classical Persian)
		{ 'چَامَه‌سَرَایِی', "čāma-sarāyī" },
		{ 'طَنِین', "tanīn" },
		{ 'لِهٰذَا', "lihāzā" }, -- can be lehāzā if majhul diacritics are shown
		{ 'قَهْرًا', "qahran" },
		{ 'عَصاً', "asan" }, --either placement works
		{ 'خَانَه', "xāna" },	
		{ 'کورِیَایِ شُمَالِی', "kōriyā-yi šumālī" },	
		{ 'ضَمَّه', "zamma" },
		{ 'ضَمِّهْ', "zammih" }, -- force include final -h with diacritics
		{ 'کِه', "ki"},
		{ 'کِهْ', "kih" }, -- another example of forcing the h
		{ 'اَرْمَنِسْتَان', "armanistān" }, 
		{ 'بَاکُو', "bākū" },
		{ 'کَسی', "kasē"}, --word final -ē
		{"بَرَادَرِ بُزُرْگ", "barādar-i buzurg"}, -- izafa/ezafe marked with a dash -
		{'قُرُونِ وُسْطیٰ', "qurūn-i wustā" }, -- a dagger alif case
		{'دَر-آمَد', "dar-āmad" }, -- alif madda test
		{ 'بَازِیِ شَطْرَنْج', "bāzī-yi šatranj" },
		{ 'ایرَانِیَان', "ērāniyān"},
		{ 'سُؤَال', "su'āl"}, --if majhul diacritics are used then so'āl
		{ 'صُبَاح', "subāh" },
		{ 'صُبْح', "subh"},
		{ 'صُبْه', "subh"}, --purposefully mispelt
		{ "دُروغ گویْ", "durōğ gōy"}, --have semivowels become consonts with jazm
		{ 'او', "ō" }, -- transliteration of wa, beginning of sentence
		{ 'وَ', "wa" },	--transliteration of wa, elsewhere (requires two spaces on both sides)
		{ ' و ', " u " },
		{ 'بَه نَامِ خُدَا', "ba nām-i xudā"},
		{ 'جَوَانِی', "jawānī"},
		{ 'شَاهْنَامَه', "šāhnāma"},
		{ 'زِنْدَگِی', "zindagī"},
		{ 'زِنْدَه‌گِی', "zinda-gī"},
		{ 'میوَهٔ جَاپَانِی', "mēwa-yi jāpānī" },
		{ 'نُوید', "nuwēd"}, -- nawīd/navid in modern Persian
		{ 'دُخْتَرَْبَچَّه',"duxtar-bačča"},
		{ 'کِیَه', "kiya" },
		{ 'کُرُوَاسِیَا', "kuruwāsiyā" }, --moderate vowel test
		{ 'مِیَایِین', "miyāyīn"}, -- more complex vowel test
		{ 'مْیَایین', "myāyēn"}, -- more complex vowel test
		{ 'طِلَّا', "tillā" },
		{ 'لیکِن', "lēkin" },
		{ 'بَچَّهٔ لَطِیفَه کَلَان اَسْت', "bačča-yi latīfa kalān ast" },
		{ 'مَعْرُوف و مَجْهُول', "ma'rūf u majhūl"},
		{ 'مَعْرُوف وَ مَجْهُول', "ma'rūf wa majhūl"},
		{ 'اَرمنستان', nil }, 
		{ 'باکو', nil },
		{ 'کسی', nil }, --word final -ē
		{"برادر بزرگ", nil }, -- izafa/ezafe marked with a dash -
		{'قرون وسطی', nil }, -- a dagger alif 
		{'وَٱللّٰه', "wal-lāh"}, --alef_wasla 
		-- uncommon characters
		{'کَسے',
			'kasē'}, -- treated like normal ye
		{'کَٹَه',
			'kaṭa'},--hazaragi retroflex's
		-- Arabic al-
		{'آیَةُ‌اللّٰه',
			'āyatu-l-lāh'},
		{'فِالْحَال',
			'fi-l-hāl'},
		{'بویِ تُو',
			'bō-yi tū'},
		{'بِسْمِ اللّٰهِ الْرَّحْمٰنِ الْرَّحِیم',
			'bismi l-lāhi r-rahmāni r-rahīm'},
		{'اِیَالَاتِ مُتَّحِدَه',
			'iyālāt-i muttahida'},
		{'دَارُ الخَلَافَه',
		'dāru l-xalāfa'},
		{'اَبُو الهَوْد',
			'abū l-hawd'}
	}
	self:iterate(examples, "do_test_translit")
end	

return tests