Jump to content

Module:Road data/testcases

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by BrandonXLF (talk | contribs) at 15:59, 23 August 2024 (Add testcases). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
local p = {}

local live = require('Module:Road data')
local sandbox = require('Module:Road data/sandbox')

local function addTest(out, functionName, ...)
	out = out .. '|-\n'
	out = out .. '| <code>' .. functionName .. '</code> with <pre>' .. mw.dumpObject(arg) .. '</pre>\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 = '10', state = 'NY' })
	out = addTest(out, 'link', { type = 'RA', route = '5', country = 'ITA' })
	out = addTest(out, 'link', {  type = 'Hwy', route = '5', province = 'ON' })
	out = endTable(out)
	
	return out
end

return p