aboutsummaryrefslogtreecommitdiff
path: root/test/functional/autocmd/autocmd_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/autocmd/autocmd_spec.lua')
-rw-r--r--test/functional/autocmd/autocmd_spec.lua31
1 files changed, 29 insertions, 2 deletions
diff --git a/test/functional/autocmd/autocmd_spec.lua b/test/functional/autocmd/autocmd_spec.lua
index 72aff58d73..8ee9462a8d 100644
--- a/test/functional/autocmd/autocmd_spec.lua
+++ b/test/functional/autocmd/autocmd_spec.lua
@@ -1,8 +1,13 @@
local helpers = require('test.functional.helpers')(after_each)
+local eq = helpers.eq
+local eval = helpers.eval
local clear = helpers.clear
+local meths = helpers.meths
+local expect = helpers.expect
local command = helpers.command
-local eval = helpers.eval
+local exc_exec = helpers.exc_exec
+local curbufmeths = helpers.curbufmeths
describe('autocmds:', function()
before_each(clear)
@@ -11,8 +16,8 @@ describe('autocmds:', function()
local expected = {
'WinLeave',
'TabLeave',
- 'TabNew',
'WinEnter',
+ 'TabNew',
'TabEnter',
'BufLeave',
'BufEnter'
@@ -28,4 +33,26 @@ describe('autocmds:', function()
command('tabnew')
assert.same(expected, eval('g:foo'))
end)
+
+ it('v:vim_did_enter is 1 after VimEnter', function()
+ eq(1, eval('v:vim_did_enter'))
+ end)
+
+ describe('BufLeave autocommand', function()
+ it('can wipe out the buffer created by :edit which triggered autocmd',
+ function()
+ meths.set_option('hidden', true)
+ curbufmeths.set_lines(0, 1, false, {
+ 'start of test file xx',
+ 'end of test file xx'})
+
+ command('autocmd BufLeave * bwipeout yy')
+ eq('Vim(edit):E143: Autocommands unexpectedly deleted new buffer yy',
+ exc_exec('edit yy'))
+
+ expect([[
+ start of test file xx
+ end of test file xx]])
+ end)
+ end)
end)