test/functional: clean up according to luacheck (part 2)

This commit is contained in:
Marco Hinz
2015-11-17 23:31:22 +01:00
parent 4a69e55f39
commit d9fbc1865b
49 changed files with 121 additions and 125 deletions

View File

@@ -106,7 +106,7 @@
-- use `screen:snapshot_util({},true)`
local helpers = require('test.functional.helpers')
local request, run, stop = helpers.request, helpers.run, helpers.stop
local request, run = helpers.request, helpers.run
local dedent = helpers.dedent
local Screen = {}
@@ -241,7 +241,7 @@ function Screen:wait(check, timeout)
checked = true
if not err then
success_seen = true
stop()
helpers.stop()
elseif success_seen and #args > 0 then
failure_after_success = true
--print(require('inspect')(args))
@@ -448,7 +448,7 @@ function Screen:_row_repr(row, attr_ids, attr_ignore)
local rv = {}
local current_attr_id
for i = 1, self._width do
local attr_id = get_attr_id(attr_ids, attr_ignore, row[i].attrs)
local attr_id = self:_get_attr_id(attr_ids, attr_ignore, row[i].attrs)
if current_attr_id and attr_id ~= current_attr_id then
-- close current attribute bracket, add it before any whitespace
-- up to the current cell
@@ -524,8 +524,8 @@ function Screen:print_snapshot(attrs, ignore)
local row = self._rows[i]
for j = 1, self._width do
local attr = row[j].attrs
if attr_index(attrs, attr) == nil and attr_index(ignore, attr) == nil then
if not equal_attrs(attr, {}) then
if self:_attr_index(attrs, attr) == nil and self:_attr_index(ignore, attr) == nil then
if not self:_equal_attrs(attr, {}) then
table.insert(attrs, attr)
end
end
@@ -544,7 +544,7 @@ function Screen:print_snapshot(attrs, ignore)
if self._default_attr_ids == nil or self._default_attr_ids[i] ~= a then
alldefault = false
end
local dict = "{"..pprint_attrs(a).."}"
local dict = "{"..self:_pprint_attrs(a).."}"
table.insert(attrstrs, "["..tostring(i).."] = "..dict)
end
local attrstr = "{"..table.concat(attrstrs, ", ").."}"
@@ -558,7 +558,7 @@ function Screen:print_snapshot(attrs, ignore)
io.stdout:flush()
end
function pprint_attrs(attrs)
function Screen:_pprint_attrs(attrs)
local items = {}
for f, v in pairs(attrs) do
local desc = tostring(v)
@@ -572,7 +572,7 @@ function pprint_attrs(attrs)
return table.concat(items, ", ")
end
function backward_find_meaningful(tbl, from)
function backward_find_meaningful(tbl, from) -- luacheck: ignore
for i = from or #tbl, 1, -1 do
if tbl[i] ~= ' ' then
return i + 1
@@ -581,24 +581,24 @@ function backward_find_meaningful(tbl, from)
return from
end
function get_attr_id(attr_ids, ignore, attrs)
function Screen:_get_attr_id(attr_ids, ignore, attrs)
if not attr_ids then
return
end
for id, a in pairs(attr_ids) do
if equal_attrs(a, attrs) then
if self:_equal_attrs(a, attrs) then
return id
end
end
if equal_attrs(attrs, {}) or
ignore == true or attr_index(ignore, attrs) ~= nil then
if self:_equal_attrs(attrs, {}) or
ignore == true or self:_attr_index(ignore, attrs) ~= nil then
-- ignore this attrs
return nil
end
return "UNEXPECTED "..pprint_attrs(attrs)
return "UNEXPECTED "..self:_pprint_attrs(attrs)
end
function equal_attrs(a, b)
function Screen:_equal_attrs(a, b)
return a.bold == b.bold and a.standout == b.standout and
a.underline == b.underline and a.undercurl == b.undercurl and
a.italic == b.italic and a.reverse == b.reverse and
@@ -606,12 +606,12 @@ function equal_attrs(a, b)
a.background == b.background
end
function attr_index(attrs, attr)
function Screen:_attr_index(attrs, attr)
if not attrs then
return nil
end
for i,a in pairs(attrs) do
if equal_attrs(a, attr) then
if self:_equal_attrs(a, attr) then
return i
end
end