aboutsummaryrefslogtreecommitdiff
path: root/test/functional/legacy/crash_spec.lua
blob: b63b3146f4038d226f16f01a34f005be789ffe94 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
local t = require('test.testutil')
local n = require('test.functional.testnvim')()

local assert_alive = n.assert_alive
local clear = n.clear
local command = n.command
local eq = t.eq
local eval = n.eval
local exec = n.exec
local feed = n.feed
local pcall_err = t.pcall_err

before_each(clear)

it('no crash when ending Visual mode while editing buffer closes window', function()
  command('new')
  command('autocmd ModeChanged v:n ++once close')
  feed('v')
  command('enew')
  assert_alive()
end)

it('no crash when ending Visual mode close the window to switch to', function()
  command('new')
  command('autocmd ModeChanged v:n ++once only')
  feed('v')
  command('wincmd p')
  assert_alive()
end)

it('no crash when truncating overlong message', function()
  pcall(command, 'source test/old/testdir/crash/vim_msg_trunc_poc')
  assert_alive()
end)

it('no crash with very long option error message', function()
  pcall(command, 'source test/old/testdir/crash/poc_did_set_langmap')
  assert_alive()
end)

it('no crash when closing window with tag in loclist', function()
  exec([[
    new
    lexpr ['foo']
    lopen
    let g:qf_bufnr = bufnr()
    lclose
    call settagstack(1, #{items: [#{tagname: 'foo', from: [g:qf_bufnr, 1, 1, 0]}]})
  ]])
  eq(1, eval('bufexists(g:qf_bufnr)'))
  command('1close')
  eq(0, eval('bufexists(g:qf_bufnr)'))
  assert_alive()
end)

it('no crash when writing "Untitled" file fails', function()
  t.mkdir('Untitled')
  finally(function()
    vim.uv.fs_rmdir('Untitled')
  end)
  feed('ifoobar')
  command('set bufhidden=unload')
  eq('Vim(enew):E502: "Untitled" is a directory', pcall_err(command, 'confirm enew'))
  assert_alive()
end)