Module:Sandbox/Jackmcbarn: Difference between revisions

Content deleted Content added
Jackmcbarn (talk | contribs)
test bug in param order/parsing
Jackmcbarn (talk | contribs)
test the gerrit change
Line 1:
local p = {}
 
function p.expectedmain(frame)
local retvalargs, args_mt = { '__pairs was not used' }, {}
function args_mt.__pairs( t )
for _,v in ipairs{'red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet', 'UV'} do
return pairs( { 'success' } )
-- {{#switch:XXXX|red|orange=1|yellow|green=2|blue|indigo=3|violet=4|5}}
retval = retval .. frame:preprocess('{{#switch:' .. v .. '|red|orange=1|yellow|green=2|blue|indigo=3|violet=4|5}}') .. '\n\n'
end
return frame:expandTemplate{ title = 'Echo', args = setmetatable( args, args_mt ) }
return retval
end
 
function p.equalsInValue(frame)
local retval = ''
for _,v in ipairs{'red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet', 'UV'} do
-- {{#switch:XXXX|red|orange=1|yellow|green=2|blue|indigo=3|violet=4|5}}
retval = retval .. frame:callParserFunction('#switch', {v, 'red', 'orange=1', 'yellow', 'green=2', 'blue', 'indigo=3', 'violet=4', '5'}) .. '\n\n'
end
return retval
end
 
function p.associativeArray(frame)
local retval = ''
for _,v in ipairs{'red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet', 'UV'} do
-- {{#switch:XXXX|red|orange=1|yellow|green=2|blue|indigo=3|violet=4|5}}
retval = retval .. frame:callParserFunction('#switch', {v, 'red', orange='1', 'yellow', green='2', 'blue', indigo='3', violet='4', '5'}) .. '\n\n'
end
return retval
end
 
function p.main(frame)
return p.expected(frame) .. '\n\n' .. p.equalsInValue(frame) .. '\n\n' .. p.associativeArray(frame)
end