neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

crash_spec.lua (1965B)


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