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

ویکی لغت سے

All tests passed. (refresh)

Text Expected Actual Comments
test_classical_persian:
Passed خوش xʷaʃ xʷaʃ
Passed ابرنواختر abaɾ naw axtaɾ abaɾ naw axtaɾ
Passed ابراهیم ibɾɑːhiːm ibɾɑːhiːm
Passed امام imɑːm imɑːm
Passed پیشوا peːʃwɑː peːʃwɑː
Passed نو naw naw
Passed مستعمره mustaʔmaɾa mustaʔmaɾa
Text Expected Actual Comments
test_dari_persian:
Passed خوش xoʃ xoʃ
Passed ابرنواختر abaɾ naw axtaɾ abaɾ naw axtaɾ
Passed ابراهیم ebɾɒːhiːm ebɾɒːhiːm
Passed امام emɒːm emɒːm
Passed پیشوا peːʃwɒː peːʃwɒː
Passed نو naw naw
Passed مستعمره mostaʔmaɾa mostaʔmaɾa
Text Expected Actual Comments
test_iranian_persian:
Passed خوش xoʃ xoʃ
Passed ابرنواختر æbæɾ now æxtæɾ æbæɾ now æxtæɾ
Passed ابراهیم ebɾɒːhiːm ebɾɒːhiːm
Passed امام emɒːm emɒːm
Passed پیشوا piːʃvɒː piːʃvɒː
Passed نو now now
Passed مستعمره mostæʔmæɾe mostæʔmæɾe
Text Expected Actual Comments
test_tajik:
Passed хуш xʊʃ xʊʃ
Passed абарнавахтар abaɾnavaxtaɾ abaɾnavaxtaɾ
Passed Иброҳим ɪbɾɔhɪm ɪbɾɔhɪm
Passed имом ɪmɔm ɪmɔm
Passed пешво peʃvɔ peʃvɔ
Passed нав nav nav
Passed مستعمره mʊstaʔmaɾa mʊstaʔmaɾa

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