2024-04-20 08:44:13 -07:00
|
|
|
local t = require('test.testutil')
|
|
|
|
local n = require('test.functional.testnvim')()
|
|
|
|
|
|
|
|
local clear = n.clear
|
|
|
|
local command = n.command
|
2024-04-08 02:03:20 -07:00
|
|
|
local eq = t.eq
|
2024-04-20 08:44:13 -07:00
|
|
|
local eval = n.eval
|
2022-07-30 15:45:00 -07:00
|
|
|
|
|
|
|
-- oldtest: Test_missing_attr()
|
2023-01-19 19:03:29 -07:00
|
|
|
describe('synIDattr()', function()
|
|
|
|
setup(clear)
|
|
|
|
|
2022-07-30 15:45:00 -07:00
|
|
|
local bool_attrs = {
|
|
|
|
'bold',
|
|
|
|
'italic',
|
|
|
|
'reverse',
|
|
|
|
'standout',
|
|
|
|
'underline',
|
|
|
|
'undercurl',
|
|
|
|
'underdouble',
|
|
|
|
'underdotted',
|
|
|
|
'underdashed',
|
|
|
|
'strikethrough',
|
|
|
|
'nocombine',
|
|
|
|
}
|
|
|
|
|
2023-01-19 19:03:29 -07:00
|
|
|
describe(':hi Mine cterm=NONE gui=NONE', function()
|
|
|
|
setup(function()
|
|
|
|
command(':hi Mine cterm=NONE gui=NONE')
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('"name"', function()
|
|
|
|
eq('Mine', eval([[synIDattr(hlID("Mine"), "name")]]))
|
|
|
|
end)
|
|
|
|
|
|
|
|
local function none_test(attr, mode)
|
|
|
|
it(('"%s"'):format(attr), function()
|
|
|
|
eq('', eval(([[synIDattr(hlID("Mine"), "%s", '%s')]]):format(attr, mode)))
|
|
|
|
end)
|
2022-07-30 15:45:00 -07:00
|
|
|
end
|
2023-01-19 19:03:29 -07:00
|
|
|
|
2024-01-02 18:09:18 -07:00
|
|
|
for _, mode in ipairs({ 'cterm', 'gui' }) do
|
2023-01-19 19:03:29 -07:00
|
|
|
describe(('"%s"'):format(mode), function()
|
|
|
|
for _, attr in ipairs(bool_attrs) do
|
|
|
|
none_test(attr, mode)
|
|
|
|
end
|
2024-01-02 18:09:18 -07:00
|
|
|
for _, attr in ipairs({ 'inverse', 'bg', 'fg', 'sp' }) do
|
2023-01-19 19:03:29 -07:00
|
|
|
none_test(attr, mode)
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
|
|
|
local function attr_test(attr1, attr2)
|
|
|
|
local cmd = (':hi Mine cterm=%s gui=%s'):format(attr1, attr2)
|
|
|
|
it(cmd, function()
|
|
|
|
command(cmd)
|
|
|
|
eq('1', eval(([[synIDattr("Mine"->hlID(), "%s", 'cterm')]]):format(attr1)))
|
|
|
|
eq('', eval(([[synIDattr(hlID("Mine"), "%s", 'cterm')]]):format(attr2)))
|
|
|
|
eq('', eval(([[synIDattr("Mine"->hlID(), "%s", 'gui')]]):format(attr1)))
|
|
|
|
eq('1', eval(([[synIDattr(hlID("Mine"), "%s", 'gui')]]):format(attr2)))
|
|
|
|
end)
|
2022-07-30 15:45:00 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
for i, attr1 in ipairs(bool_attrs) do
|
|
|
|
local attr2 = bool_attrs[i - 1] or bool_attrs[#bool_attrs]
|
2023-01-19 19:03:29 -07:00
|
|
|
attr_test(attr1, attr2)
|
|
|
|
attr_test(attr2, attr1)
|
2022-07-30 15:45:00 -07:00
|
|
|
end
|
|
|
|
|
2023-01-19 19:03:29 -07:00
|
|
|
it(':hi Mine cterm=reverse gui=inverse', function()
|
|
|
|
command(':hi Mine cterm=reverse gui=inverse')
|
|
|
|
eq('1', eval([[synIDattr(hlID("Mine"), "reverse", 'cterm')]]))
|
|
|
|
eq('1', eval([[synIDattr(hlID("Mine"), "inverse", 'cterm')]]))
|
|
|
|
eq('1', eval([[synIDattr(hlID("Mine"), "reverse", 'gui')]]))
|
|
|
|
eq('1', eval([[synIDattr(hlID("Mine"), "inverse", 'gui')]]))
|
|
|
|
end)
|
2022-07-30 15:45:00 -07:00
|
|
|
end)
|