robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
56fe6713ca
master
1 2func SetUp () 3source $VIMRUNTIME/menu.vim 4endfunc 5 6func Test_colorscheme () 7" call assert_equal('16777216', &t_Co) 8 9let colorscheme_saved = exists ( 'g:colors_name' ) ? g: colors_name : 'default' 10let g: color_count = 0 11augroup TestColors 12au ! 13au ColorScheme * let g: color_count += 1 14 \ |let g: after_colors = g: color_count 15 \ |let g: color_after = expand ( '<amatch>' ) 16au ColorSchemePre * let g: color_count += 1 17 \ |let g: before_colors = g: color_count 18 \ |let g: color_pre = expand ( '<amatch>' ) 19augroup END 20 21colorscheme torte 22redraw ! 23call assert_equal ( 'dark' , & background ) 24call assert_equal ( 1 , g: before_colors ) 25call assert_equal ( 2 , g: after_colors ) 26call assert_equal ( 'torte' , g: color_pre ) 27call assert_equal ( 'torte' , g: color_after ) 28call assert_equal ( "\ntorte" , execute ( 'colorscheme' )) 29 30let a = substitute ( execute ( 'hi Search' ), "\n\\s\\+" , ' ' , 'g' ) 31" FIXME: temporarily check less while the colorscheme changes 32" call assert_match("\nSearch xxx term=reverse cterm=reverse ctermfg=196 ctermbg=16 gui=reverse guifg=#ff0000 guibg=#000000", a) 33" call assert_match("\nSearch xxx term=reverse ", a) 34 35call assert_fails ( 'colorscheme does_not_exist' , 'E185:' ) 36call assert_equal ( 'does_not_exist' , g: color_pre ) 37call assert_equal ( 'torte' , g: color_after ) 38 39exec 'colorscheme' colorscheme_saved 40augroup TestColors 41au ! 42augroup END 43unlet g: color_count g: after_colors g: before_colors 44redraw ! 45endfunc 46 47func Test_gui_recursive_mapping () 48nmap '< C-W > 49nmap < C-W > a :let didit = 1< CR > 50call feedkeys ( "'a" , 'xt' ) 51call assert_equal ( 1 , didit ) 52 53nunmap ' 54nunmap <C-W>a 55endfunc 56 57" Test that Buffers menu generates the correct index for different buffer 58" names for sorting. 59func Test_Buffers_Menu () 60doautocmd LoadBufferMenu VimEnter 61 62" Non-ASCII characters only use the first character as idx 63let idx_emoji = or ( char2nr ( 'π' ), 0x40000000 ) 64 65" Only first five letters are used for alphanumeric: 66" ('a'-32) << 24 + ('b'-32) << 18 + ('c'-32) << 12 + ('d'-32) << 6 + ('e'-32) 67let idx_abcde = 0x218A3925 68" ('a'-32) << 24 + ('b'-32) << 18 + ('c'-32) << 12 + ('d'-32) << 6 + ('f'-32) 69let idx_abcdf = 0x218A3926 70" ('a'-32) << 24 + 63 (clamped) << 18 + ('c'-32) << 12 + ('d'-32) << 6 + ('e'-32) 71let idx_a_emoji_cde = 0x21FE3925 72 73let names = [ 'π' , 'π1' , 'π2' , 'abcde' , 'abcdefghi' , 'abcdf' , 'aπcde' ] 74let indices = [ idx_emoji , idx_emoji , idx_emoji , idx_abcde , idx_abcde , idx_abcdf , idx_a_emoji_cde ] 75for i in range ( len ( names )) 76let name = names [ i ] 77let idx = indices [ i ] 78exe ':badd ' .. name 79let nr = bufnr ( '$' ) 80 81let cmd = printf ( ':amenu Buffers.%s\ (%d)' , name , nr ) 82let menu = split ( execute ( cmd ), '\n' )[ 1 ] 83call assert_inrange ( 0 , 0x7FFFFFFF , idx ) 84call assert_match ( '^' .. idx .. ' ' .. name , menu ) 85endfor 86 87 %bw ! 88endfunc 89 90" vim: shiftwidth=2 sts=2 expandtab