Fix tests for matrix.eventable

This commit is contained in:
Adrian Perez de Castro
2016-07-03 15:27:59 +03:00
parent a8ebe24d38
commit 72060d8a32

View File

@@ -8,7 +8,7 @@
local eventable = require "matrix.eventable"
do -- Simple event
local fire, hook = assert(eventable())
local fire, hook = assert(eventable.functions())
local flag = false
hook("foo", function () flag = true end)
fire("foo")
@@ -16,7 +16,7 @@ do -- Simple event
end
do -- Stop at first handler that returns some value
local fire, hook = assert(eventable())
local fire, hook = assert(eventable.functions())
local flag1, flag2, flag3 = false, false, false
hook("foo", function () flag1 = true end)
hook("foo", function () flag2 = true ; return 42 end)
@@ -29,7 +29,7 @@ end
do -- Arguments to eventable() are passed to handlers
local obj = { answer = 42 }
local fire, hook = assert(eventable(obj))
local fire, hook = assert(eventable.functions(obj))
hook("foo", function (o)
assert(o == obj)
assert(o.answer == 42)
@@ -40,7 +40,7 @@ do -- Arguments to eventable() are passed to handlers
end
do -- Multiple arguments passed to eventable
local fire, hook = assert(eventable(42, "bar", nil, { v=10 }))
local fire, hook = assert(eventable.functions(42, "bar", nil, { v=10 }))
hook("foo", function (a, s, n, o)
assert(a == 42)
assert(s == "bar")
@@ -55,7 +55,7 @@ do -- Unhooking should work
local h1 = function () flag1 = true end
local h2 = function () flag2 = true end
local fire, hook, unhook = assert(eventable())
local fire, hook, unhook = assert(eventable.functions())
hook("foo", h1)
hook("foo", h2)
fire("foo")