2014-11-09 13:54:33 -07:00
|
|
|
-- Tests for ":highlight".
|
|
|
|
|
2015-02-15 06:21:13 -07:00
|
|
|
local Screen = require('test.functional.ui.screen')
|
2016-04-23 16:53:11 -07:00
|
|
|
local helpers = require('test.functional.helpers')(after_each)
|
2015-11-17 15:31:22 -07:00
|
|
|
local clear, feed = helpers.clear, helpers.feed
|
2017-04-08 14:12:26 -07:00
|
|
|
local command, expect = helpers.command, helpers.expect
|
2017-04-08 15:43:46 -07:00
|
|
|
local eq = helpers.eq
|
2015-02-15 06:21:13 -07:00
|
|
|
local wait = helpers.wait
|
2017-04-08 15:43:46 -07:00
|
|
|
local exc_exec = helpers.exc_exec
|
2014-11-09 13:54:33 -07:00
|
|
|
|
|
|
|
describe(':highlight', function()
|
|
|
|
setup(clear)
|
|
|
|
|
|
|
|
it('is working', function()
|
2015-02-15 06:21:13 -07:00
|
|
|
local screen = Screen.new(35, 10)
|
|
|
|
screen:attach()
|
2014-11-09 13:54:33 -07:00
|
|
|
-- Basic test if ":highlight" doesn't crash
|
2017-04-08 15:43:46 -07:00
|
|
|
command('set more')
|
|
|
|
feed(':highlight<CR>')
|
2015-02-15 06:21:13 -07:00
|
|
|
-- FIXME(tarruda): We need to be sure the prompt is displayed before
|
|
|
|
-- continuing, or risk a race condition where some of the following input
|
|
|
|
-- is discarded resulting in test failure
|
|
|
|
screen:expect([[
|
|
|
|
:highlight |
|
|
|
|
SpecialKey xxx ctermfg=4 |
|
|
|
|
guifg=Blue |
|
|
|
|
EndOfBuffer xxx links to NonText|
|
|
|
|
|
|
2015-04-08 04:34:27 -07:00
|
|
|
TermCursor xxx cterm=reverse |
|
|
|
|
gui=reverse |
|
|
|
|
TermCursorNC xxx cleared |
|
2015-02-15 06:21:13 -07:00
|
|
|
NonText xxx ctermfg=12 |
|
2015-03-05 02:07:55 -07:00
|
|
|
-- More --^ |
|
2015-02-15 06:21:13 -07:00
|
|
|
]])
|
|
|
|
feed('q')
|
|
|
|
wait() -- wait until we're back to normal
|
2017-04-08 14:12:26 -07:00
|
|
|
command('hi Search')
|
2017-08-15 09:03:06 -07:00
|
|
|
command('hi Normal')
|
2014-11-09 13:54:33 -07:00
|
|
|
|
|
|
|
-- Test setting colors.
|
|
|
|
-- Test clearing one color and all doesn't generate error or warning
|
2017-04-08 14:12:26 -07:00
|
|
|
command('hi NewGroup cterm=italic ctermfg=DarkBlue ctermbg=Grey gui=NONE guifg=#00ff00 guibg=Cyan')
|
|
|
|
command('hi Group2 cterm=NONE')
|
|
|
|
command('hi Group3 cterm=bold')
|
|
|
|
command('redir! @a')
|
|
|
|
command('hi NewGroup')
|
|
|
|
command('hi Group2')
|
|
|
|
command('hi Group3')
|
|
|
|
command('hi clear NewGroup')
|
|
|
|
command('hi NewGroup')
|
|
|
|
command('hi Group2')
|
|
|
|
command('hi Group2 NONE')
|
|
|
|
command('hi Group2')
|
|
|
|
command('hi clear')
|
|
|
|
command('hi Group3')
|
2017-04-08 15:43:46 -07:00
|
|
|
eq('Vim(highlight):E475: Invalid argument: cterm=\'asdf',
|
|
|
|
exc_exec([[hi Crash cterm='asdf]]))
|
2017-04-08 14:12:26 -07:00
|
|
|
command('redir END')
|
2014-11-09 13:54:33 -07:00
|
|
|
|
|
|
|
-- Filter ctermfg and ctermbg, the numbers depend on the terminal
|
2017-04-08 14:12:26 -07:00
|
|
|
command('0put a')
|
|
|
|
command([[%s/ctermfg=\d*/ctermfg=2/]])
|
|
|
|
command([[%s/ctermbg=\d*/ctermbg=3/]])
|
2014-11-09 13:54:33 -07:00
|
|
|
|
|
|
|
-- Fix the fileformat
|
2017-04-08 14:12:26 -07:00
|
|
|
command('set ff&')
|
|
|
|
command('$d')
|
2014-11-09 13:54:33 -07:00
|
|
|
|
|
|
|
-- Assert buffer contents.
|
|
|
|
expect([[
|
2017-04-08 14:12:26 -07:00
|
|
|
|
2015-02-15 06:21:13 -07:00
|
|
|
NewGroup xxx cterm=italic
|
|
|
|
ctermfg=2
|
|
|
|
ctermbg=3
|
|
|
|
guifg=#00ff00
|
|
|
|
guibg=Cyan
|
2014-11-09 13:54:33 -07:00
|
|
|
Group2 xxx cleared
|
2015-02-13 08:06:08 -07:00
|
|
|
Group3 xxx cterm=bold
|
2014-11-09 13:54:33 -07:00
|
|
|
NewGroup xxx cleared
|
|
|
|
Group2 xxx cleared
|
|
|
|
Group2 xxx cleared
|
2017-04-08 15:43:46 -07:00
|
|
|
Group3 xxx cleared]])
|
2015-02-15 06:21:13 -07:00
|
|
|
screen:detach()
|
2014-11-09 13:54:33 -07:00
|
|
|
end)
|
|
|
|
end)
|