3 of 8 tests failed. (refresh)

TextExpectedActual
test_getCanonicalName:
PassedroaRomanceRomance
FailedgemGermanicජර්මානු
TextExpectedActual
test_getWikidataItem:
PassedroaQ19814Q19814
PassedgemQ21200Q21200
TextExpectedActual
test_makeWikipediaLink:
Passedroa[[w:Romance languages|Romance]][[w:Romance languages|Romance]]
Failedgem[[w:Germanic languages|Germanic]][[w:Germanic languages|ජර්මානු]]
Passedsgn-jsl[[w:Japanese Sign Language family|Japanese Sign Languages]][[w:Japanese Sign Language family|Japanese Sign Languages]]
TextExpectedActual
test_toJSON:
Failedroa-JSON{"type" : "family", "wikidataItem" : "Q19814", "code" : "roa", "canonicalName" : "Romance", "otherNames" : ["Romanic", "Latin", "Neolatin", "Neo-Latin"], "categoryName" : "Romance languages", "family" : "itc"}{"type" : [ "family", "full", "regular" ], "code" : "roa", "canonicalName" : "Romance", "full" : "roa", "aliases" : [ "Romanic", "Latin", "Neolatin", "Neo-Latin" ], "wikipediaArticle" : "Romance languages", "wikidataItem" : "Q19814", "varieties" : [], "protoLanguage" : "la", "family" : "itc", "otherNames" : [], "categoryName" : "Romance භාෂා"}

local tests = require("Module:UnitTests")

local getByCode = require("Module:families").getByCode

local families = {}
setmetatable(families, { -- Auto-create family objects: families.roa -> family object for Romance.
	__index = function(self, key)
		local family = getByCode(key) or error("No language with code " .. key .. ".")
		self[key] = family
		return family
	end
})

function tests:test_getCanonicalName()
	local examples = {
		{"roa", "Romance"},
		{"gem", "Germanic"},
	}

	self:iterate(examples, function(self, code, expected)
		self:equals(code, families[code]:getCanonicalName(), expected)
	end)
end

function tests:test_makeWikipediaLink()
	local examples = {
		{"roa", "[[w:Romance languages|Romance]]"},
		{"gem", "[[w:Germanic languages|Germanic]]"},
		{"sgn-jsl", "[[w:Japanese Sign Language family|Japanese Sign Languages]]"},
	}
	
	self:iterate(examples, function(self, code, expected)
		self:equals(code, families[code]:makeWikipediaLink(), expected, {nowiki=1})
	end)
end

function tests:test_getWikidataItem()
	local examples = {
		{"roa", "Q19814"},
		{"gem", "Q21200"},
	}

	self:iterate(examples, function(self, code, expected)
		self:equals(code, families[code]:getWikidataItem(), expected)
	end)
end

function tests:test_toJSON()
	self:equals('roa-JSON', families.roa:toJSON(), [[{"type" : "family", "wikidataItem" : "Q19814", "code" : "roa", "canonicalName" : "Romance", "otherNames" : ["Romanic", "Latin", "Neolatin", "Neo-Latin"], "categoryName" : "Romance languages", "family" : "itc"}]])
end

return tests
"https://si.wiktionary.org/w/index.php?title=Module:families/testcases&oldid=32451" වෙතින් සම්ප්‍රවේශනය කෙරිණි