مندرجات کا رخ کریں

ماڈیول:fa-IPA/testcases

ویکی لغت سے

لوا خطا package.lua میں 80 سطر پر: module 'Module:string utilities' not found۔


local tests = require("Module:UnitTests")
local m_IPA = require("Module:fa-IPA")

local sc_fa = require("Module:scripts").getByCode("fa-Arab")
local sc_tg = require("Module:scripts").getByCode("Cyrl")
local lang_fa = require("Module:languages").getByCode("fa")
local lang_tg = require("Module:languages").getByCode("tg")

function link(term)
    return require("Module:links").full_link {
        term = term,
        lang = lang_fa,
        sc = sc_fa
    }
end

function link_tg(term)
    return require("Module:links").full_link {
        term = term,
        lang = lang_tg,
        sc = sc_tg
    }
end

local function tag_IPA(IPA)
	return '<span class="IPA">' .. IPA .. '</span>'
end

function tests:check_output_fa(term, romanisation, expected)
	self:equals(
		link(term),
		tag_IPA(m_IPA.fa_IPA(romanisation)),
		tag_IPA(expected)
	)
end

function tests:check_output_fa_cls(term, romanisation, expected)
	self:equals(
		link(term),
		tag_IPA(m_IPA.fa_cls_IPA(romanisation)),
		tag_IPA(expected)
	)
end

function tests:check_output_tg(term, romanisation, expected)
	self:equals(
		link_tg(term),
		tag_IPA(m_IPA.tg_IPA(romanisation)),
		tag_IPA(expected)
	)
end

function tests:check_output_prs(term, romanisation, expected)
	self:equals(
		link(term),
		tag_IPA(m_IPA.prs_IPA(romanisation)),
		tag_IPA(expected)
	)
end

function tests:test_classical_persian()
	examples = {
		{ "خوش", "xwaš", "xʷaʃ"},
		{ "ابرنواختر", "abar nav axtar", "abaɾ naw axtaɾ"},
		{ "ابراهیم", "ibrāhīm", "ibɾɑːhiːm"},
		{ "امام", "imām", "imɑːm"},
		{ "پیشوا", "pēšwā", "peːʃwɑː"},
		{ "نو", "naw", "naw"},
		{ "مستعمره", "musta'mara", "mustaʔmaɾa"},
	}
--[[	Copy the following to add more examples:
		{ "", "", ""},
]]
	
	tests:iterate(examples, "check_output_fa_cls")
end

function tests:test_dari_persian()
	examples = {
		{ "خوش", "xwaš", "xoʃ"},
		{ "ابرنواختر", "abar-nav-axtar", "abaɾ naw axtaɾ"},
		{ "ابراهیم", "ibrāhīm", "ebɾɒːhiːm"},
		{ "امام", "imām", "emɒːm"},
		{ "پیشوا", "pēšwā", "peːʃwɒː"},
		{ "نو", "naw", "naw"},
		{ "مستعمره", "musta'mara", "mostaʔmaɾa"},
	}
--[[	Copy the following to add more examples:
		{ "", "", ""},
]]
	
	tests:iterate(examples, "check_output_prs")
end

function tests:test_iranian_persian()
	examples = {
		{ "خوش", "xwaš", "xoʃ"},
		{ "ابرنواختر", "abar nav axtar", "æbæɾ now æxtæɾ"},
		{ "ابراهیم", "ibrāhīm", "ebɾɒːhiːm"},
		{ "امام", "imām", "emɒːm"},
		{ "پیشوا", "pēšwā", "piːʃvɒː"},
		{ "نو", "naw", "now"},
		{ "مستعمره", "musta'mara", "mostæʔmæɾe"},
	}
--[[	Copy the following to add more examples:
		{ "", "", ""},
]]
	
	tests:iterate(examples, "check_output_fa")
end

function tests:test_tajik()
	examples = {
		{ "хуш", "xwaš", "xʊʃ"},
		{ "абарнавахтар", "abarnawaxtar", "abaɾnavaxtaɾ"},
		{ "Иброҳим", "ibrāhīm", "ɪbɾɔhɪm"},
		{ "имом", "imām", "ɪmɔm"},
		{ "пешво", "pēšwā", "peʃvɔ"},
		{ "нав", "naw", "nav"},
		{ "مستعمره", "musta'mara", "mʊstaʔmaɾa"},
	}
--[[	Copy the following to add more examples:
		{ "", "", ""},
]]
	
	tests:iterate(examples, "check_output_tg")
end

return tests