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`.
73 lines
2.2 KiB
Lua
73 lines
2.2 KiB
Lua
local t = require('test.testutil')
|
|
local describe, it, before_each = t.describe, t.it, t.before_each
|
|
local pcall_err = t.pcall_err
|
|
local n = require('test.functional.testnvim')()
|
|
local Screen = require('test.functional.ui.screen')
|
|
|
|
local eq, command = t.eq, n.command
|
|
local clear = n.clear
|
|
local eval = n.eval
|
|
local exec = n.exec
|
|
local fn = n.fn
|
|
local api = n.api
|
|
local command = n.command
|
|
|
|
describe(':highlight', function()
|
|
before_each(function()
|
|
clear()
|
|
local _ = Screen.new()
|
|
end)
|
|
|
|
it('invalid color name', function()
|
|
eq(
|
|
'Vim(highlight):E421: Color name or number not recognized: ctermfg=#181818',
|
|
pcall_err(command, 'highlight normal ctermfg=#181818')
|
|
)
|
|
eq(
|
|
'Vim(highlight):E421: Color name or number not recognized: ctermbg=#181818',
|
|
pcall_err(command, 'highlight normal ctermbg=#181818')
|
|
)
|
|
end)
|
|
|
|
it('invalid group name', function()
|
|
eq('Vim(highlight):E411: Highlight group not found: foo', pcall_err(command, 'highlight foo'))
|
|
end)
|
|
|
|
it('"Normal" foreground with red', function()
|
|
eq('', eval('synIDattr(hlID("Normal"), "fg", "cterm")'))
|
|
command('highlight normal ctermfg=red')
|
|
eq('9', eval('synIDattr(hlID("Normal"), "fg", "cterm")'))
|
|
end)
|
|
|
|
it('"Normal" background with red', function()
|
|
eq('', eval('synIDattr(hlID("Normal"), "bg", "cterm")'))
|
|
command('highlight normal ctermbg=red')
|
|
eq('9', eval('synIDattr(hlID("Normal"), "bg", "cterm")'))
|
|
end)
|
|
|
|
it('only the last underline style takes effect #22371', function()
|
|
command('highlight NonText gui=underline,undercurl')
|
|
eq('', eval('synIDattr(hlID("NonText"), "underline", "gui")'))
|
|
eq('1', eval('synIDattr(hlID("NonText"), "undercurl", "gui")'))
|
|
command('highlight NonText gui=undercurl,underline')
|
|
eq('', eval('synIDattr(hlID("NonText"), "undercurl", "gui")'))
|
|
eq('1', eval('synIDattr(hlID("NonText"), "underline", "gui")'))
|
|
end)
|
|
|
|
it('clear', function()
|
|
api.nvim_set_var('colors_name', 'foo')
|
|
eq(1, fn.exists('g:colors_name'))
|
|
command('hi clear')
|
|
eq(0, fn.exists('g:colors_name'))
|
|
api.nvim_set_var('colors_name', 'foo')
|
|
eq(1, fn.exists('g:colors_name'))
|
|
exec([[
|
|
func HiClear()
|
|
hi clear
|
|
endfunc
|
|
]])
|
|
fn.HiClear()
|
|
eq(0, fn.exists('g:colors_name'))
|
|
end)
|
|
end)
|