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
|
-- Test that groups and patterns are tested correctly when calling exists() for
-- autocommands.
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local command, expect = helpers.command, helpers.expect
describe('augroup when calling exists()', function()
setup(clear)
it('is working', function()
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"))')
command('augroup auexists')
command('au BufEnter * let g:entered=1')
command('augroup END')
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')
-- 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)
|