From 14be909206bc9ee16d2caecce2d77a08cb97bf81 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sun, 6 Sep 2015 13:23:05 +0200 Subject: [PATCH] Remove gears.debug.assert Lua provides an assert() function already, so let's just use that. Signed-off-by: Uli Schlachter --- lib/gears/debug.lua | 11 ----------- lib/gears/matrix.lua | 3 +-- lib/wibox/drawable.lua | 3 +-- lib/wibox/widget/base.lua | 5 ++--- 4 files changed, 4 insertions(+), 18 deletions(-) diff --git a/lib/gears/debug.lua b/lib/gears/debug.lua index 9f56e839c..f36a80890 100644 --- a/lib/gears/debug.lua +++ b/lib/gears/debug.lua @@ -14,17 +14,6 @@ local pairs = pairs local debug = {} ---- Check that the given condition holds true, else throw an error --- --- @param cond If this is false, throw a lua error with a backtrace. --- @param[opt] message Message to print in the error. -function debug.assert(cond, message) - local message = message or cond - if not cond then - error(traceback("Assertion failed: '" .. tostring(message) .. "'")) - end -end - --- Given a table (or any other data) return a string that contains its -- tag, value and type. If data is a table then recursively call `dump_raw` -- on each of its values. diff --git a/lib/gears/matrix.lua b/lib/gears/matrix.lua index c8ea28607..3a08a36a3 100644 --- a/lib/gears/matrix.lua +++ b/lib/gears/matrix.lua @@ -6,14 +6,13 @@ --------------------------------------------------------------------------- local cairo = require("lgi").cairo -local debug = require("gears.debug") local matrix = {} --- Copy a cairo matrix -- @param matrix The matrix to copy. -- @return A copy of the given cairo matrix. function matrix.copy(matrix) - debug.assert(cairo.Matrix:is_type_of(matrix), "Argument should be a cairo matrix") + assert(cairo.Matrix:is_type_of(matrix), "Argument should be a cairo matrix") local ret = cairo.Matrix() ret:init(matrix.xx, matrix.yx, matrix.xy, matrix.yy, matrix.x0, matrix.y0) return ret diff --git a/lib/wibox/drawable.lua b/lib/wibox/drawable.lua index 4ba29c1fb..bfcb58324 100644 --- a/lib/wibox/drawable.lua +++ b/lib/wibox/drawable.lua @@ -15,7 +15,6 @@ local capi = { local beautiful = require("beautiful") local cairo = require("lgi").cairo local color = require("gears.color") -local debug = require("gears.debug") local object = require("gears.object") local sort = require("gears.sort") local surface = require("gears.surface") @@ -133,7 +132,7 @@ local function do_redraw(self) self.drawable:refresh() - debug.assert(cr.status == "SUCCESS", "Cairo context entered error state: " .. cr.status) + assert(cr.status == "SUCCESS", "Cairo context entered error state: " .. cr.status) end local function find_widgets(drawable, result, hierarchy, x, y) diff --git a/lib/wibox/widget/base.lua b/lib/wibox/widget/base.lua index 562670663..c2767a833 100644 --- a/lib/wibox/widget/base.lua +++ b/lib/wibox/widget/base.lua @@ -5,7 +5,6 @@ -- @module wibox.widget.base --------------------------------------------------------------------------- -local debug = require("gears.debug") local object = require("gears.object") local cache = require("gears.cache") local matrix = require("gears.matrix") @@ -440,9 +439,9 @@ end --- Do some sanity checking on widget. This function raises a lua error if -- widget is not a valid widget. function base.check_widget(widget) - debug.assert(type(widget) == "table") + assert(type(widget) == "table") for k, func in pairs({ "add_signal", "connect_signal", "disconnect_signal" }) do - debug.assert(type(widget[func]) == "function", func .. " is not a function") + assert(type(widget[func]) == "function", func .. " is not a function") end end