请输入您要查询的百科知识:

 

词条 Module:ScribuntoUnit/testcases
释义

local ScribuntoUnit = require('Module:ScribuntoUnit')

p = {}


-- Test assertEquals

local function testAssertEquals(msg, expected, actual, shouldFail)

local out = msg .. ' '

local errmsg =

success, details = pcall(function ()

local suite = ScribuntoUnit:new()

suite:assertEquals(expected, actual)

end)

if not success and (type(details) ~= 'table' or not details.ScribuntoUnit) then -- a real error, not a failed assertion

errmsg = 'Lua error: ' .. tostring(details)

end

if success == not shouldFail then

out = out .. 'OK'

else

out = out .. 'FAIL' .. (errmsg and ' -- ' .. errmsg or )

end

return out

end

function p.testAssertEqualsWithEqualStrings()

return testAssertEquals(

'Testing that assertEquals does not throw error for equal strings...',

'abc',

'abc',

false

)

end

function p.testAssertEqualsWithUnequalStrings()

return testAssertEquals(

'Testing that assertEquals throws error for unequal strings...',

'abc',

'def',

true

)

end


-- TODO: Test more methods

return p

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/11/11 6:01:44