Edge Rewrite
// HTMLRewriter · presentation

This page was redesigned at the edge.

Cloudflare fetched the original article and streamed it through HTMLRewriter to apply an entirely new visual system without rebuilding the source page.

Jump to content

Module:Road data/locations/testcases

From Wikipedia, the free encyclopedia
local p = {}

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

local function showArgs(frame, args)
	local out = ''

	for _, arg in ipairs(args) do
		out = out ..  frame:preprocess('<syntaxhighlight lang="lua">' .. mw.dumpObject(arg) .. '</syntaxhighlight>')
	end
	
	return out
end

local function addTest(frame, out, functionName, ...)
	out = out .. '|-\n'
	out = out .. '| style="vertical-align:top" | <code>' .. functionName .. '</code> with arguments:' .. showArgs(frame, arg) .. '\n'
	out = out .. frame:preprocess('| style="vertical-align:top" | <syntaxhighlight lang="lua">' .. mw.dumpObject(live[functionName](unpack(arg))) .. '</syntaxhighlight>\n')
	out = out .. frame:preprocess('| style="vertical-align:top" | <syntaxhighlight lang="lua">' .. mw.dumpObject(sandbox[functionName](unpack(arg))) .. '</syntaxhighlight>\n')

	return out
end

function p.test(frame)
	local out = '{| class="wikitable"\n'
	out = out .. '! Lua\n'
	out = out .. '! Live\n'
	out = out .. '! Sandbox\n'
	
	out = addTest(
		frame,
		out,
		'locations',
		{
			primary_topic = 'no',
			country = 'USA',
			region = 'New Jersey',
			sub1 = 'Monmouth',
			sub2 = 'Wall Township'
			
		},
		'jctint'
	)
	
	out = addTest(
		frame,
		out,
		'locations',
		{
			primary_topic = 'no',
			country = 'USA',
			region = 'New Jersey',
			sub1 = 'Monmouth',
			sub2 = 'Wall Township'
			
		},
		'jcttop'
	)
	
	return out .. '|}\n'
end

return p