Open main menu
Home
Random
Donate
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:ScribuntoUnit/testcases
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local ScribuntoUnit = require('Module:ScribuntoUnit') local p = {} -------------------------------------------------------------------------------- -- Test assertEquals local function testAssertEquals(msg, expected, actual, shouldFail) local out = msg .. ' ' local errmsg = '' local 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 local 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
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:ScribuntoUnit/testcases/doc
(
edit
)