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