2014-11-08 13:17:04 -07:00
|
|
|
-- Test that groups and patterns are tested correctly when calling exists() for
|
|
|
|
-- autocommands.
|
|
|
|
|
2016-04-23 16:53:11 -07:00
|
|
|
local helpers = require('test.functional.helpers')(after_each)
|
2015-11-17 15:31:22 -07:00
|
|
|
local clear = helpers.clear
|
2017-04-08 14:12:26 -07:00
|
|
|
local command, expect = helpers.command, helpers.expect
|
2014-11-08 13:17:04 -07:00
|
|
|
|
|
|
|
describe('augroup when calling exists()', function()
|
|
|
|
setup(clear)
|
|
|
|
|
|
|
|
it('is working', function()
|
2017-04-08 14:12:26 -07:00
|
|
|
command('let results=[]')
|
|
|
|
command('call add(results, "##BufEnter: " . exists("##BufEnter"))')
|
|
|
|
command('call add(results, "#BufEnter: " . exists("#BufEnter"))')
|
|
|
|
command('au BufEnter * let g:entered=1')
|
|
|
|
command('call add(results, "#BufEnter: " . exists("#BufEnter"))')
|
|
|
|
command('call add(results, "#auexists#BufEnter: " . exists("#auexists#BufEnter"))')
|
2017-04-08 16:00:06 -07:00
|
|
|
command('augroup auexists')
|
|
|
|
command('au BufEnter * let g:entered=1')
|
|
|
|
command('augroup END')
|
2017-04-08 14:12:26 -07:00
|
|
|
command('call add(results, "#auexists#BufEnter: " . exists("#auexists#BufEnter"))')
|
|
|
|
command('call add(results, "#BufEnter#*.test: " . exists("#BufEnter#*.test"))')
|
|
|
|
command('au BufEnter *.test let g:entered=1')
|
|
|
|
command('call add(results, "#BufEnter#*.test: " . exists("#BufEnter#*.test"))')
|
|
|
|
command('edit testfile.test')
|
|
|
|
command('call add(results, "#BufEnter#<buffer>: " . exists("#BufEnter#<buffer>"))')
|
|
|
|
command('au BufEnter <buffer> let g:entered=1')
|
|
|
|
command('call add(results, "#BufEnter#<buffer>: " . exists("#BufEnter#<buffer>"))')
|
|
|
|
command('edit testfile2.test')
|
|
|
|
command('call add(results, "#BufEnter#<buffer>: " . exists("#BufEnter#<buffer>"))')
|
|
|
|
command('bf')
|
|
|
|
command('call append(0, results)')
|
|
|
|
command('$d')
|
2014-11-08 13:17:04 -07:00
|
|
|
|
|
|
|
-- Assert buffer contents.
|
|
|
|
expect([[
|
|
|
|
##BufEnter: 1
|
|
|
|
#BufEnter: 0
|
|
|
|
#BufEnter: 1
|
|
|
|
#auexists#BufEnter: 0
|
|
|
|
#auexists#BufEnter: 1
|
|
|
|
#BufEnter#*.test: 0
|
|
|
|
#BufEnter#*.test: 1
|
|
|
|
#BufEnter#<buffer>: 0
|
|
|
|
#BufEnter#<buffer>: 1
|
|
|
|
#BufEnter#<buffer>: 0]])
|
|
|
|
end)
|
|
|
|
end)
|