Modul:ScribuntoUnit/testtilfeller
Utseende
Denne siden inneholder testtilfeller for modulen Modul:ScribuntoUnit. Vis resultater fra testene. |
local ScribuntoUnit = require('Module:ScribuntoUnit')
p = {}
function p.testAssertEqualsWithEqualStrings()
local out = "Testing that assertEquals does not throw error for equal strings... "
success, details = pcall(function ()
local suite = ScribuntoUnit:new()
suite:assertEquals('abc', 'abc')
end)
if success then
out = out .. "OK"
else
out = out .. "FAIL"
if type(details) ~= 'table' or not details.ScribuntoUnit then -- a real error, not a failed assertion
out = out .. '. Lua error: ' .. tostring(details)
end
end
return out
end
function p.testAssertEqualsWithUnequalStrings()
local out = 'Testing that assertEquals throws error for unequal strings... '
success, details = pcall(function ()
local suite = ScribuntoUnit:new()
suite:assertEquals('abc', 'def')
end)
if success then
out = out .. 'FAIL'
elseif type(details) ~= 'table' or not details.ScribuntoUnit then -- a real error, not a failed assertion
out = out .. 'FAIL. Lua error: ' .. tostring(details)
else
out = out .. 'OK'
end
return out
end
return p