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 = {
{'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'}
}
function p.makeCell(fu, pa)
if fu == 'callstrip' then
return '<td>'..'{{#invoke:ISO 3166|'..fu..'|'..pa[1]..'}}'..(pa[2] and ' {{#invoke:ISO 3166|'..fu..'|'..pa[2]..'}}' or '')..'</td>'
else
return '<td>'..'{{#invoke:ISO 3166|'..fu..'|'..pa[1]..(pa[2] and '|'..pa[2] or '')..'}}'..'</td>'
end
end
function p.makeRow(frame, fu, pa)
local out = p.makeCell(fu, pa) -- Live
out = out..p.makeCell(fu, pa):gsub('ISO 3166','ISO 3166/sandbox') -- Sandbox
out = out..p.makeCell(fu, pa):gsub('<td>','<td><code><nowiki>'):gsub('</td>','</nowiki></code></td>') -- Code
return frame:preprocess('<tr>'..out..'</tr>')
end
function p.makeTable(frame, fu)
local out = '<tr><th>Live</th><th>Sandbox</th><th>Code</th></tr>'
for k,v in ipairs(arguments) do
out = out..p.makeRow(frame, fu, v)
end
return '<table class="wikitable">'..out..'</table>'
end
function p.run(frame)
return p.makeTable(frame, frame.args[1])
end
return p