Module:Road data/testcases
Appearance
![]() | This is the test cases page for the module Module:Road data. Results of the test cases. |
local p = {}
local live = require('Module:Road data')
local sandbox = require('Module:Road data/sandbox')
local p = {}
local function showArgs(args)
local out = ''
for _, arg in ipairs(args) do
out = out .. mw.getCurrentFrame():preprocess('<syntaxhighlight lang="lua">' .. mw.dumpObject(arg) .. '</syntaxhighlight>')
end
return out
end
local function addTest(out, functionName, ...)
out = out .. '|-\n'
out = out .. '| <code>' .. functionName .. '</code> with parameters:' .. showArgs(arg) .. '\n'
-- out = out .. '| ' .. live[functionName](unpack(arg)) .. '\n'
out = out .. '| ' .. sandbox[functionName](unpack(arg)) .. '\n'
return out
end
local function startTable(out)
out = out .. '{| class="wikitable"\n'
out = out .. '! Lua' .. '\n'
-- out = out .. '! Live'
out = out .. '! Sandbox' .. '\n'
return out
end
local function endTable(out)
out = out .. '|}\n'
return out
end
function p.test(frame)
local out = ''
out = out .. '== <code>shield</code> ==\n'
out = startTable(out)
out = addTest(out, 'shield', { type = 'I', route = '10', state = 'NY' })
out = addTest(out, 'shield', { type = 'RA', route = '5', country = 'ITA' }, nil, 'jct')
out = addTest(out, 'shield', { type = 'Hwy', route = '5', province = 'ON' }, nil, 'jct')
out = addTest(out, 'shield', { type = 'Hwy', route = '5', province = 'ON' }, 'list', 'jct')
out = addTest(out, 'shield', { type = 'Hwy', route = '5', province = 'ON' }, 'main', 'infobox', true)
out = addTest(out, 'shield', { type = 'Both', route = '821', state = 'FL' }, nil, 'jct')
out = addTest(out, 'shield', { type = 'Both', route = '821', state = 'FL' }, 'main', 'infobox', true)
out = endTable(out)
out = out .. '== <code>link</code> ==\n'
out = startTable(out)
out = addTest(out, 'link', { type = 'I', route = '90', state = 'NY' })
out = addTest(out, 'link', { type = 'I', route = '90', state = 'NY' }, true)
out = addTest(out, 'link', { type = 'I', route = '10', state = 'NY' })
out = addTest(out, 'link', { type = 'RA', route = '5', country = 'ITA' })
out = addTest(out, 'link', { type = 'RA', route = '5', country = 'ITA' }, true)
out = addTest(out, 'link', { type = 'Hwy', route = '5', province = 'ON' })
out = endTable(out)
return out
end
return p