aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/inspector_spec.lua
blob: 5e488bb08230b4b6592dc566ab5762e3aae1c3aa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
local helpers = require('test.functional.helpers')(after_each)
local exec_lua = helpers.exec_lua
local eq = helpers.eq
local eval = helpers.eval
local clear = helpers.clear

describe('vim.inspect_pos', function()
  before_each(function()
    clear()
  end)

  it('it returns items', function()
    local ret = exec_lua([[
      local buf = vim.api.nvim_create_buf(true, false)
      vim.api.nvim_set_current_buf(buf)
      vim.api.nvim_buf_set_lines(0, 0, -1, false, {"local a = 123"})
      vim.api.nvim_buf_set_option(buf, "filetype", "lua")
      vim.cmd("syntax on")
      return {buf, vim.inspect_pos(0, 0, 10)}
    ]])
    local buf, items = unpack(ret)
    eq('', eval('v:errmsg'))
    eq({
      buffer = buf,
      col = 10,
      row = 0,
      extmarks = {},
      treesitter = {},
      semantic_tokens = {},
      syntax = {
        {
          hl_group = 'luaNumber',
          hl_group_link = 'Constant',
        },
      },
    }, items)
  end)
end)

describe('vim.show_pos', function()
  before_each(function()
    clear()
  end)

  it('it does not error', function()
    exec_lua([[
      local buf = vim.api.nvim_create_buf(true, false)
      vim.api.nvim_set_current_buf(buf)
      vim.api.nvim_buf_set_lines(0, 0, -1, false, {"local a = 123"})
      vim.api.nvim_buf_set_option(buf, "filetype", "lua")
      vim.cmd("syntax on")
      return {buf, vim.show_pos(0, 0, 10)}
    ]])
    eq('', eval('v:errmsg'))
  end)
end)