Module:Road data/testcases: Difference between revisions
Appearance
Content deleted Content added
BrandonXLF (talk | contribs) Remove extra space |
BrandonXLF (talk | contribs) Add more tests |
||
Line 39: | Line 39: | ||
return out |
return out |
||
end |
end |
||
local NIL = setmetatable({}, { __tostring = function() return 'nil' end }) |
|||
function p.test(frame) |
function p.test(frame) |
||
Line 45: | Line 47: | ||
out = out .. '== <code>shield</code> ==\n' |
out = out .. '== <code>shield</code> ==\n' |
||
out = startTable(out) |
out = startTable(out) |
||
out = addTest(out, 'shield', { |
out = addTest(out, 'shield', { country = 'USA', state = 'ny', type = 'I', route = '10' }) |
||
out = addTest(out, 'shield', { |
out = addTest(out, 'shield', { country = 'ITA', type = 'RA', route = '5' }, NIL, 'jct') |
||
out = addTest(out, 'shield', { |
out = addTest(out, 'shield', { country = 'CAN', province = 'ON', type = 'Hwy', route = '5' }, NIL, 'jct') |
||
out = addTest(out, 'shield', { |
out = addTest(out, 'shield', { country = 'CAN', province = 'ON', type = 'Hwy', route = '5' }, 'normal (or anything)', 'jct') |
||
out = addTest(out, 'shield', { |
out = addTest(out, 'shield', { country = 'CAN', province = 'ON', type = 'Hwy', route = '5' }, 'list', 'jct') |
||
out = addTest(out, 'shield', { |
out = addTest(out, 'shield', { country = 'CAN', province = 'ON', type = 'Hwy', route = '5' }, 'main', 'jct') |
||
out = addTest(out, 'shield', { |
out = addTest(out, 'shield', { country = 'CAN', province = 'ON', type = 'Hwy', route = '5', to = true }, NIL, 'jct') |
||
out = addTest(out, 'shield', { country = 'CAN', province = 'ON', type = 'Hwy', route = '5', to = true }, 'main', 'jct') |
|||
out = addTest(out, 'shield', { country = 'CAN', province = 'ON', type = 'Hwy', route = '5' }, 'main', 'infobox', true) |
|||
out = addTest(out, 'shield', { country = 'USA', state = 'FL', type = 'Both', route = '821' }, NIL, 'jct') |
|||
out = addTest(out, 'shield', { country = 'USA', state = 'FL', type = 'Both', route = '821'}, 'main', 'infobox', true) |
|||
out = endTable(out) |
out = endTable(out) |
||
Revision as of 03:27, 25 August 2024
![]() | 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
local NIL = setmetatable({}, { __tostring = function() return 'nil' end })
function p.test(frame)
local out = ''
out = out .. '== <code>shield</code> ==\n'
out = startTable(out)
out = addTest(out, 'shield', { country = 'USA', state = 'ny', type = 'I', route = '10' })
out = addTest(out, 'shield', { country = 'ITA', type = 'RA', route = '5' }, NIL, 'jct')
out = addTest(out, 'shield', { country = 'CAN', province = 'ON', type = 'Hwy', route = '5' }, NIL, 'jct')
out = addTest(out, 'shield', { country = 'CAN', province = 'ON', type = 'Hwy', route = '5' }, 'normal (or anything)', 'jct')
out = addTest(out, 'shield', { country = 'CAN', province = 'ON', type = 'Hwy', route = '5' }, 'list', 'jct')
out = addTest(out, 'shield', { country = 'CAN', province = 'ON', type = 'Hwy', route = '5' }, 'main', 'jct')
out = addTest(out, 'shield', { country = 'CAN', province = 'ON', type = 'Hwy', route = '5', to = true }, NIL, 'jct')
out = addTest(out, 'shield', { country = 'CAN', province = 'ON', type = 'Hwy', route = '5', to = true }, 'main', 'jct')
out = addTest(out, 'shield', { country = 'CAN', province = 'ON', type = 'Hwy', route = '5' }, 'main', 'infobox', true)
out = addTest(out, 'shield', { country = 'USA', state = 'FL', type = 'Both', route = '821' }, NIL, 'jct')
out = addTest(out, 'shield', { country = 'USA', state = 'FL', type = 'Both', route = '821'}, '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