Jump to content

Module:Example/testcases: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Undid revision 594573616 by ViniciusBR11 (talk)
mNo edit summary
Line 1: Line 1:
local p = {}
-- Unit tests for [[Module:Bananas]]. Click talk page to run tests.
function p.animate( f )
local p = require('Module:UnitTests')
local args = f

if f == mw.getCurrentFrame() then
function p:test_hello()
args = f:getParent().args
self:preprocess_equals('{{#invoke:Bananas | hello}}', 'Hello World!')
end
local files = args[1] or ''
local size = args[2] or ''
if size ~= '' then
size = '|' .. size
end
local images = {}
for image in mw.text.gsplit( files, '%s*;%s*' ) do
if image == '' then
table.insert( images, '<span><br></span>' )
else
table.insert( images, '<span>[[File:' .. image .. size .. ']]</span>' )
end
end
images[1] = images[1]:gsub( '^<span>', '<span class="active">' )
return '<span class="animated">' .. table.concat( images ) .. '</span>'
end
end

return p
return p

Revision as of 21:45, 8 February 2014

local p = {}
function p.animate( f )
	local args = f
	if f == mw.getCurrentFrame() then
		args = f:getParent().args
	end
	local files = args[1] or ''
	local size = args[2] or ''
	
	if size ~= '' then
		size = '|' .. size
	end
	
	local images = {}
	for image in mw.text.gsplit( files, '%s*;%s*' ) do
		if image == '' then
			table.insert( images, '<span><br></span>' )
		else
			table.insert( images, '<span>[[File:' .. image .. size .. ']]</span>' )
		end
	end
	images[1] = images[1]:gsub( '^<span>', '<span class="active">' )
	
	return '<span class="animated">' .. table.concat( images ) .. '</span>'
end
return p