Module:Separated entries/testcases

From The Goon Show Depository

< Module:Separated entries

Revision as of 19:35, 30 July 2021 by en>Shirayuki (Created page with "local p = require('Module:ScribuntoUnit'):new() local m = require('Module:Separated entries') local function callWithArgs(args, separator, conjunction, start) local frame = (mw.getCurrentFrame() :newChild{ args = args } :newChild{ args = { separator = separator, conjunction = conjunction, start = start } }) return m.main(frame) end local function callWithArgsBr(args, start) local frame = (mw.getCurrentFrame() :newChild{ args = args } :newChild{ args = { star...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

local p = require('Module:ScribuntoUnit'):new()
local m = require('Module:Separated entries')

local function callWithArgs(args, separator, conjunction, start)
	local frame = (mw.getCurrentFrame()
		:newChild{ args = args }
		:newChild{ args = { separator = separator, conjunction = conjunction, start = start } })
	return m.main(frame)
end

local function callWithArgsBr(args, start)
	local frame = (mw.getCurrentFrame()
		:newChild{ args = args }
		:newChild{ args = { start = start } })
	return m.br(frame)
end

local function callWithArgsComma(args, start)
	local frame = (mw.getCurrentFrame()
		:newChild{ args = args }
		:newChild{ args = { start = start } })
	return m.comma(frame)
end

function p:testMain()
	self:assertEquals('abc', callWithArgs({ 'a', 'b', 'c' }))
	self:assertEquals('a, b, c', callWithArgs({ 'a', 'b', 'c' }, ',&#32;'))
	self:assertEquals('a, b and c', callWithArgs({ 'a', 'b', 'c' }, ',&#32;', '&#32;and&#32;'))
	self:assertEquals('b and c', callWithArgs({ 'a', 'b', 'c' }, ',&#32;', '&#32;and&#32;', '2'))
end

function p:testBr()
	self:assertEquals('a<br />b<br />c', callWithArgsBr({ 'a', 'b', 'c' }))
	self:assertEquals('b<br />c', callWithArgsBr({ 'a', 'b', 'c' }, '2'))
end

function p:testComma()
	self:assertEquals('a, b, c', callWithArgsComma({ 'a', 'b', 'c' }))
	self:assertEquals('b, c', callWithArgsComma({ 'a', 'b', 'c' }, '2'))
end

return p