မာတိကာသို့ ခုန်သွားရန်

မဝ်ဂျူ:he-translit/testcases

နူ ဝိက်ရှေန်နရဳ

Documentation for this module may be created at မဝ်ဂျူ:he-translit/testcases/doc

-- Unit tests for [[Module:he-translit]]. Refresh page to run tests.
local tests = require('Module:UnitTests')
local he_translit = require('Module:he-translit')
local full_link = require('Module:links').full_link
local lang = require('Module:languages').getByCode('he')
local sc = require('Module:scripts').getByCode('Hebr')

local function link(term)
	return full_link{lang = lang, sc = sc, term = term}
end

function tests:do_test_translit(system)
	local tr
	if system == "modern" then
		local modern = he_translit.tr
		function tr(text)
			return modern(text, 'he', 'Hebr')
		end
	elseif system == "biblical" then
		tr = he_translit.biblical
	end
	
	return function (self, text, expected_tr, comment)
		self:equals(link(text), tr(text), expected_tr, {comment=comment})
	end
end

function tests:test_translit_hebrew()
	local examples = {
		{ 'מַקְלֵעַ', "maklea'" },
		{ 'אַבְּסוּרְד', "'ab'sur'd" , "not sure about what should be expected here"},
		-- { 'ביומטריה', ? },
		{ 'בִּיּוֹמֶטְרִיָּה', "biyometriya" },
		{ 'קַפְרִיסִין', "kafrisin" },
		{ 'חֹרֶף', "khoref" },
		{ 'טוּרְקִיז', "turkiz" },
		{ 'טַחַב', "takhav" },
		{ 'יִוָּלֵד', "yivaled" },
		{ 'יָקִינְתּוֹן', "yakinton" },
		{ 'כֻּתְנָה', "kutna" },
		{ 'נַגָּרִיָּה', "nagariya" },
		{ 'נַעֲלֶה', "na'ale" },
		{ 'מִצְווֹת', "mitsvot" },
		{ 'מָקוֹם', "makom" },
		{ 'פֶּרוּאָנִי', "peru'ani" },
		{ 'צִדְפָּה', "tsidpa" },
		{ 'תׇּכְנָה', "tokhna" },
		{ 'רְאוּ', "r'u" },

		{ 'גּ׳וּק', "juk" },
		{ 'ג׳וּק', "juk" },
		{ 'גִּ׳ירָאפָה', "jirafa" },
		{ 'גִ׳ירָאפָה', "jirafa" },
		{ 'זַ׳רְגוֹן', "zhargon" },
		{ 'קַפּוּצִ׳ינוֹ', "kapuchino" },

		{ 'סְקוֹץ׳', "s'koch" },
		{ 'סְתוֹם תַּ׳פֶּה', "s'tom ta′pe" },
		{ 'אִמָּא׳לֶה', "'ima′le" },
		{ 'חָזָ״ל', "khaza″l" },
		{ 'נַחַ״ל', "nakha″l" },
		{ 'רה״מ', "rh″m" },
		{ 'ב״ה', "b″h" },
		{ 'ת״א', "t″'" },
	}
	
	self:iterate(examples, self:do_test_translit("modern"))
end

function tests:test_biblical()
	local examples = {
		{ "בַּיִת", "bayiṯ" },
		{ "בֵּית", "bēṯ" },
        { "עַכּוֹ‎", ""},
		{ "בָּתִּים", "bāttīm" },
		{ "מַחֲנֶה", "maḥăne" },
		{ "בָּרָא", "bārā" },
		{ "רֶגֶל", "reḡel" },
		{ "כֹּהֵן", "kōhēn" },
		{ "מֶלֶךְ", "meleḵ" },
		{ "מַמְלָכָה", "mamlāḵā" },
		{ "הַמַּמְלָכָה", "hammamlāḵā" },
		{ "הַלְּלוּיָהּ", "halləlūyāh" },
		{ "הַלְלוּיָהּ", "haləlūyāh" },
		{ "יָדַע", "yāḏaʿ" },
		{ "שָׁבוּעַ", "šāḇūaʿ" },
		{ "רוּחַ", "rūaḥ" },
		{ "גָּבֹהַּ", "gāḇōah" },
		{ "מָשִׁיחַ", "māšīaḥ" },
		{ "רֵיחַ", "rēaḥ" },
		{ "שָׂדֶה", "śāḏe" },
		{ "שְׂדֵה", "śəḏē" },
		{ "בָּנַי", "bānay" },
		{ "בְּנֵי", "bənē" },
		{ "צָרְכִּי", "ṣorkī" },
		{ "חָכְמָה", "ḥāḵəmā", "ambiguous case: could be ḥāḵəmā or ḥoḵmā, but I think ḥāḵəmā is the preferred default" },
		{ "שִׁפְרָה", "šip̄rā" },
		{ "שָׁכְבְּךָ", "šoḵbəḵā" },
		{ "הָפְכָּה", "hop̄kā", "made-up word, but a particular potentially problematic Unicode situation" },
		{ "קָטְבּוֹ", "qoṭbō", "another particular potentially problematic Unicode situation" },
		{ "נִשְׂרְפָה", "niśrəp̄ā" },
		{ "בָּנָיו", "bānāw" },
		{ "בָּנֶיהָ", "bānehā" },
		{ "מִצְוֹת", "miṣwōṯ" },
		{ "זִוּוּג", "ziwwūḡ" },
		{ "רֹאשׁ", "rōš" },
		{ "רֵאשִׁית", "rēšīṯ" },
		{ "רִאשׁוֹן", "rīšōn" },
		{ "מְלָאכָה", "məlāḵā" },
		{ "מְלֶאכֶת", "məleḵeṯ" },
		{ "חֵטְא", "ḥēṭ" },
		{ "בָּרָאתָ", "bārāṯā" },
		{ "חַטֹּאות", "ḥaṭṭōṯ" },
		{ "יְראוּ", "yərū" },
		{ "וַיֶּאְסֹר", "wayyeʾsōr" },
		{ "הָחְלַט", "hoḥlaṭ" },
		{ "וַיֵּבְךְּ", "wayyēḇk" },
		{ "אַרְאֶךָּ", "ʾarʾekkā" },
		{ "וַיַּשְׁקְ", "wayyašq" },
		{ "אַתְּ", "ʾatt" },
		{ "וּוָווֹ", "ūwāwō" },
		{ "וָו", "wāw" },
		{ "תָּו", "tāw" },
		{ "קַו", "qaw" },
		{ "לָאו", "lāw" },
		{ "חַי", "ḥay" },
		{ "חָי", "ḥāy", "pausal" },
		{ "פִּיו", "pīw" },
		{ "כִּסְלֵו", "kislēw" },
		{ "גּוֹי", "gōy" },
		{ "גֹּי", "gōy" },
		{ "גֹּיִים", "gōyīm" },
		{ "רָאוּי", "rāʾūy" },
		{ "קִיא", "qī" },
		{ "יָבִיאוּ", "yāḇīʾū" },
		{ "יְבִיאוּן", "yəḇīʾūn" },
		{ "מֵאוּן", "mēʾūn" },
		{ "מֵיאוּן", "mēʾūn" },
		{ "בּוֹאוּ", "bōʾū" },
		{ "בֹּאוּ", "bōʾū" },
		{ "בּוּאוּ", "būʾū", "made-up word, but may help identify the issue" },
		{ "אָבִיאָה", "ʾāḇīʾā" },
		{ "מֵאָה", "mēʾā" },
		{ "גֵּיאָהּ", "gēʾāh" },
		{ "אָבוֹאָה", "ʾāḇōʾā" },
		{ "אָבֹאָה", "ʾāḇōʾā" },
		{ "נְשׂוּאָה", "nəśūʾā" },
		{ "קִיאוֹ", "qīʾō" },
		{ "גֵּאוֹ", "gēʾō" },
		{ "גֵּיאוֹ", "gēʾō" },
		{ "בּוֹאוֹ", "bōʾō" },
		{ "בֹּאוֹ", "bōʾō" },
		{ "מִלּוּאוֹ", "millūʾō" },
		{ "מִי", "mī" },
		{ "אִיִּים", "ʾiyyīm" },
		{ "אִיּוֹב", "ʾiyyōḇ" },
		{ "אִיּוּן", "ʾiyyūn" },
		{ "אַיִן", "ʾayin" },
		{ "בּוֹא", "bō" },
		{ "יְפֵהפֶה", "yəp̄ēp̄e" },
		{ "אֹהֶל", "ʾōhel" },
		{ "הָאֹהֱלָה", "hāʾōhĕlā" },
		{ "אָהֳלוֹ", "ʾohŏlō" },
		{ "אָהָלְךָ", "ʾoholəḵā" },
		{ "יִשָּׂשכָר", "yiśśāḵār", "Still undecided if this actually needs to be handled" },
		{ "הוֹשִׁיעָה נָּא", "hōšīʿā nnā" },
		{ "עַד בֹּאֲךָ", "ʿaḏ bōʾăḵā" },
		{ "וַיַּשְׁקְ אֶת הַצֹּאן", "wayyašq ʾeṯ haṣṣōn" },
		{ "בְּנֵי בְרָק", "bənē ḇərāq" },
		{ "בְרָק", "ḇərāq" },
		{ "אִישׁ יְהוּדִי הָיָה בְּשׁוּשַׁן הַבִּירָה וּשְׁמוֹ מָרְדֳּכַי בֶּן יָאִיר בֶּן־שִׁמְעִי בֶּן־קִישׁ אִישׁ יְמִינִי׃", "ʾīš yəhūḏī hāyā bəšūšan habbīrā ūšəmō mordŏḵay ben yāʾīr ben-šimʿī ben-qīš ʾīš yəmīnī." },
		{ "אִ֣ישׁ יְהוּדִ֔י הָיָ֖ה בְּשׁוּשַׁ֣ן הַבִּירָ֑ה וּשְׁמ֣וֹ מָרְדֳּכַ֗י בֶּ֣ן יָאִ֧יר בֶּן־שִׁמְעִ֛י בֶּן־קִ֖ישׁ אִ֥ישׁ יְמִינִֽי׃", "ʾīš yəhūḏī hāyā bəšūšan habbīrā ūšəmō mordŏḵay ben yāʾīr ben-šimʿī ben-qīš ʾīš yəmīnī.", "fully accented verse; stress should not be indicated in the final syllable" },
		{ "וַיְהִי הַמַּבּוּל אַרְבָּעִים יוֹם עַל־הָאָרֶץ וַיִּרְבּוּ הַמַּיִם וַיִּשְׂאוּ אֶת־הַתֵּבָה וַתָּרָם מֵעַל הָאָרֶץ׃", "wayəhī hammabbūl ʾarbāʿīm yōm ʿal-hāʾā́reṣ wayyirbū hammáyim wayyiśəʾū ʾeṯ-hattēḇā wattā́rom mēʿal hāʾāreṣ.", "a reminder of why this is hard" },
		{ "וַיְהִ֧י הַמַּבּ֛וּל אַרְבָּעִ֥ים י֖וֹם עַל־הָאָ֑רֶץ וַיִּרְבּ֣וּ הַמַּ֗יִם וַיִּשְׂאוּ֙ אֶת־הַתֵּבָ֔ה וַתָּ֖רָם מֵעַ֥ל הָאָֽרֶץ׃", "wayəhī hammabbūl ʾarbāʿīm yōm ʿal-hāʾā́reṣ wayyirbū hammáyim wayyiśəʾū ʾeṯ-hattēḇā wattā́rom mēʿal hāʾāreṣ.", "fully accented verse version of the above" },

		"implicit ktiv/qre that would be nice to have",
		{ "הִוא", "hī" },
		{ "יְרוּשָׁלִַם", "yərūšālayim" },
		{ "יְרוּשָׁלִָם", "yərūšālāyim", "pausal form" },
		{ "יְרוּשָׁלְַמָה", "yərūšālaymā" },
		{ "יְרוּשָׁלְָמָה", "yərūšālāymā" },

		"ktiv male tests",
		{ "חַיָּיב", "ḥayyāḇ" },
		{ "חַוָּוה", "ḥawwā" },
		{ "הֱוֵוה", "hĕwē" },
		{ "הַיְינוּ", "haynū" },
		{ "הִתְכַּוְּונוּ", "hiṯkawwənū" },
		{ "גַּוְונָא", "gawnā" },
		{ "מְייוּחָד", "məyūḥāḏ" , "there is no way to tell that it really should be məyuḥāḏ, but anyway this test is for the double yod"},
		{ "כְּדַאי", "kəḏay" },
		{ "כּוּלָּם", "kullām", "shuruk does not necessarily imply a long vowel" },
		{ "קִידּוּשׁ", "qiddūš", "chiriq male does not necessarily imply a long vowel" },
	}
	self:iterate(examples, self:do_test_translit("biblical"))
end
 
return tests