awesome/tests/test-miss-handlers.lua

39 lines
808 B
Lua
Raw Normal View History

-- Test set_{,new}index_miss_handler
2016-04-25 03:04:27 +02:00
local mouse = mouse
local class = tag
local obj = class({})
2016-03-30 09:20:56 +02:00
local handler = require("gears.object.properties")
awesome.connect_signal("debug::index::miss", error)
awesome.connect_signal("debug::newindex::miss", error)
class.set_index_miss_handler(function(o, k)
assert(o == obj)
assert(k == "key")
return 42
end)
assert(obj.key == 42)
local called = false
class.set_newindex_miss_handler(function(o, k, v)
assert(o == obj)
assert(k == "key")
assert(v == 42)
called = true
end)
obj.key = 42
assert(called)
2016-03-30 09:20:56 +02:00
handler(class, {auto_emit=true})
assert(not obj.key)
obj.key = 1337
assert(obj.key == 1337)
2016-04-25 03:04:27 +02:00
-- The the custom mouse handler
mouse.foo = "bar"
assert(mouse.foo == "bar")
require("_runner").run_steps({ function() return true end })