Module:hit-translit/testcases

From Linguifex
Jump to navigation Jump to search

Documentation for this module may be created at Module:hit-translit/testcases/doc

local hit_translit = require('Module:hit-translit')
local hit_tag = require('Module:hit-translit/tag')
local tests = require('Module:UnitTests')

function tests:test_1_tr()
	local test_tr = {
		{ "๐’Šญ๐’‰๐’……๐’†ช๐’‘๐’‹ซ", "ลกa-pรญ-ik-ku-uลก-ta" },
		{ "๐’„ฟ๐’…€๐’€œ๐’‹ซ", "i-ya-at-ta" },
		{ "๐’€ ๐’‰บ๐’€ธ", "al-pa-aลก" },
		{ "๐’† ๐’…•", "ke-er" },
		{ "๐’‹ผ๐’€€๐’‹พ๐’…€๐’€ธ", "kar-ti-ya-aลก" },
		{ "๐’Šฎ๐’…•", hit_tag.tag_sumerogram("ล ร€") .. "-er" },
		{ "๐’‰บ๐’„ด๐’„ท๐’‰ฟ๐’…ˆ", "pa-aแธซ-แธซu-wa-ar" },
		{ "๐’‰บ๐’„ด๐’„ฏ", "pa-aแธซ-แธซur" },
		{ "๐’‰บ๐’„ด๐’„ท๐’Œ‹๐’Œจ", "pa-aแธซ-แธซu-u-ur" },
		{ "๐’‰บ๐’„ด๐’„ท๐’‚Š๐’ˆพ๐’€ญ๐’", "pa-aแธซ-แธซu-e-na-an-za" },
		{ "๐’‰บ๐’„ด๐’„ท๐’‚Š๐’‰Œ", "pa-aแธซ-แธซu-e-ni" },
		{ "๐’‰บ๐’„ด๐’„ท๐’‚Š๐’‰Œ๐’€‰", "pa-aแธซ-แธซu-e-ni-it" },
		{ "๐’‰บ๐’„ด๐’„ท๐’€ญ๐’‹ซ", "pa-aแธซ-แธซu-an-ta" },
		{ "๐’„ฉ๐’€ธ๐’‹ผ๐’…•๐’", "แธซa-aลก-te-er-za" },
		{ "๐’€ญ๐’‹ซ๐’Š๐’€ธ", "an-ta-ra-aลก" },
		{ "๐’‰บ๐’€€๐’„ฟ", "pa-a-i" },
		{ "๐’€€๐’€€๐’Š", "a-a-ra" },
		{ "๐’€€๐’Šญ๐’€€๐’€ญ๐’‹ซ๐’€ญ", "a-ลกa-a-an-ta-an" },
		{ "๐’€€๐’Šญ๐’€€๐’€ญ๐’‹ซ๐’€ธ", "a-ลกa-a-an-ta-aลก" },
		{ "๐’ˆ—๐’‘", hit_tag.tag_sumerogram("LUGAL") .. "-uลก" },
		{ "๐’ˆ—๐’Œ‘๐’‰ฟ๐’€ธ", hit_tag.tag_sumerogram("LUGAL") .. "-รบ-wa-aลก" },
		{ "๐’„ฏ๐’–๐’‚ต๐’€ธ", "แธซar-tรกg-ga-aลก" },
		{ "๐’„ฏ๐’–๐’„€", "แธซar-tรกg-gi" },
		{ "๐’๐’€Š๐’๐’‹ก๐’…€", "za-ap-za-kaโ‚„-ya" },
		{ "๐’„ญ๐’…–๐’Šญ๐’€ญ", "แธซi-iลก-ลกa-an" },
		{ "๐’„ฏ๐’–๐’„€๐’Œ", "แธซar-tรกg-ge-eลก" },
		{ "๐’‹ผ๐’Š‘๐’€‰๐’‹พ๐’Œ…๐’Œ‹๐’‰Œ๐’…–", "te-ri-it-ti-tu-u-ni-iลก" },
		{ "๐’บ๐’Œ“๐’‹ป๐’Š‘๐’…€๐’‹พ๐’…€๐’€ธ", "tรน-ut-tar-ri-ya-ti-ya-aลก" },
		{ "๐’€ญ๐’Œ…๐’‰ฟ๐’„ด๐’„ฉ๐’€ธ", "an-tu-wa-aแธซ-แธซa-aลก" },
		{ "๐’‹ป๐’†ช๐’‰ฟ๐’€ญ๐’ฃ", "tar-ku-wa-an-zi" },
		{ "๐’‹ซ๐’€€๐’Š’", "ta-a-ru" },
	}
	
	tests:iterate(test_tr, function(self, text, tr)
		self:equals(hit_tag.tag_hittite(text), hit_translit.tr(text, "hit", "Xsux"), hit_tag.tag_hittite_tr(tr))
	end)
end

local test_syls = {
	{ "aลก", { "a", "s" } },
	{ "แธซal", { "h", "l" } },
	{ "pal", { "p", "l" } },
	{ "bal", { "b", "l" } },
	{ "ลกir", { "s", "r" } },
	{ "แธซaลก", { "h", "s" } },
	{ "pรกt", { "p", "t" } },
	{ "gaโ‚…", { "g", "a" } },
	{ "kaโ‚„", { "k", "a" } },
	{ "inโ‚„", { "i", "n" } },
	{ "nรฉ", { "n", "e" } },
	{ "30", { "3", "0" } },
}

function tests:find_seg(func, index)
	return function(self, syl, lauts)
		self:equals(syl, func(syl), lauts[index])
	end
end

function tests:test_2_find_onset()
	tests:iterate(test_syls, tests:find_seg(hit_translit.find_onset, 1))
end

function tests:test_3_find_coda()
	tests:iterate(test_syls, tests:find_seg(hit_translit.find_coda, 2))
end

function tests:test_4_hash_sign()
	local test_signs = {
		{
			{ "it", "id", "et", "ed", hit = true },
			{
				{ "it", o = "i", c = "t" },
				{ "id", o = "i", c = "d" },
				{ "et", o = "e", c = "t" },
				{ "ed", o = "e", c = "d" },
				o_hash = 6,
				c_hash = 192,
				hit = true,
			}
		},
	}
	
	tests:iterate(test_signs, function(self, sign, initialized)
		self:equals_deep("-", hit_translit.hash_sign(sign), initialized)
	end)
end

function tests:test_5_copy_sign()
	local test_signs = {
		{
			"๐’„ซ",
			{
				{ "paลก", c = "s", o = "p" },
				{ "pรนลก", c = "s", o = "p" },
				{ "piลก", c = "s", o = "p" },
				{ "biลก", c = "s", o = "b" },
				{ "kir", c = "r", o = "k" },
				{ "gir", c = "r", o = "g" },
				{ "gir", c = "r", o = "g" },
				c_hash = 69632,
				hit = true,
				o_hash = 816
			}
		},
	}
	
	tests:iterate(test_signs, function(self, sign, init_copy)
		self:equals_deep("-", hit_translit.copy_sign(sign), init_copy)
	end)
end

return tests