Module:User:Erutuon/zh-han/sandbox/testcases

local tests = require "Module:UnitTests"

local as_and_sn_codes = { c = 'simplified Chinese', t = 'traditional Chinese', m = 'mainland Chinese', j = 'Japanese', k = 'Korean', }

local sorted_pairs = require "Module:table".sortedPairs local function print_parameters(parameters) local output = require "Module:array" for k, v in sorted_pairs(parameters) do output:insert(mw.text.nowiki "|" .. k .. "=" .. v)	end return output:concat end

local function print_result(result) local output = require "Module:array" for k, v in sorted_pairs(result) do output:insert((as_and_sn_codes[k] or k) .. ": " .. v)	end return output:concat(", ") end

function tests:test_sn local examples = { { { sn = 4, ["sncj+"] = 3 }, { t = 4, k = 4, c = 3, j = 3 } }, }	self:iterate(		examples,		function (self, parameters, expected)			mw.logObject(parameters, "parameters")			mw.logObject(expected, "expected")			self:equals(print_parameters(parameters), print_result(expected), print_result({}))		end) end

return tests