Module:ISO 3166/testcases
Appearance
![]() | This is the test cases page for the module Module:ISO 3166. Results of the test cases. |
--SEE: Module talk:ISO 3166/testcases
local p = {}
local arguments = {
-- {{Positional/numbered parameters},{named arguments}}
{{'Canada'}},
{{'United States'}},
{{'The United States of America'}},
{{'US'}},
{{'US', 'New York'}},
{{'USA', 'New York'}},
{{'US-NY'}},
{{'United States', 'New York'}},
{{'United States', 'New York (State)'}},
{{'United States', '[[New York (State)]]'}},
{{'United States', '[[New York (State)|Test]]'}},
{{'Áfghanistan'}},
{{'[[United States|THE PLACE]]'}},
{{'[[File:Flag_of_Canada.svg|20px]]'}},
{{'{{flag|India}}'}},
{{'{{CAN}}'}},
{{'[[Canada]]'}},
{{[[C"A'NA‘,DA(AAA)']]}},
{{'Taiwan, Province of China'}},
{{'Taiwan'}},
{{'Republic of China'}},
{{'TW'}},
{{'TWN'}},
{{'158'}},
{{'{{PRC}}'}},
{{'{{USA}}'}},
{{'United States<ref name=A>{{cite web|url=http://www.example.com}}</ref>'}},
{{'United States<ref name="A">{{cite web|url=http://www.example.com}}</ref>'}},
{{'United States<ref name="B" />'}},
{{'[[Russia]]', '[[Sakha Republic]]'}}
}
local function makeCell(func, params)
local code = '<td>{{#invoke:ISO 3166|'..func
if params[1] then
for k,v in ipairs(params[1]) do
code = code..'|'..k..' = '..v..''
end
end
if params[2] then
for k,v in pairs(params[2]) do
code = code..'|'..k..' = '..v..''
end
end
return code..'}}</td>'
end
local function makeRow(frame, func, params)
local out = ''
out = out..makeCell(func, params) -- Live
out = out..makeCell(func, params):gsub('ISO 3166','ISO 3166/sandbox') -- Sandbox
out = out..makeCell(func, params):gsub('<td>','<td><code><nowiki>'):gsub('</td>','</nowiki></code></td>') -- Code
return frame:preprocess('<tr>'..out..'</tr>')
end
function p.run(frame)
local out = '<tr><th>Live</th><th>Sandbox</th><th>Code</th></tr>'
for k,v in ipairs(arguments) do
out = out..makeRow(frame, frame.args[1], v)
end
return '<table class="wikitable">'..out..'</table>'
end
return p