To: vim_dev@googlegroups.com Subject: Patch 8.2.5049 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.5049 Problem: Insufficient tests for autocommands. Solution: Add a few more tests. (Yegappan Lakshmanan, closes #10507) Files: src/autocmd.c, src/testdir/gen_opt_test.vim, src/testdir/test_autocmd.vim, src/testdir/test_cmdline.vim *** ../vim-8.2.5048/src/autocmd.c 2022-05-27 21:16:29.297019075 +0100 --- src/autocmd.c 2022-06-01 12:26:35.114774855 +0100 *************** *** 3161,3193 **** for (ac = ap->cmds; ac != NULL; ac = ac->next) { event_dict = dict_alloc(); ! if (event_dict == NULL) return; ! if (list_append_dict(event_list, event_dict) == FAIL) ! return; ! ! if (dict_add_string(event_dict, "event", event_name) == FAIL) ! return; ! ! if (dict_add_string(event_dict, "group", group_name == NULL ! ? (char_u *)"" : group_name) == FAIL) ! return; ! ! if (ap->buflocal_nr != 0) ! if (dict_add_number(event_dict, "bufnr", ap->buflocal_nr) ! == 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; } } --- 3161,3183 ---- for (ac = ap->cmds; ac != NULL; ac = ac->next) { event_dict = dict_alloc(); ! if (event_dict == NULL ! || list_append_dict(event_list, event_dict) == FAIL) return; ! if (dict_add_string(event_dict, "event", event_name) == FAIL ! || dict_add_string(event_dict, "group", ! group_name == NULL ? (char_u *)"" ! : group_name) == FAIL ! || (ap->buflocal_nr != 0 ! && (dict_add_number(event_dict, "bufnr", ! ap->buflocal_nr) == FAIL)) ! || dict_add_string(event_dict, "pattern", ! ap->pat) == FAIL ! || dict_add_string(event_dict, "cmd", ac->cmd) == FAIL ! || dict_add_bool(event_dict, "once", ac->once) == FAIL ! || dict_add_bool(event_dict, "nested", ! ac->nested) == FAIL) return; } } *** ../vim-8.2.5048/src/testdir/gen_opt_test.vim 2022-03-02 20:11:59.289532141 +0000 --- src/testdir/gen_opt_test.vim 2022-06-01 12:21:02.759079453 +0100 *************** *** 90,96 **** \ 'display': [['', 'lastline', 'lastline,uhex'], ['xxx']], \ 'eadirection': [['', 'both', 'ver'], ['xxx', 'ver,hor']], \ 'encoding': [['latin1'], ['xxx', '']], ! \ 'eventignore': [['', 'WinEnter', 'WinLeave,winenter'], ['xxx']], \ 'fileencoding': [['', 'latin1', 'xxx'], []], \ 'fileformat': [['', 'dos', 'unix'], ['xxx']], \ 'fileformats': [['', 'dos', 'dos,unix'], ['xxx']], --- 90,96 ---- \ 'display': [['', 'lastline', 'lastline,uhex'], ['xxx']], \ 'eadirection': [['', 'both', 'ver'], ['xxx', 'ver,hor']], \ 'encoding': [['latin1'], ['xxx', '']], ! \ 'eventignore': [['', 'WinEnter', 'WinLeave,winenter', 'all,WinEnter'], ['xxx']], \ 'fileencoding': [['', 'latin1', 'xxx'], []], \ 'fileformat': [['', 'dos', 'unix'], ['xxx']], \ 'fileformats': [['', 'dos', 'dos,unix'], ['xxx']], *** ../vim-8.2.5048/src/testdir/test_autocmd.vim 2022-05-27 18:05:28.335620087 +0100 --- src/testdir/test_autocmd.vim 2022-06-01 12:21:02.759079453 +0100 *************** *** 3384,3389 **** --- 3384,3395 ---- let l = [#{group: 'TestAcSet', event: 'BufAdd', bufnr: 9999, \ cmd: 'echo "bufadd"'}] 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: [], \ cmd: 'echo "bufread"'}] call assert_fails("echo autocmd_add(l)", 'E745:') *************** *** 3479,3484 **** --- 3485,3491 ---- " Test for invalid values for 'pattern' item let l = [#{group: 'TestAcSet', event: "BufEnter", \ pattern: test_null_string(), cmd: 'echo "bufcmds"'}] + call assert_fails('call autocmd_add(l)', 'E928:') let l = [#{group: 'TestAcSet', event: "BufEnter", \ pattern: test_null_list(), cmd: 'echo "bufcmds"'}] call assert_fails('call autocmd_add(l)', 'E714:') *************** *** 3555,3560 **** --- 3562,3570 ---- " Delete a non-existing autocmd pattern let l = [#{group: 'TestAcSet', event: 'BufAdd', pat: 'abc'}] 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 augroup TestAcSet *** ../vim-8.2.5048/src/testdir/test_cmdline.vim 2022-05-17 20:10:58.744361606 +0100 --- src/testdir/test_cmdline.vim 2022-06-01 12:21:02.759079453 +0100 *************** *** 1063,1072 **** --- 1063,1081 ---- augroup END call feedkeys(":augroup X\\\"\", 'xt') call assert_equal("\"augroup XTest.test", @:) + + " group name completion in :autocmd call feedkeys(":au X\\\"\", 'xt') call assert_equal("\"au XTest.test", @:) + call feedkeys(":au XTest.test\\\"\", 'xt') + call assert_equal("\"au XTest.test", @:) + augroup! XTest.test + " autocmd pattern completion + call feedkeys(":au BufEnter *.py\\\"\", 'xt') + call assert_equal("\"au BufEnter *.py\t", @:) + " completion for the :unlet command call feedkeys(":unlet one two\\\"\", 'xt') call assert_equal("\"unlet one two", @:) *** ../vim-8.2.5048/src/version.c 2022-05-31 17:03:11.271702930 +0100 --- src/version.c 2022-06-01 12:28:43.238681449 +0100 *************** *** 736,737 **** --- 736,739 ---- { /* Add new patch number below this line */ + /**/ + 5049, /**/ -- Vim is like Emacs without all the typing. (John "Johann" Spetz) /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///