-- Unit tests for . Click talk page to run tests.
local moduleName = 'Roman/sandbox' -- assigning this to a variable as it is later used to generate an #invoke statement.local mainFuncName = 'main'local mm = require('Module:' .. moduleName)local suite = require('Module:UnitTests')
function suite.buildInvocation(funcName, args) args = args or local argsClone = mw.clone(args) -- Build a module invocation equivalent to the args table. Taken from . -- Numbered args first. local ret = ''end
function suite:getInvokeResult(funcName, args, convertNumber) -- Unless convertNumber is false, the number is converted to a number, if possible, on re-entry to Lua. args = args or local invocation = self.buildInvocation(funcName, args) local result = self.frame:preprocess(invocation) if convertNumber ~= false and tonumber(result) then return tonumber(result) else return result endend
function suite:assertInvokeEquals(expected, funcName, args, convertNumber) args = args or local invokeResult = self:getInvokeResult(funcName, args, convertNumber) self:preprocess_equals(invokeResult, expected)end
function suite:assertInvokeEqual(funcName, testTable, convertNumber) testTable = testTable or local expected = testTable[1] local args = testTable[2] or self:assertInvokeEquals(expected, funcName, args, convertNumber)end
function suite:assertInvokeEqualMany(funcName, testTables, convertNumber) for i, testTable in ipairs(testTables) do self:assertInvokeEqual(funcName, testTable, convertNumber) endend
function suite:test_genericNumbers local args = -- unsure how to test cases with overline self:assertInvokeEqualMany('main', args)end
function suite:test_outOfRangeNumbers local args = self:assertInvokeEqualMany('main', args)end
function suite:test_MessageArg local args = self:assertInvokeEqualMany('main', args)end
function suite:test_MessageArgWithFractionArg -- Note, 'fraction=yes' before 'too big' cannot happen with the template local args = self:assertInvokeEqualMany('main', args)end
--
--
return suite