From d82f883c0ba5f3768b5b42b3646d8f74d66c97dc Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sat, 3 Mar 2018 10:46:49 +0100 Subject: [PATCH] test-focus.lua: Improve error messages on assertion failure Signed-off-by: Uli Schlachter --- tests/test-focus.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/test-focus.lua b/tests/test-focus.lua index 91b39f2ce..7250f9964 100644 --- a/tests/test-focus.lua +++ b/tests/test-focus.lua @@ -12,6 +12,13 @@ client.connect_signal("focus", function(c) c.border_color = "#ff0000" 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 = { -- border_color should get applied via focus signal for first client on tag. @@ -21,7 +28,7 @@ local steps = { else local c = client.get()[1] if c then - assert(c.border_color == "#ff0000") + assert_equals(c.border_color, "#ff0000") return true end end @@ -34,9 +41,9 @@ local steps = { else if #client.get() == 2 then local c = client.get()[1] - assert(c == client.focus) + assert_equals(c, client.focus) if c then - assert(c.border_color == "#ff0000") + assert_equals(c.border_color, "#ff0000") return true end