robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

Justin M. KeyesMerge #40865 from justinmk/fixcif907614088

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