Files
neovim/test/functional/plugin/matchparen_spec.lua
Justin M. Keyes 6d8c8b18d5 test(harness): migrate away from magic globals
Problem:
The magic globals `it`, `describe`, etc., are more trouble than they are
worth.

- Hooking into `after_each` requires `getfenv()` hacks.
- They confuse luals/emmylua, because the top-level `.luarc.json` isn't
  merged with `test/.luarc.json` (apparently a luals limitation?)
- They totally defeat discoverability because the user just has to
  "know" about the various magic symbols.

So they harm DX, which means they serve no purpose at all.

Solution:
- Expose the test API from `testutil`, so tests can call `t.it()`,
  `t.describe()`, etc., in the conventional way.
- Drop `getfenv()` hacks.
- Drop the `setfenv()` injection in `load_chunk`.
- Drop `test/_meta.lua`.
2026-07-21 13:22:39 +02:00

45 lines
1.2 KiB
Lua

local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
local describe, it, before_each = t.describe, t.it, t.before_each
local clear = n.clear
local command = n.command
local api = n.api
local feed = n.feed
local eq = t.eq
describe('matchparen', function()
local screen --- @type test.functional.ui.screen
before_each(function()
clear { args = { '-u', 'NORC' } }
screen = Screen.new(20, 5)
screen:set_default_attr_ids({
[0] = { bold = true, foreground = 255 },
[1] = { bold = true },
})
end)
it('uses correct column after i_<Up>. Vim patch 7.4.1296', function()
command('set noautoindent nosmartindent nocindent laststatus=0')
eq(1, api.nvim_get_var('loaded_matchparen'))
feed('ivoid f_test()<cr>')
feed('{<cr>')
feed('}')
-- critical part: up + cr should result in an empty line in between the
-- brackets... if the bug is there, the empty line will be before the '{'
feed('<up>')
feed('<cr>')
screen:expect([[
void f_test() |
{ |
^ |
} |
{1:-- INSERT --} |
]])
end)
end)