robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
f907614088
master
1local t =require ( 'test.testutil' ) 2local n =require ( 'test.functional.testnvim' )() 3 4local it , before_each , finally =t . it , t . before_each , t . finally 5local assert_alive =n . assert_alive 6local clear =n . clear 7local command =n . command 8local eq =t . eq 9local eval =n . eval 10local exec =n . exec 11local feed =n . feed 12local pcall_err =t . pcall_err 13 14before_each ( clear ) 15 16it ( 'no crash when ending Visual mode while editing buffer closes window' , function () 17command ( 'new' ) 18command ( 'autocmd ModeChanged v:n ++once close' ) 19feed ( 'v' ) 20command ( 'enew' ) 21assert_alive () 22end ) 23 24it ( 'no crash when ending Visual mode close the window to switch to' , function () 25command ( 'new' ) 26command ( 'autocmd ModeChanged v:n ++once only' ) 27feed ( 'v' ) 28command ( 'wincmd p' ) 29assert_alive () 30end ) 31 32it ( 'no crash when truncating overlong message' , function () 33pcall ( command , 'source test/old/testdir/crash/vim_msg_trunc_poc' ) 34assert_alive () 35end ) 36 37it ( 'no crash with very long option error message' , function () 38pcall ( command , 'source test/old/testdir/crash/poc_did_set_langmap' ) 39assert_alive () 40end ) 41 42it ( 'no crash when closing window with tag in loclist' , function () 43exec ( [[ 44new 45lexpr ['foo'] 46lopen 47let g:qf_bufnr = bufnr() 48lclose 49call settagstack(1, #{items: [#{tagname: 'foo', from: [g:qf_bufnr, 1, 1, 0]}]}) 50]] ) 51eq ( 1 , eval ( 'bufexists(g:qf_bufnr)' )) 52command ( '1close' ) 53eq ( 0 , eval ( 'bufexists(g:qf_bufnr)' )) 54assert_alive () 55end ) 56 57it ( 'no crash when writing "Untitled" file fails' , function () 58t . mkdir ( 'Untitled' ) 59finally ( function () 60vim . uv . fs_rmdir ( 'Untitled' ) 61end ) 62feed ( 'ifoobar' ) 63command ( 'set bufhidden=unload' ) 64eq ( 'Vim(enew):E502: "Untitled" is a directory' , pcall_err ( command , 'confirm enew' )) 65assert_alive () 66end ) 67 68-- oldtest: Test_crash_bufwrite() 69it ( 'no crash when converting buffer with incomplete multibyte chars' , function () 70command ( 'edit ++bin test/old/testdir/samples/buffer-test.txt' ) 71finally ( function () 72os . remove ( 'Xoutput' ) 73end ) 74command ( 'w! ++enc=ucs4 Xoutput' ) 75assert_alive () 76end )