Module:User:Oyunqi/ug-common2/testcases

From Wiktionary, the free dictionary
Jump to navigation Jump to search

1 of 27 tests failed. (refresh)

TextExpectedActualDiffers atComments
test_checkCentral:
Passedپېئىلbackback
Passedبىلىمfrontfront
TextExpectedActualDiffers atComments
test_checkWord2:
open auto
Passedبالابالىلاربالىلار{{ug-headword}}
Passedئالمائالمىلارئالمىلار{{ug-headword}}
Passedئائىلەئائىلىلەرئائىلىلەر{{ug-headword}}
Passedئۇئۇلارئۇلار{{ug-headword}}
Passedئىككىئىككىلەرئىككىلەر{{ug-headword}}
open no change
Passedبالابالالاربالالار{{ug-headword|change=no}}
close auto
Passedناننانلارنانلار{{ug-headword}}
Passedتاغتاغلارتاغلار{{ug-headword}}
Passedقويقويلارقويلار{{ug-headword}}
Passedگۈلگۈللەرگۈللەر{{ug-headword}}
Passedدەزمالدەزماللاردەزماللار{{ug-headword}}
Passedپەيتونپەيتونلارپەيتونلار{{ug-headword}}
Passedئوتۇنئوتۇنلارئوتۇنلار{{ug-headword}}
Passedئەخمەقئەخمەقلەرئەخمەقلەر{{ug-headword}}
ending with چە
Passedزىخچەزىخچىلارزىخچىلار{{ug-headword}}
Passedقىرغىزچەقىرغىزچىلارقىرغىزچىلار{{ug-headword}}
Passedئۈنچەئۈنچىلەرئۈنچىلەر{{ug-headword}}
Passedغۇنچەغۇنچىلارغۇنچىلار{{ug-headword}}
central auto
Passedبىخبىخلاربىخلار{{ug-headword}}
Passedتىلتىللارتىللار{{ug-headword}}
nouns exception auto
Passedبىلىمبىلىملەربىلىملەر{{ug-headword}}
Passedئىلىمئىلىملەرئىلىملەر{{ug-headword}}
Passedتىزتىزلارتىزلار{{ug-headword}}
Passedپېئىلپېئىللارپېئىللار{{ug-headword}}
Failedۋېلسىپىتۋېلسىپىتلار(nil)N/A{{ug-headword}}

Lua error in Module:module_categorization at line 298: Could not infer any languages or scripts from root pagename 'User:Oyunqi'


-- Unit tests for [[Module:User:Oyunqi/ug-common2]].
local p = require('Module:UnitTests')
local m = require('Module:User:Oyunqi/ug-common2')
local m2 = require('Module:User:Oyunqi/ug-headword2')
local test_nouns = require('Module:User:Oyunqi/ug-common/testcases/data')
--local test_nouns2 = require('Module:User:Oyunqi/ug-common2/testcases/data2')
local test_nouns2 = require('Module:ug-common/testcases/data')


function p:make_plural_noun(singular, vv)
	local base, v, c = m.getLast(singular)
	vv = vv or v
	local term = base .. vv .. c
	local tongue = m.checkTongue(singular)
	if tongue == "front" then
		return term .. "لەر"
	elseif tongue == "back" then
		return term .. "لار"
	end
	return nil
end

local function link(word)
	return "[[" .. word .. "#Uyghur|" .. word .. "]]"
end

local function get_Tempalte(vv, change)
	local par = ""
	if vv and vv ~= "" then par = par .. "|" .. vv  end
	if change and change ~= "" then par = par .. "|change=" .. change end
	str = "<code><b>{{ug-headword".. mw.text.nowiki(par) .."}}</b></code>"
    return str
end

local function get_params(params) 
	local par = {}
	params = mw.ustring.gsub(params, "|", " ") 
	i=1
	for token in mw.ustring.gmatch(params,"[^%s]+") do
		t = mw.ustring.gsub(token, "=", " ")
		j =1
		ts={} 
		for tt in mw.ustring.gmatch(t,"[^%s]+") do
			ts[j]=tt
			j=j+1
		end

		if j ==3 then
			par[ts[1]] =ts[2]
		else
			par[i] = ts[1]
			i=i+1
		end
	end
	return par
end

function p:check_noun_plurals(singular, expected_plural)
	if expected_plural.plural then
		local params = {}
		if expected_plural.params then 
			params = get_params(expected_plural.params)
		end
		local change = params["change"] or "yes"
		local vv = params[1]
		local test = m2.make_plural_noun(singular, vv, change)
		local comment = get_Tempalte(vv, change)
		self:equals(link(singular),
			test,
			expected_plural.plural,
			{comment = get_Tempalte(params[1], params["change"])})
	end
end

function p:test_checkWord2()
	p:iterate(test_nouns2, "check_noun_plurals")
end

function p:test_checkCentral()
	local ttt = m.checkCentral("پېئىل")
	self:equals("پېئىل", ttt, "back")
	ttt = m.checkCentral("بىلىم")
	self:equals("بىلىم", ttt, "front")
end

function p:ttest_checkWord()
	--getlast
	local base, v, c = m.getLast("جۇڭخۇا")
	self:equals("جۇڭخۇا", base .. "-" .. v .. "-" .. c , "جۇڭخ-ۇا-")
	
	--check
	local ttt = m.checkTongue("ئالما")
	--local ttt = m.checkFrontBack("ئالما")
	self:equals("ئالما", ttt, "back")
	ttt = m.checkCentral("بىلىم")
	self:equals("بىلىم", ttt, "front")
	local pl = self:make_plural_noun("ئالما","ى")
	self:equals("ئالما", pl, "ئالمىلار")
	
	--head
	pl = m2.make_plural_noun("ئالما","ى", "yes")
	self:equals("ئالما", pl, "ئالمىلار")

	--test all
	for name, data in pairs(test_nouns) do
		local plural = m2.make_plural_noun(name, "", "yes")
		self:equals(name, plural, data.plural)
	end
	
end

return p