mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 8.2.5049: insufficient tests for autocommands
Problem: Insufficient tests for autocommands. Solution: Add a few more tests. (Yegappan Lakshmanan, closes #10507)
This commit is contained in:
parent
b5912e0643
commit
00e977cb83
@ -3161,33 +3161,23 @@ f_autocmd_get(typval_T *argvars, typval_T *rettv)
|
|||||||
for (ac = ap->cmds; ac != NULL; ac = ac->next)
|
for (ac = ap->cmds; ac != NULL; ac = ac->next)
|
||||||
{
|
{
|
||||||
event_dict = dict_alloc();
|
event_dict = dict_alloc();
|
||||||
if (event_dict == NULL)
|
if (event_dict == NULL
|
||||||
|
|| list_append_dict(event_list, event_dict) == FAIL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (list_append_dict(event_list, event_dict) == FAIL)
|
if (dict_add_string(event_dict, "event", event_name) == FAIL
|
||||||
return;
|
|| dict_add_string(event_dict, "group",
|
||||||
|
group_name == NULL ? (char_u *)""
|
||||||
if (dict_add_string(event_dict, "event", event_name) == FAIL)
|
: group_name) == FAIL
|
||||||
return;
|
|| (ap->buflocal_nr != 0
|
||||||
|
&& (dict_add_number(event_dict, "bufnr",
|
||||||
if (dict_add_string(event_dict, "group", group_name == NULL
|
ap->buflocal_nr) == FAIL))
|
||||||
? (char_u *)"" : group_name) == FAIL)
|
|| dict_add_string(event_dict, "pattern",
|
||||||
return;
|
ap->pat) == FAIL
|
||||||
|
|| dict_add_string(event_dict, "cmd", ac->cmd) == FAIL
|
||||||
if (ap->buflocal_nr != 0)
|
|| dict_add_bool(event_dict, "once", ac->once) == FAIL
|
||||||
if (dict_add_number(event_dict, "bufnr", ap->buflocal_nr)
|
|| dict_add_bool(event_dict, "nested",
|
||||||
== FAIL)
|
ac->nested) == FAIL)
|
||||||
return;
|
|
||||||
|
|
||||||
if (dict_add_string(event_dict, "pattern", ap->pat) == FAIL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (dict_add_string(event_dict, "cmd", ac->cmd) == FAIL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (dict_add_bool(event_dict, "once", ac->once) == FAIL)
|
|
||||||
return;
|
|
||||||
if (dict_add_bool(event_dict, "nested", ac->nested) == FAIL)
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ let test_values = {
|
|||||||
\ 'display': [['', 'lastline', 'lastline,uhex'], ['xxx']],
|
\ 'display': [['', 'lastline', 'lastline,uhex'], ['xxx']],
|
||||||
\ 'eadirection': [['', 'both', 'ver'], ['xxx', 'ver,hor']],
|
\ 'eadirection': [['', 'both', 'ver'], ['xxx', 'ver,hor']],
|
||||||
\ 'encoding': [['latin1'], ['xxx', '']],
|
\ 'encoding': [['latin1'], ['xxx', '']],
|
||||||
\ 'eventignore': [['', 'WinEnter', 'WinLeave,winenter'], ['xxx']],
|
\ 'eventignore': [['', 'WinEnter', 'WinLeave,winenter', 'all,WinEnter'], ['xxx']],
|
||||||
\ 'fileencoding': [['', 'latin1', 'xxx'], []],
|
\ 'fileencoding': [['', 'latin1', 'xxx'], []],
|
||||||
\ 'fileformat': [['', 'dos', 'unix'], ['xxx']],
|
\ 'fileformat': [['', 'dos', 'unix'], ['xxx']],
|
||||||
\ 'fileformats': [['', 'dos', 'dos,unix'], ['xxx']],
|
\ 'fileformats': [['', 'dos', 'dos,unix'], ['xxx']],
|
||||||
|
@ -3384,6 +3384,12 @@ func Test_autocmd_add()
|
|||||||
let l = [#{group: 'TestAcSet', event: 'BufAdd', bufnr: 9999,
|
let l = [#{group: 'TestAcSet', event: 'BufAdd', bufnr: 9999,
|
||||||
\ cmd: 'echo "bufadd"'}]
|
\ cmd: 'echo "bufadd"'}]
|
||||||
call assert_fails("echo autocmd_add(l)", 'E680:')
|
call assert_fails("echo autocmd_add(l)", 'E680:')
|
||||||
|
let l = [#{group: 'TestAcSet', event: 'BufAdd', bufnr: 9999,
|
||||||
|
\ pattern: '*.py', cmd: 'echo "bufadd"'}]
|
||||||
|
call assert_fails("echo autocmd_add(l)", 'E680:')
|
||||||
|
let l = [#{group: 'TestAcSet', event: 'BufAdd', bufnr: 9999,
|
||||||
|
\ pattern: ['*.py', '*.c'], cmd: 'echo "bufadd"'}]
|
||||||
|
call assert_fails("echo autocmd_add(l)", 'E680:')
|
||||||
let l = [#{group: 'TestAcSet', event: 'BufRead', bufnr: [],
|
let l = [#{group: 'TestAcSet', event: 'BufRead', bufnr: [],
|
||||||
\ cmd: 'echo "bufread"'}]
|
\ cmd: 'echo "bufread"'}]
|
||||||
call assert_fails("echo autocmd_add(l)", 'E745:')
|
call assert_fails("echo autocmd_add(l)", 'E745:')
|
||||||
@ -3479,6 +3485,7 @@ func Test_autocmd_add()
|
|||||||
" Test for invalid values for 'pattern' item
|
" Test for invalid values for 'pattern' item
|
||||||
let l = [#{group: 'TestAcSet', event: "BufEnter",
|
let l = [#{group: 'TestAcSet', event: "BufEnter",
|
||||||
\ pattern: test_null_string(), cmd: 'echo "bufcmds"'}]
|
\ pattern: test_null_string(), cmd: 'echo "bufcmds"'}]
|
||||||
|
call assert_fails('call autocmd_add(l)', 'E928:')
|
||||||
let l = [#{group: 'TestAcSet', event: "BufEnter",
|
let l = [#{group: 'TestAcSet', event: "BufEnter",
|
||||||
\ pattern: test_null_list(), cmd: 'echo "bufcmds"'}]
|
\ pattern: test_null_list(), cmd: 'echo "bufcmds"'}]
|
||||||
call assert_fails('call autocmd_add(l)', 'E714:')
|
call assert_fails('call autocmd_add(l)', 'E714:')
|
||||||
@ -3555,6 +3562,9 @@ func Test_autocmd_delete()
|
|||||||
" Delete a non-existing autocmd pattern
|
" Delete a non-existing autocmd pattern
|
||||||
let l = [#{group: 'TestAcSet', event: 'BufAdd', pat: 'abc'}]
|
let l = [#{group: 'TestAcSet', event: 'BufAdd', pat: 'abc'}]
|
||||||
call assert_true(autocmd_delete(l))
|
call assert_true(autocmd_delete(l))
|
||||||
|
" Delete an autocmd for a non-existing buffer
|
||||||
|
let l = [#{event: '*', bufnr: 9999, cmd: 'echo "x"'}]
|
||||||
|
call assert_fails('call autocmd_delete(l)', 'E680:')
|
||||||
|
|
||||||
" Delete an autocmd group
|
" Delete an autocmd group
|
||||||
augroup TestAcSet
|
augroup TestAcSet
|
||||||
|
@ -1063,10 +1063,19 @@ func Test_cmdline_complete_various()
|
|||||||
augroup END
|
augroup END
|
||||||
call feedkeys(":augroup X\<C-A>\<C-B>\"\<CR>", 'xt')
|
call feedkeys(":augroup X\<C-A>\<C-B>\"\<CR>", 'xt')
|
||||||
call assert_equal("\"augroup XTest.test", @:)
|
call assert_equal("\"augroup XTest.test", @:)
|
||||||
|
|
||||||
|
" group name completion in :autocmd
|
||||||
call feedkeys(":au X\<C-A>\<C-B>\"\<CR>", 'xt')
|
call feedkeys(":au X\<C-A>\<C-B>\"\<CR>", 'xt')
|
||||||
call assert_equal("\"au XTest.test", @:)
|
call assert_equal("\"au XTest.test", @:)
|
||||||
|
call feedkeys(":au XTest.test\<Tab>\<C-B>\"\<CR>", 'xt')
|
||||||
|
call assert_equal("\"au XTest.test", @:)
|
||||||
|
|
||||||
augroup! XTest.test
|
augroup! XTest.test
|
||||||
|
|
||||||
|
" autocmd pattern completion
|
||||||
|
call feedkeys(":au BufEnter *.py\<Tab>\<C-B>\"\<CR>", 'xt')
|
||||||
|
call assert_equal("\"au BufEnter *.py\t", @:)
|
||||||
|
|
||||||
" completion for the :unlet command
|
" completion for the :unlet command
|
||||||
call feedkeys(":unlet one two\<C-A>\<C-B>\"\<CR>", 'xt')
|
call feedkeys(":unlet one two\<C-A>\<C-B>\"\<CR>", 'xt')
|
||||||
call assert_equal("\"unlet one two", @:)
|
call assert_equal("\"unlet one two", @:)
|
||||||
|
@ -734,6 +734,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
5049,
|
||||||
/**/
|
/**/
|
||||||
5048,
|
5048,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user