diff options
Diffstat (limited to 'test/functional/ui')
-rw-r--r-- | test/functional/ui/highlight_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/ui/input_spec.lua | 1 | ||||
-rw-r--r-- | test/functional/ui/screen.lua | 40 | ||||
-rw-r--r-- | test/functional/ui/screen_basic_spec.lua | 5 | ||||
-rw-r--r-- | test/functional/ui/searchhl_spec.lua | 4 |
5 files changed, 24 insertions, 28 deletions
diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua index 33a53ef201..f9b112e464 100644 --- a/test/functional/ui/highlight_spec.lua +++ b/test/functional/ui/highlight_spec.lua @@ -1,6 +1,6 @@ local helpers = require('test.functional.helpers') local Screen = require('test.functional.ui.screen') -local clear, feed, nvim = helpers.clear, helpers.feed, helpers.nvim +local clear, feed = helpers.clear, helpers.feed local execute, request, eq = helpers.execute, helpers.request, helpers.eq diff --git a/test/functional/ui/input_spec.lua b/test/functional/ui/input_spec.lua index a7c8e02def..4818830940 100644 --- a/test/functional/ui/input_spec.lua +++ b/test/functional/ui/input_spec.lua @@ -8,7 +8,6 @@ describe('mappings', function() local cid local add_mapping = function(mapping, send) - local str = 'mapped '..mapping local cmd = "nnoremap "..mapping.." :call rpcnotify("..cid..", 'mapped', '" ..send:gsub('<', '<lt>').."')<cr>" execute(cmd) diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index 1be83d745e..e1c2d14759 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -106,8 +106,8 @@ -- use `screen:snapshot_util({},true)` local helpers = require('test.functional.helpers') -local request, run, stop = helpers.request, helpers.run, helpers.stop -local eq, dedent = helpers.eq, helpers.dedent +local request, run = helpers.request, helpers.run +local dedent = helpers.dedent local Screen = {} Screen.__index = Screen @@ -125,7 +125,7 @@ end do local spawn, nvim_prog = helpers.spawn, helpers.nvim_prog - local session = spawn({nvim_prog, '-u', 'NONE', '-N', '--embed'}) + local session = spawn({nvim_prog, '-u', 'NONE', '-i', 'NONE', '-N', '--embed'}) local status, rv = session:request('vim_get_color_map') if not status then print('failed to get color map') @@ -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)) @@ -294,9 +294,9 @@ end function Screen:_handle_resize(width, height) local rows = {} - for i = 1, height do + for _ = 1, height do local cols = {} - for j = 1, width do + for _ = 1, width do table.insert(cols, {text = ' ', attrs = {}}) end table.insert(rows, cols) @@ -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 diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index 092cc8c126..a4545eeff0 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers') local Screen = require('test.functional.ui.screen') local spawn, set_session, clear = helpers.spawn, helpers.set_session, helpers.clear local feed, execute = helpers.feed, helpers.execute -local insert, wait = helpers.insert, helpers.wait +local insert = helpers.insert describe('Initial screen', function() local screen @@ -11,9 +11,6 @@ describe('Initial screen', function() '--embed'} before_each(function() - if session then - session:exit(0) - end local screen_nvim = spawn(nvim_argv) set_session(screen_nvim) screen = Screen.new() diff --git a/test/functional/ui/searchhl_spec.lua b/test/functional/ui/searchhl_spec.lua index d04329e1e2..e4217abcfe 100644 --- a/test/functional/ui/searchhl_spec.lua +++ b/test/functional/ui/searchhl_spec.lua @@ -1,7 +1,7 @@ local helpers = require('test.functional.helpers') local Screen = require('test.functional.ui.screen') -local clear, feed, nvim, insert = helpers.clear, helpers.feed, helpers.nvim, helpers.insert -local execute, request, eq = helpers.execute, helpers.request, helpers.eq +local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert +local execute = helpers.execute describe('search highlighting', function() local screen |