Skip to content

Instantly share code, notes, and snippets.

@starius
Created April 6, 2015 19:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save starius/ab8d6aa7929d18a31df0 to your computer and use it in GitHub Desktop.
Save starius/ab8d6aa7929d18a31df0 to your computer and use it in GitHub Desktop.
busted example with global functions
function processEvent(e)
eventId = getEventType(e)
if eventId == 3 then
return 3
else
return 0
end
end
describe("processEvent", function()
it("calls getEventType with the event", function()
local getEventType_argument
function getEventType(x)
getEventType_argument = x
end
processEvent(42)
assert.equal(getEventType_argument, 42)
end)
it("returns 3 if getEventType returns 3", function()
function getEventType()
return 3
end
assert.equal(processEvent(), 3)
end)
it("returns 0 if getEventType returns not 3", function()
function getEventType()
return 42
end
assert.equal(processEvent(), 0)
end)
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment