ข้ามไปเนื้อหา

มอดูล:languages/testcases

จาก วิกิพจนานุกรม พจนานุกรมเสรี

22 of 57 tests failed. (refresh)

TextExpectedActual
testcases for getCategoryName:
FailedenEnglish languageภาษาอังกฤษ
FailedafAfrikaans languageภาษาแอฟริคานส์
FailedavAvar languageภาษาอะวาร์
FailedhtHaitian Creole languageภาษาครีโอลเฮติ
FailedaseAmerican Sign Languageภาษามืออเมริกัน
TextExpectedActual
testcases for getFamily:
Passedengmw-anggmw-ang
Passedhtcrpcrp
Passedasesgnsgn
TextExpectedActual
testcases for getFull:
Passeddedede
Passedde-ATdede
Passedde-AT-viedede
Script error during testing: มอดูล:languages/testcases:192: attempt to call method 'getFull' (a nil value)
stack traceback:
	[C]: in function 'getFull'
	มอดูล:languages/testcases:192: in function 'func'
	มอดูล:UnitTests:295: in function 'iterate'
	มอดูล:languages/testcases:191: in function <มอดูล:languages/testcases:183>
	(tail call): ?
	[C]: in function 'xpcall'
	มอดูล:UnitTests:369: in function <มอดูล:UnitTests:328>
	(tail call): ?
	mw.lua:527: in function <mw.lua:507>
	[C]: ?
	[C]: in function 'expandTemplate'
	mw.lua:333: in function 'expandTemplate'
	มอดูล:documentation:857: in function 'chunk'
	mw.lua:527: in function <mw.lua:507>
	[C]: ?
TextExpectedActual
testcases for getOtherNames:
Failedht{"Creole", "Haitian", "Kreyòl"}{"ครีโอลไฮติ", "ไฮติครีโอล", "เฮติครีโอล", "ครีโอล", "Haitian Creole", "Creole", "Haitian", "Kreyòl"}
Failedase{"Ameslan", "ASL"}{"American Sign Language", "Ameslan", "ASL"}
TextExpectedActual
testcases for getScriptCodes:
Passeden{"Latn", "Brai", "Shaw", "Dsrt"}{"Latn", "Brai", "Shaw", "Dsrt"}
Passedht{"Latn"}{"Latn"}
Passedase{"Sgnw"}{"Sgnw"}
TextExpectedActual
testcases for getWikidataItem:
PassedenQ1860Q1860
PassedeoQ143Q143
Passedaql-proQ18389588Q18389588
Failedmkh-ban-pro(nil)Q116773189
TextExpectedActual
testcases for getWikipediaArticle:
FailedenEnglish languageภาษาอังกฤษ
FailedafAfrikaansภาษาอาฟรีกานส์
PassedaeAvestanAvestan
FailedhtHaitian Creoleภาษาครีโอลเฮติ
FailedaseAmerican Sign Languageภาษามืออเมริกัน
FaileddvMaldivian languageภาษามัลดีฟส์
FailedeoEsperantoภาษาเอสเปรันโต
FailedgohOld High Germanภาษาเยอรมันสูงเก่า
TextExpectedActual
testcases for makeDisplayText:
Passedஸ்ரீகாகுளம் (ทมิฬ, ta)ஶ்ரீகாகுளம்ஶ்ரீகாகுளம்
TextExpectedActual
testcases for makeEntryName:
Passedhūmānitās (ละติน, la)humanitashumanitas
Passedcoëō (ละติน, la)coeocoeo
Passedàzàhàr̃iyyā̀ (เฮาซา, ha)azahariyyaazahariyya
Passedalas! (อังกฤษ, en)alasalas
Passed¿cómo te llamas? (สเปน, es)cómo te llamascómo te llamas
Passedӓ ё (รัสเซีย, ru)а ёа ё
Passed¿ ? (สเปน, es)¿ ?¿ ?
Passed¡ ! (สเปน, es)¡ !¡ !
Passedmais bien sûr ! (ฝรั่งเศส, fr)mais bien sûrmais bien sûr
Passed¡ (ร่วม, mul)¡¡
PassedΠηληῐ̈ᾰ́δης (กรีกโบราณ, grc)ΠηληϊάδηςΠηληϊάδης
Passedالعَرَبِيَّة (อาหรับ, ar)العربيةالعربية
Passedٱ (อาหรับ, ar)ٱٱ
Passedـُ (อาหรับ, ar)ـُـُ
Passed치〯 (เกาหลีกลาง, okm)
script-specific (no change when wrong script code is provided)
Passedایشؽق (อาเซอร์ไบจาน, az)ایشیقایشیق
Passedایشؽق (อาเซอร์ไบจาน, az), tableایشؽقایشؽق
TextExpectedActual
testcases for makeSortKey:
diacritic removal
PassedΠηληϊάδης Αἶνος (กรีกโบราณ, grc)ΠΗΛΗΙΑΔΗΣ ΑΙΝΟΣΠΗΛΗΙΑΔΗΣ ΑΙΝΟΣ
Passedshį́į́dą́ą́ʼ (นาวาโฮ, nv)SIIDAAZSIIDAAZ
dedicated sortkey modules
FailedTuyên ngôn toàn thế giới về nhân quyền của Liên Hợp Quốc (เวียดนาม, vi)TUYEN NGON TOAN! THE% GIOI% VE! NHAN QUYEN! CUA# LIEN HOP& QUOC%TUYEN NGON TOAN! THE% GIOI% VE! NHAN QUYEN! CUA# LIEN HOP& QUOC%
Failed命裡有時終須有,命裡無時莫強求 (จีน, zh)口05衣07月02日06糸05頁03月02,口05衣07火08日06艸07弓08水02口05衣07月02日06糸05頁03月02口05衣07火08日06艸07弓08水02
Passed⿱𡩧⿺進⿰貝招 (จีน, zh)宀37宀37
dotted and dotless i
Passedİzmir (ตุรกี, tr)IZMIRIZMIR
Passedışık (ตุรกี, tr)ISIKISIK
TextExpectedActual
testcases for makeWikipediaLink:
Faileden[[w:English language|English]][[w:ภาษาอังกฤษ|ภาษาอังกฤษ]]
Failedaf[[w:Afrikaans|Afrikaans]][[w:ภาษาอาฟรีกานส์|ภาษาแอฟริคานส์]]
Failedae[[w:Avestan|Avestan]][[w:Avestan|ภาษาอเวสตะ]]
TextExpectedActual
testcases for toJSON:
Faileden-toJSON{"ancestors" : [ "en-ear" ], "code" : "en", "canonicalName" : "English", "wikimediaLanguages" : [ "en", "simple" ], "aliases" : [ "Modern English", "New English" ], "type" : [ "language", "full", "regular" ], "wikidataItem" : "Q1860", "varieties" : [ "Polari", "Yinglish" ], "scripts" : [ "Latn", "Brai", "Shaw", "Dsrt" ], "family" : "gmw-ang", "otherNames" : [], "categoryName" : "English language", "nonEtymological" : "en"}{"ancestors" : ["en-ear"], "code" : "en", "canonicalName" : "อังกฤษ", "wikimediaLanguages" : ["en", "simple"], "full" : "en", "aliases" : ["อังกฤษใหม่", "English", "Modern English", "New English"], "wikidataItem" : "Q1860", "varieties" : ["Polari", "Yinglish"], "scripts" : ["Latn", "Brai", "Shaw", "Dsrt"], "family" : "gmw-ang", "otherNames" : [], "categoryName" : "ภาษาอังกฤษ", "type" : ["language", "full", "regular"]}

local tests = require("Module:UnitTests")

local m_languages = require("Module:languages")
local tag = require("Module:script utilities").tag_text

-- Auto-create language objects: langs.en -> language object for English.
local langs = require ("Module:languages/cache")

local get_script = require("Module:scripts").getByCode

function tests:check(funcName)
	-- Use English language object to test for existence of function.
	local func = langs.en[funcName] or error("No function named " .. funcName .. " in language object.")
	local options = {}
	local function show_remaining_arguments(...)
		if select("#", ...) > 0 then
			local output = require "Module:array"()
			for _, arg in ipairs {...} do
				output:insert(", ")
				output:insert(tostring(arg))
			end
			return output:concat()
		else
			return ""
		end
	end
	return function(self, lang, example, expected, ...)
		function options.display(text)
			return tag(text, lang)
		end
		self:equals(tag(example, lang) .. " (" .. lang:getCanonicalName() .. ", <code>" .. lang:getCode() .. "</code>)" .. show_remaining_arguments(...),
			func(lang, example, ...),
			expected,
			options)
	end
end

function tests:test_makeEntryName()
	local examples = {
		{ langs.la, "hūmānitās", "humanitas" },
		{ langs.la, "coëō", "coeo" },
		{ langs.ha, "àzàhàr̃iyyā̀", "azahariyya" },
		{ langs.en, "alas!", "alas" },
		{ langs.es, "¿cómo te llamas?", "cómo te llamas" },
		{ langs.ru, "ӓ ё", "а ё" },
		{ langs.es, "¿ ?", "¿ ?" },
		{ langs.es, "¡ !", "¡ !" },
		{ langs.fr, "mais bien sûr !", "mais bien sûr" },
		{ langs.mul, "¡", "¡" },
		{ langs.grc, "Πηληῐ̈ᾰ́δης", "Πηληϊάδης" },
		{ langs.ar, "العَرَبِيَّة", "العربية" },
		{ langs.ar, "ٱ", "ٱ" }, -- special case: alif waṣla
		{ langs.ar, "ـُ", "ـُ" }, -- special case: taṭwīl with vowel diacritic
		{ langs.okm, "치〯", "치" },
		"script-specific (no change when wrong script code is provided)",
		{ langs.az, "ایشؽق", "ایشیق" },
		{ langs.az, "ایشؽق", "ایشؽق", get_script("Cyrl") }, -- no change with wrong script code
	}
	
	self:iterate(examples, self:check("makeEntryName"))
end

function tests:test_makeDisplayText()
	local examples = {
		{ langs.ta, "ஸ்ரீகாகுளம்", "ஶ்ரீகாகுளம்" },
	}
	
	self:iterate(examples, self:check("makeDisplayText"))
end

function tests:test_makeSortKey()
	local examples = {
		"diacritic removal",
		{ langs.grc, "Πηληϊάδης Αἶνος", "ΠΗΛΗΙΑΔΗΣ ΑΙΝΟΣ" },
		{ langs.nv, "shį́į́dą́ą́ʼ", "SIIDAAZ" },
		"dedicated sortkey modules",
		{ langs.vi, "Tuyên ngôn toàn thế giới về nhân quyền của Liên Hợp Quốc", "TUYEN NGON TOAN! THE% GIOI% VE! NHAN QUYEN! CUA# LIEN HOP& QUOC%" },
		{ langs.zh, "命裡有時終須有,命裡無時莫強求", "口05衣07月02日06糸05頁03月02,口05衣07火08日06艸07弓08水02" },
		{ langs.zh, "⿱𡩧⿺進⿰貝招", "宀37" },
		"dotted and dotless i",
		{ langs.tr, "İzmir", "IZMIR" },
		{ langs.tr, "ışık", "ISIK" }
	}
	self:iterate(examples, self:check("makeSortKey"))
end

function tests:test_getWikipediaArticle()
	local examples = {
		{"en", "English language"},
		{"af", "Afrikaans"},
		{"ae", "Avestan"},
		{"ht", "Haitian Creole"},
		{"ase", "American Sign Language"},
		{"dv", "Maldivian language"},
		{"eo", "Esperanto"},
		{"goh", "Old High German"},
	}

	self:iterate(examples, function(self, lang, expected)
		self:equals(lang, langs[lang]:getWikipediaArticle(), expected)
	end)
end

function tests:test_makeWikipediaLink()
	local examples = {
		{"en", "[[w:English language|English]]"},
		{"af", "[[w:Afrikaans|Afrikaans]]"},
		{"ae", "[[w:Avestan|Avestan]]"},
	}
	
	self:iterate(examples, function(self, lang, expected)
		self:equals(lang, langs[lang]:makeWikipediaLink(), expected, {nowiki=1})
	end)
end

function tests:test_getFamily()
	local examples = {
		{"en", "gmw-ang"},
		{"ht", "crp"},
		{"ase", "sgn"}
	}

	self:iterate(examples, function(self, lang, expected)
		self:equals(lang, langs[lang]:getFamily():getCode(), expected)
	end)
end

function tests:test_getScriptCodes()
	local examples = {
		{"en", {"Latn", "Brai", "Shaw", "Dsrt"}},
		{"ht", {"Latn"}},
		{"ase", {"Sgnw"}}
	}

	self:iterate(examples, function(self, lang, expected)
		self:equals_deep(lang, langs[lang]:getScriptCodes(), expected, {})
	end)
end

function tests:test_getOtherNames()
	local examples = {
		{"ht", {"Creole", "Haitian", "Kreyòl"}},
		{"ase", {"Ameslan", "ASL"}}
	}

	self:iterate(examples, function(self, lang, expected)
		self:equals_deep(lang, langs[lang]:getOtherNames(), expected, {})
	end)
end

function tests:test_getCategoryName()
	local examples = {
		{"en", "English language"},
		{"af", "Afrikaans language"},
		{"av", "Avar language"},
		{"ht", "Haitian Creole language"},
		{"ase", "American Sign Language"}
	}

	self:iterate(examples, function(self, lang, expected)
		self:equals(lang, langs[lang]:getCategoryName(), expected)
	end)
end

function tests:test_getWikidataItem()
	local examples = {
		{"en", "Q1860"},
		{"eo", "Q143"},
		{"aql-pro", "Q18389588"},
		{"mkh-ban-pro", nil},
		
	}

	self:iterate(examples, function(self, lang, expected)
		self:equals(lang, langs[lang]:getWikidataItem(), expected)
	end)
end

function tests:test_toJSON() 
	self:equals('en-toJSON', langs.en:toJSON(), [[{"ancestors" : [ "en-ear" ], "code" : "en", "canonicalName" : "English", "wikimediaLanguages" : [ "en", "simple" ], "aliases" : [ "Modern English", "New English" ], "type" : [ "language", "full", "regular" ], "wikidataItem" : "Q1860", "varieties" : [ "Polari", "Yinglish" ], "scripts" : [ "Latn", "Brai", "Shaw", "Dsrt" ], "family" : "gmw-ang", "otherNames" : [], "categoryName" : "English language", "nonEtymological" : "en"}]])
end

function tests:test_getFull()
	local examples = {
		{ "de", "de" },
		{ "de-AT", "de" },
		{ "de-AT-vie", "de" },
		{ "gem", "gem" },
	}

	self:iterate(examples, function(self, lang, expected)
		self:equals(lang, langs[lang]:getFull():getCode(), expected)
	end)
end

for k, v in require "Module:table".sortedPairs(tests) do
	if type(k) == "string" and k:sub(1, 5) == "test_" then
		local new_key = k:gsub('^test_(.+)$', 'testcases for <code>%1</code>')
		tests[new_key], tests[k] = v, nil
	end
end

return tests