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 it , before_each , finally =t . it , t . before_each , t . finally 6local clear =n . clear 7local write_file =t . write_file 8local command =n . command 9local feed =n . feed 10local api =n . api 11local eq =t . eq 12 13before_each ( clear ) 14 15local function expected_empty () 16eq ( {} , api . nvim_get_vvar ( 'errors' )) 17end 18 19-- oldtest: Test_get_Visual_selection_in_curbuf_autocmd() 20it ( 'autocmd can get Visual selection when using setbufvar() on curbuf' , function () 21n . exec ( [[ 22new 23autocmd OptionSet list let b:text = getregion(getpos('.'), getpos('v')) 24call setline(1, 'foo bar baz') 25 26normal! gg0fbvtb 27setlocal list 28call assert_equal(['bar '], b:text) 29exe "normal! \<Esc>" 30 31normal! v0 32call setbufvar('%', '&list', v:false) 33call assert_equal(['foo bar '], b:text) 34exe "normal! \<Esc>" 35]] ) 36expected_empty () 37end ) 38 39-- oldtest: Test_autocmd_invalidates_undo_on_textchanged() 40it ( 'no E440 in quickfix window when autocommand invalidates undo' , function () 41write_file ( 42'XTest_autocmd_invalidates_undo_on_textchanged' , 43[[ 44set hidden 45" create quickfix list (at least 2 lines to move line) 46vimgrep /u/j % 47 48" enter quickfix window 49cwindow 50 51" set modifiable 52setlocal modifiable 53 54" set autocmd to clear quickfix list 55 56autocmd! TextChanged <buffer> call setqflist([]) 57" move line 58move+1 59]] 60) 61finally ( function () 62os . remove ( 'XTest_autocmd_invalidates_undo_on_textchanged' ) 63end ) 64command ( 'edit XTest_autocmd_invalidates_undo_on_textchanged' ) 65command ( 'so %' ) 66feed ( 'G' ) 67eq ( '' , api . nvim_get_vvar ( 'errmsg' )) 68end ) 69 70-- oldtest: Test_WinScrolled_Resized_eiw() 71it ( 'WinScrolled and WinResized events can be ignored in a window' , function () 72local screen =Screen . new () 73n . exec ( [[ 74call setline(1, ['foo']->repeat(32)) 75set eventignorewin=WinScrolled,WinResized 76split 77let [g:afile,g:resized,g:scrolled] = ['none',0,0] 78au WinScrolled * let [g:afile,g:scrolled] = [expand('<afile>'),g:scrolled+1] 79au WinResized * let [g:afile,g:resized] = [expand('<afile>'),g:resized+1] 80]] ) 81feed ( '<C-W>-' ) 82screen : expect ( [[ 83^foo | 84foo |*4 85{3:[No Name] [+] }| 86foo |*6 87{2:[No Name] [+] }| 88| 89]] ) 90feed ( ':echo g:afile g:resized g:scrolled<CR>' ) 91screen : expect ( { any ='none 0 0.*' } ) 92feed ( 'G' ) 93screen : expect ( [[ 94foo |*4 95^foo | 96{3:[No Name] [+] }| 97foo |*6 98{2:[No Name] [+] }| 99none 0 0 | 100]] ) 101feed ( 'gg' ) 102screen : expect ( [[ 103^foo | 104foo |*4 105{3:[No Name] [+] }| 106foo |*6 107{2:[No Name] [+] }| 108none 0 0 | 109]] ) 110feed ( ':echo g:afile g:resized g:scrolled' ) 111screen : expect ( { any =':echo g:afile g:resized g:scrolled.*' } ) 112feed ( '<CR>' ) 113screen : expect ( { any ='none 0 0.*' } ) 114feed ( ':set eventignorewin=<CR><C-W>w<C-W>+' ) 115screen : expect ( { any =':set eventignorewin=.*' } ) 116feed ( ':echo win_getid() g:afile g:resized g:scrolled<CR>' ) 117screen : expect ( { any ='1000 1001 1 1.*' } ) 118end ) 119 120-- oldtest: Test_CmdlineLeavePre_cabbr() 121it ( ':cabbr does not cause a spurious CmdlineLeavePre' , function () 122command ( 'let g:a = 0' ) 123command ( 'cabbr v v' ) 124command ( 'command! -nargs=* Foo echo' ) 125command ( 'au! CmdlineLeavePre * let g:a += 1' ) 126feed ( ':Foo v<CR>' ) 127eq ( 1 , api . nvim_get_var ( 'a' )) 128end )