Modul:ur-translit/testcases

A Wikiszótárból, a nyitott szótárból

A modult a Modul:ur-translit/testcases/doc lapon tudod dokumentálni

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

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

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

function tests:do_test_translit(Urdu, roman)
	self:equals(link(Urdu), ur_translit.tr(Urdu, 'ur', 'ur-Arab'), roman)
end

function tests:test_translit_urdu()
	local examples = {
		{ "اِیرانِی", "īrānī"},
		{ "ماشاءاَللّٰہ", "māśā'allāh"},
		{ "پَیدائِش", "paidāiś"},
		{ "بَرْقِیات", "barqiyāt"},
		{ "عَقْل", "'aql" },
		{ "عِزَّت", "'izzat" },
		{ "عَین", "'ain" },
		{ "عالَم", "'ālam" },
		{ "عَورَت", "'aurat" },
		{ "شُرُوع", "śurū'" },
		{ "اِشْعاع"	, "iś'ā'" },
		{ "تَعَلُّقات", "ta'alluqāt" },
		{ "تَعَلُّق", "ta'alluq" },
		{ "مُتَعَلِّق", "muta'alliq" },
		{ "متعلق", nil }, -- this test should fail for the lack of vocalisation
		{ "عُمْر", "'umr" },
		{ "دَفْعَہ", "daf'a" },
		{ "بَچَّہ", "bacca" },
		{ "قُوَّت", "quvvat" },
		{ "مَۓ عِشْق", "ma-ye 'iśq" },
		{ "شیرِ پَنْجاب", "śer-i pañjāb" },
		{ "مَلْکَۂ دُنْیا", "malka-yi dunyā" },
		{ "جَمُّوں", "jammū̃"},
		{ "آم", "ām" },
		{ "اِشْتِراکِیَّت", "iśtirākiyyat"},
		{ "سِسَکْنا","sisaknā"},
		{ "پُل","pul"},
		{ "عِیسیٰ", "'īsā"},
		{ "اَعْلیٰ", "a'lā"},
		{ "لَفْظ","lafz"},
		{ "حاضِر", "hāzir" },
		{ "بَہورا", "bahorā"},
		{ "نَہِیں", "nahī̃"},
		{ "اِشْتِمالِیَت", "iśtimāliyat"},
		{ "چَوڑا", "cauṛā" },
		{ "تِھیں", "thī̃"},
		{ "کُتّا", "kuttā" },
		{ "پَہْلے", "pahle"},
		{ "کِھلائی", "khilāī"},
		{ "کھلائی", nil },	-- "khl" must be an impossible cluster at the beginning of a word
		--this one is supposed to fail
		{ "ٹَھہَرْنا", "ṭhaharnā"},
		{ "تَیمُور", "taimūr"},
		{ "فَوراً", "fauran"},
		{ "کوئے", 
		"koe"}, 
		{ "مَنَّتوں", 
		"mannatõ"},
		{ "گان٘وں", 
		"gā̃õ"},
		{ "مَیں", 
		"ma͠i"},
		{ "آئی", 
		"āī"},
		{ "مَکَّھن", 
		"makkhan"},
		{ "خُدا", "xudā" },
		{ "کَئی", "kaī" },
		{ "کُئی", "kuī" },
		{ "چائے", "cāe" },
		{ "کُھلْواؤ", "khulvāo" },
		{ "غَدّار", "ġaddār"},
		{ "بَیٹھو", "baiṭho"},
		{ "بَطَّخ", "battax"},
		{"مُتَّحِدَۂ", "muttahida-yi"},
		{ "ساؤُتھ اَفْرِیقَہ", 
			"sāuth afrīqa"},
		{"کُلِّیَّہ", "kulliyya"},
		{"دائِرَۃُ", 
			"dāiratu"},
		{ "سُورَۃ", "sūra"}, -- alt form of سُورَہ
		{"بِلّا", "billā"},
		{"دائِرَۃُ الْمَعارِف", "dāiratu l-ma'ārif"}, -- restoring this case, pls check the line below
		{"دائِرَۃْ اُلْمَعارِف", "dāirat  ulma'ārif" }, -- is that a more appropriate spelling?
		{"آیَت اُللّٰہ", "āyat ullāh"}, -- allāh fails when there is a diacritic over alif 
		{"صَیّاد", "sayyād"}, -- testing tashdid on ye
		{"کہاں", nil}, -- should fail
	}
	
	self:iterate(examples, "do_test_translit")
end	

return tests