mirror of
https://github.com/neovim/neovim.git
synced 2026-07-31 12:49:11 +00:00
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`.
43 lines
1.4 KiB
Lua
43 lines
1.4 KiB
Lua
local n = require('test.functional.testnvim')()
|
|
local t = require('test.testutil')
|
|
local Screen = require('test.functional.ui.screen')
|
|
|
|
local describe, it, before_each = t.describe, t.it, t.before_each
|
|
local clear = n.clear
|
|
local exec = n.exec
|
|
local api = n.api
|
|
|
|
describe('Vimscript syntax highlighting', function()
|
|
local screen --- @type test.functional.ui.screen
|
|
|
|
before_each(function()
|
|
clear()
|
|
n.add_builddir_to_rtp()
|
|
exec([[
|
|
setfiletype vim
|
|
syntax on
|
|
]])
|
|
screen = Screen.new()
|
|
screen:set_default_attr_ids({
|
|
[0] = { foreground = Screen.colors.Blue, bold = true },
|
|
[1] = { foreground = Screen.colors.Brown, bold = true },
|
|
[2] = { foreground = tonumber('0x6a0dad') },
|
|
})
|
|
end)
|
|
|
|
it('prefixed boolean options are highlighted properly', function()
|
|
api.nvim_buf_set_lines(0, 0, -1, true, {
|
|
'set number incsearch hlsearch',
|
|
'set nonumber noincsearch nohlsearch',
|
|
'set invnumber invincsearch invhlsearch',
|
|
})
|
|
screen:expect([[
|
|
{1:^set} {2:number} {2:incsearch} {2:hlsearch} |
|
|
{1:set} {2:nonumber} {2:noincsearch} {2:nohlsearch} |
|
|
{1:set} {2:invnumber} {2:invincsearch} {2:invhlsearch} |
|
|
{0:~ }|*10
|
|
|
|
|
]])
|
|
end)
|
|
end)
|