Module:fa-ira-translit/testcases

-- Unit tests for Module:fa-translit. Refresh page to run tests. local tests = require('Module:UnitTests') local fa_translit = require('Module:fa-ira-translit') local m_links = require('Module:links')

local fa = require('Module:languages').getByCode('fa') local function link(term) return m_links.full_link{term = term, lang = fa} end

function tests:do_test_translit(Pers, roman, xlit) self:equals(link(Pers), fa_translit.tr(Pers, 'fa', 'fa-Arab'), roman) end

function tests:test_translit_persian local examples = { { 'سَرْاَنْجام', "sar-anjâm" }, { 'کُروز', "koruz" }, { 'کُرُوز', "korowz" }, -- this word is intentionally incorrect but demonstrates that zamme before vaaw produces a diphthong { 'واو', "vâv" }, {'نُوروز', "nowruz"}, { 'قَهْوِه‌ای' , "ğahve-i" }, -- case for ه‌ای as e-yi {'خوانْدَن', "xândan"}, -- case for خوا as xâ		{'خویش', "xiš"}, -- case for خوی as xi		{'خوَد', "xod"}, -- case for خو as xo (Iranian Persian) and xwad (Classical Persian) { 'چامِه‌سَرایی', "čâme-sarâyi" }, { 'چامه‌سَرایی', nil }, { 'طَنین', "tanin" }, { 'طَنِین', "taneyn" },	-- this word is intentionally incorrect but demonstrates that kasre before ye produces a diphthong { 'لِهٰذا', "lehâzâ" }, { 'عَصاً', "asan" }, { 'خانه', nil }, { 'خانِه', "xâne" }, { 'کُرِهٔ شُمالی', "kore-ye šomâli" }, { 'ضَمّه', nil }, { 'ضَمِّه', "zamme" }, { 'وُدْکا', "vodkâ" }, { 'اَرْمَنِسْتان', "armanestân" }, { 'باکو', "bâku" }, {"بَرادَرِ بُزُرْگ", "barâdar-e bozorg"}, -- ezafe, need a hyphen {'قُرونِ وُسْطیٰ', "ğorun-e vostâ" }, -- a dagger alif case {'دَرْ-آمَد', "dar-âmad" }, -- alif madda test { 'بازیِ شَطْرَنْج', "bâzi-ye šatranj" }, -- unmarked ezâfe with a kasra {'متعلق', nil}, -- should fail without vocalisations {'مُتَعَلِّق', "mota'alleğ"}, {'اِتِّحادِیِهٔ اُروپا', "ettehâdiye-ye orupâ"}, { "آیَتُ‌اللّٰه", "âyato-llâh"}, { 'شِیْخ', "šeyx"}, -- kasra + ye + consonant should give "ey" {'نُوْروز', "nowruz"}, -- 'ow', not 'ov'? Is this right? {'پَیام', "payâm"}, {'اَیّوب', "ayyub"}, {'شِبْهِ‌جَزیرِه', "šebh-e-jazire"}, -- ZWNJ should produce a hyphen {'پایْگاهِ‌دادِه',"pâygâh-e-dâde"}, --ZWNJ should produce a hyphen {'صَحْرایِ غَرْبی', "sahrâ-ye ğarbi"}, }	self:iterate(examples, "do_test_translit") end

return tests