Module:Template test case: Difference between revisions

Jump to navigation Jump to search
Content added Content deleted
(add the option defaults before we compress the table to fix the case where the first numbered argument is higher than 2)
(Don't export the table and nowiki functions. At the moment the Lua interfaces don't make much sense, and rewriting the module to include nice Lua interfaces would probably be a lot of wasted work, as Lua modules will generally use Lua-based test cases.)
Line 474: Line 474:


-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- Bridge functions
-- Exports
--
-- These functions translate template arguments into forms that can be accepted
-- by the different classes, and return the results.
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------


local p = {}
local bridge = {}


function p.table(args, cfg)
function bridge.table(args, cfg)
cfg = cfg or mw.loadData(DATA_MODULE)
cfg = cfg or mw.loadData(DATA_MODULE)


Line 508: Line 511:
end
end


function p.nowiki(args, cfg)
function bridge.nowiki(args, cfg)
cfg = cfg or mw.loadData(DATA_MODULE)
cfg = cfg or mw.loadData(DATA_MODULE)


Line 518: Line 521:
return tostring(testCaseObj)
return tostring(testCaseObj)
end
end

-------------------------------------------------------------------------------
-- Exports
-------------------------------------------------------------------------------

local p = {}


function p.main(frame, cfg)
function p.main(frame, cfg)
Line 552: Line 561:
end
end


return p[func](args, cfg)
return bridge[func](args, cfg)
end
end