test-focus.lua: Improve error messages on assertion failure

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2018-03-03 10:46:49 +01:00
parent 1acae2aa6c
commit d82f883c0b
1 changed files with 10 additions and 3 deletions

View File

@ -12,6 +12,13 @@ client.connect_signal("focus", function(c)
c.border_color = "#ff0000" c.border_color = "#ff0000"
end) end)
local function assert_equals(a, b)
if a == b then
return
end
error(string.format("Assertion failed: %s == %s", a, b))
end
local steps = { local steps = {
-- border_color should get applied via focus signal for first client on tag. -- border_color should get applied via focus signal for first client on tag.
@ -21,7 +28,7 @@ local steps = {
else else
local c = client.get()[1] local c = client.get()[1]
if c then if c then
assert(c.border_color == "#ff0000") assert_equals(c.border_color, "#ff0000")
return true return true
end end
end end
@ -34,9 +41,9 @@ local steps = {
else else
if #client.get() == 2 then if #client.get() == 2 then
local c = client.get()[1] local c = client.get()[1]
assert(c == client.focus) assert_equals(c, client.focus)
if c then if c then
assert(c.border_color == "#ff0000") assert_equals(c.border_color, "#ff0000")
return true return true
end end