highlight_spec.lua (3759B)
1 local t = require('test.testutil') 2 local n = require('test.functional.testnvim')() 3 local Screen = require('test.functional.ui.screen') 4 5 local clear, feed = n.clear, n.feed 6 local expect = n.expect 7 local eq = t.eq 8 local poke_eventloop = n.poke_eventloop 9 local exc_exec = n.exc_exec 10 local feed_command = n.feed_command 11 local exec = n.exec 12 13 before_each(clear) 14 15 describe(':highlight', function() 16 it('is working', function() 17 local screen = Screen.new(35, 10) 18 -- Basic test if ":highlight" doesn't crash 19 feed_command('set more') 20 feed(':highlight<CR>') 21 -- FIXME(tarruda): We need to be sure the prompt is displayed before 22 -- continuing, or risk a race condition where some of the following input 23 -- is discarded resulting in test failure 24 screen:expect([[ 25 :highlight | 26 SpecialKey {18:xxx} {18:ctermfg=}4 | 27 {18:guifg=}Blue | 28 EndOfBuffer {1:xxx} {18:links to} NonText| 29 | 30 TermCursor {2:xxx} {18:cterm=}reverse | 31 {18:gui=}reverse | 32 NonText {1:xxx} {18:ctermfg=}12 | 33 {18:gui=}bold | 34 {6:-- More --}^ | 35 ]]) 36 feed('q') 37 poke_eventloop() -- wait until we're back to normal 38 feed_command('hi Search') 39 feed_command('hi Normal') 40 41 -- Test setting colors. 42 -- Test clearing one color and all doesn't generate error or warning 43 feed_command( 44 'hi NewGroup cterm=italic ctermfg=DarkBlue ctermbg=Grey gui=NONE guifg=#00ff00 guibg=Cyan' 45 ) 46 feed_command('hi Group2 cterm=NONE') 47 feed_command('hi Group3 cterm=bold') 48 feed_command('redir! @a') 49 feed_command('hi NewGroup') 50 feed_command('hi Group2') 51 feed_command('hi Group3') 52 feed_command('hi clear NewGroup') 53 feed_command('hi NewGroup') 54 feed_command('hi Group2') 55 feed_command('hi Group2 NONE') 56 feed_command('hi Group2') 57 feed_command('hi clear') 58 feed_command('hi Group3') 59 feed('<cr>') 60 eq("Vim(highlight):E475: Invalid argument: cterm='asdf", exc_exec([[hi Crash cterm='asdf]])) 61 feed_command('redir END') 62 63 -- Filter ctermfg and ctermbg, the numbers depend on the terminal 64 feed_command('0put a') 65 feed_command([[%s/ctermfg=\d*/ctermfg=2/]]) 66 feed_command([[%s/ctermbg=\d*/ctermbg=3/]]) 67 68 -- Fix the fileformat 69 feed_command('set ff&') 70 feed_command('$d') 71 72 -- Assert buffer contents. 73 expect([[ 74 75 76 NewGroup xxx cterm=italic 77 ctermfg=2 78 ctermbg=3 79 guifg=#00ff00 80 guibg=Cyan 81 82 Group2 xxx cleared 83 84 Group3 xxx cterm=bold 85 86 87 NewGroup xxx cleared 88 89 Group2 xxx cleared 90 91 92 Group2 xxx cleared 93 94 95 Group3 xxx cleared]]) 96 end) 97 end) 98 99 describe('Visual selection highlight', function() 100 -- oldtest: Test_visual_sbr() 101 it("when 'showbreak' is set", function() 102 local screen = Screen.new(60, 6) 103 exec([[ 104 set showbreak=> 105 call setline(1, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.') 106 exe "normal! z1\<CR>" 107 ]]) 108 feed('v$') 109 screen:expect([[ 110 {1:>}{17:n, no sea takimata sanctus est Lorem ipsum dolor sit amet.}^ | 111 |*4 112 {5:-- VISUAL --} | 113 ]]) 114 end) 115 end)