Difference between revisions of "Module:Arguments/testcases"
Jump to navigation
Jump to search
blackwiki>Mr. Stradivarius (test) |
blackwiki>Mr. Stradivarius (add some test structures) |
||
| Line 3: | Line 3: | ||
local suite = ScribuntoUnit:new() | local suite = ScribuntoUnit:new() | ||
| − | + | function suite.expandTestTemplate(funcName) | |
| − | function suite | + | local frame = mw.getCurrentFrame() |
| − | + | local val = frame:preprocess('{{Module talk:Arguments/testTemplate|function=' .. funcName .. '}}') | |
| − | + | return val | |
| + | end | ||
| − | + | function suite.createInvokeFunction(funcName, key, options) | |
| + | return function (frame) | ||
| + | options = options or {} | ||
| + | local args = getArgs(frame, options) | ||
| + | return args[key] | ||
| + | end | ||
| + | end | ||
| − | function | + | function suite.main(frame) |
local args = getArgs(frame) | local args = getArgs(frame) | ||
return args[1] | return args[1] | ||
end | end | ||
| − | function | + | function suite.test() |
local frame = mw.getCurrentFrame() | local frame = mw.getCurrentFrame() | ||
local mainVal = frame:preprocess('{{Module talk:Arguments/testInvoke|function=main}}') | local mainVal = frame:preprocess('{{Module talk:Arguments/testInvoke|function=main}}') | ||
| Line 21: | Line 28: | ||
end | end | ||
| − | return | + | return suite |
Revision as of 23:52, 9 December 2013
Documentation for this module may be created at Module:Arguments/testcases/doc
local getArgs = require('Module:Arguments').getArgs
local ScribuntoUnit = require('Module:ScribuntoUnit')
local suite = ScribuntoUnit:new()
function suite.expandTestTemplate(funcName)
local frame = mw.getCurrentFrame()
local val = frame:preprocess('{{Module talk:Arguments/testTemplate|function=' .. funcName .. '}}')
return val
end
function suite.createInvokeFunction(funcName, key, options)
return function (frame)
options = options or {}
local args = getArgs(frame, options)
return args[key]
end
end
function suite.main(frame)
local args = getArgs(frame)
return args[1]
end
function suite.test()
local frame = mw.getCurrentFrame()
local mainVal = frame:preprocess('{{Module talk:Arguments/testInvoke|function=main}}')
return mainVal
end
return suite