Module:ScribuntoUnit/sandbox: Difference between revisions

Content deleted Content added
Create sandbox version of Module:ScribuntoUnit with an assertContains method
 
fix parameter name error
Line 124:
-- @param plain search is made with a plain string instead of a ustring pattern
--
function ScribuntoUnit:assertContains(pattern, strings, plain, message)
if type(pattern) ~= 'string' then
DebugHelper.raise({
Line 132:
}, 2)
end
if type(strings) ~= 'string' then
DebugHelper.raise({
ScribuntoUnit = true,
text = mw.ustring.format("String type error (expected string, got %s)", type(strings)),
message = message
}, 2)
end
if not mw.ustring.find(strings, pattern, nil, plain) then
local errTextdisplay = strings
if #errTextdisplay > 100 then
textdisplay = mw.ustring.sub(errTextdisplay, 1, 90) .. " ... " .. mw.ustring.sub(errTextdisplay, -10, -1)
end
DebugHelper.raise({
ScribuntoUnit = true,
text = mw.ustring.format('Failed to find %s "%s" in string "%s"', plain and "plain string" or "pattern", pattern, errTextdisplay),
message = message
}, 2)