mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-13 08:58:35 +00:00
Split local and global event handlers
This commit is contained in:
parent
981ca957c1
commit
7a9c2d5e88
@ -346,5 +346,5 @@ return {
|
||||
engineHandlers = {
|
||||
onFrame = testing.updateLocal,
|
||||
},
|
||||
eventHandlers = testing.eventHandlers
|
||||
eventHandlers = testing.localEventHandlers,
|
||||
}
|
||||
|
@ -330,5 +330,5 @@ return {
|
||||
engineHandlers = {
|
||||
onUpdate = testing.makeUpdateGlobal(),
|
||||
},
|
||||
eventHandlers = testing.eventHandlers,
|
||||
eventHandlers = testing.globalEventHandlers,
|
||||
}
|
||||
|
@ -208,8 +208,20 @@ function M.formatActualExpected(actual, expected)
|
||||
return string.format('actual: %s, expected: %s', actual, expected)
|
||||
end
|
||||
|
||||
M.eventHandlers = {
|
||||
runLocalTest = function(name) -- used only in local scripts
|
||||
-- used only in global scripts
|
||||
M.globalEventHandlers = {
|
||||
localTestFinished = function(data)
|
||||
if data.name ~= currentLocalTest then
|
||||
error(string.format('localTestFinished with incorrect name %s, expected %s', data.name, currentLocalTest))
|
||||
end
|
||||
currentLocalTest = nil
|
||||
currentLocalTestError = data.errMsg
|
||||
end,
|
||||
}
|
||||
|
||||
-- used only in local scripts
|
||||
M.localEventHandlers = {
|
||||
runLocalTest = function(name)
|
||||
fn = localTests[name]
|
||||
if not fn then
|
||||
core.sendGlobalEvent('localTestFinished', {name=name, errMsg='Local test is not found'})
|
||||
@ -223,13 +235,6 @@ M.eventHandlers = {
|
||||
core.sendGlobalEvent('localTestFinished', {name=name, errMsg=err})
|
||||
end)
|
||||
end,
|
||||
localTestFinished = function(data) -- used only in global scripts
|
||||
if data.name ~= currentLocalTest then
|
||||
error(string.format('localTestFinished with incorrect name %s, expected %s', data.name, currentLocalTest))
|
||||
end
|
||||
currentLocalTest = nil
|
||||
currentLocalTestError = data.errMsg
|
||||
end,
|
||||
}
|
||||
|
||||
return M
|
||||
|
@ -16,5 +16,5 @@ return {
|
||||
engineHandlers = {
|
||||
onUpdate = testing.makeUpdateGlobal(),
|
||||
},
|
||||
eventHandlers = testing.eventHandlers,
|
||||
eventHandlers = testing.globalEventHandlers,
|
||||
}
|
||||
|
@ -80,5 +80,5 @@ return {
|
||||
engineHandlers = {
|
||||
onFrame = testing.updateLocal,
|
||||
},
|
||||
eventHandlers = testing.eventHandlers
|
||||
eventHandlers = testing.localEventHandlers,
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user