Jump to content

Module:Lua call/testcases

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Uzume (talk | contribs) at 20:41, 15 December 2021 (fix). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

local ScribuntoUnit = require('Module:ScribuntoUnit')
local suite = ScribuntoUnit:new()

function suite:testmain()
	self:assertResultEquals(
		[=[test test test test test test test ]=],
		[=[{{#invoke:LuaCall|main|a=test |b=7|string.rep(a,b)}}]=])
	self:assertResultEquals(
		[=[I. c.a.n.'t. g.e.t. n.o. s.a.t.i.s.f.a.c.t.i.o.n.]=],
		[=[{{#invoke:LuaCall|main|pattern=(%a)|replace=%1.|string=I can't get no satisfaction|mw.ustring.gsub(string,pattern,replace)|reserved_return=1}}]=])
	self:assertResultEquals(
		[=[22]=],
		[=[{{#invoke:LuaCall|main|pattern=(%a)|replace=%1.|string=I can't get no satisfaction|mw.ustring.gsub(string,pattern,replace)|reserved_return=2}}]=])
	self:assertResultEquals(
		[=[2]=],
		[=[{{#invoke:LuaCall|main|value=1.4512|math.ceil(value)}}]=])
	self:assertResultEquals(
		[=[1]=],
		[=[{{#invoke:LuaCall|main|value=1.4512|math.modf(value)}}]=])
	self:assertResultEquals(
		[=[0.4512]=],
		[=[{{#invoke:LuaCall|main|value=1.4512|math.modf(value)|reserved_return=2}}]=])
	self:assertResultEquals(
		[=[181]=],
		[=[{{#invoke:LuaCall|main|value=... that the '''[[Privacy and Civil Liberties Oversight Board report on mass surveillance]]''' recommended against imposing a [[data retention]] requirement on U.S. phone companies?|string.len(value)}}]=])
	self:assertResultEquals(
		[=[bc]=],
		[=[{{#invoke:LuaCall|main|value=abcd|start=2|end=3|string.sub(value,start,end)}}]=],
		[=[For comparison with [[n:Template:Evalx]]]=])
end

return suite