Jump to content

Module:Sandbox/Erutuon/testcases

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Erutuon (talk | contribs) at 23:54, 3 July 2018 (fixed; more examples). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
local p = require "Module:UnitTests"
local parse_IETF = require "Module:Sandbox/Erutuon".parse_IETF

function p:test_parse_IETF()
	local examples = {
		{ "ru", { language = "ru" } },
		{ "ru-Latn", { language = "ru", script = "Latn" } },
		{ "ru-blahblahblah", { language = "ru", error = "invalid subtag", invalid = "blahblahblah" } },
		{ "ru-Latn-blahblahblah", { language = "ru", script = "Latn", error = "invalid subtag", invalid = "blahblahblah" } },
	}
	
	self:iterate(
		examples,
		function (self, IETF_code, expected)
			self:equals_deep(IETF_code, parse_IETF(IETF_code), expected)
		end)
end

return p