diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2022-08-07 16:01:34 -0600 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2022-08-07 16:01:34 -0600 |
commit | a5f27a311fb28797a72b8aa16ec7122c5a1b15e4 (patch) | |
tree | 3732f7339e29431f31310aef6ffc802cf4f6255d /test | |
parent | 6c909fedc924d9f4257aa204b0168c6177cc5d28 (diff) | |
parent | 629169462a82f0fbb7a8911a4554894537d6776c (diff) | |
download | rneovim-a5f27a311fb28797a72b8aa16ec7122c5a1b15e4.tar.gz rneovim-a5f27a311fb28797a72b8aa16ec7122c5a1b15e4.tar.bz2 rneovim-a5f27a311fb28797a72b8aa16ec7122c5a1b15e4.zip |
Merge branch 'master' of https://github.com/neovim/neovim into rahm
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/api/buffer_spec.lua | 12 | ||||
-rw-r--r-- | test/functional/api/keymap_spec.lua | 6 | ||||
-rw-r--r-- | test/functional/api/vim_spec.lua | 7 | ||||
-rw-r--r-- | test/functional/core/exit_spec.lua | 6 | ||||
-rw-r--r-- | test/functional/editor/completion_spec.lua | 6 | ||||
-rw-r--r-- | test/functional/editor/tabpage_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/ex_cmds/excmd_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/legacy/062_tab_pages_spec.lua | 239 | ||||
-rw-r--r-- | test/functional/terminal/window_split_tab_spec.lua | 33 | ||||
-rw-r--r-- | test/functional/ui/statusline_spec.lua | 37 | ||||
-rw-r--r-- | test/functional/vimscript/let_spec.lua | 2 | ||||
-rw-r--r-- | test/includes/CMakeLists.txt | 2 |
12 files changed, 100 insertions, 254 deletions
diff --git a/test/functional/api/buffer_spec.lua b/test/functional/api/buffer_spec.lua index dc668e7201..8f6fc666c9 100644 --- a/test/functional/api/buffer_spec.lua +++ b/test/functional/api/buffer_spec.lua @@ -7,6 +7,7 @@ local meths = helpers.meths local funcs = helpers.funcs local request = helpers.request local exc_exec = helpers.exc_exec +local exec_lua = helpers.exec_lua local feed_command = helpers.feed_command local insert = helpers.insert local NIL = helpers.NIL @@ -565,6 +566,17 @@ describe('api/buf', function() eq('start is higher than end', pcall_err(set_text, 1, 0, 0, 0, {})) eq('start is higher than end', pcall_err(set_text, 0, 1, 0, 0, {})) end) + + it('no heap-use-after-free when called consecutively #19643', function() + set_text(0, 0, 0, 0, {'one', '', '', 'two'}) + eq({'one', '', '', 'two'}, get_lines(0, 4, true)) + meths.win_set_cursor(0, {1, 0}) + exec_lua([[ + vim.api.nvim_buf_set_text(0, 0, 3, 1, 0, {''}) + vim.api.nvim_buf_set_text(0, 0, 3, 1, 0, {''}) + ]]) + eq({'one', 'two'}, get_lines(0, 2, true)) + end) end) describe('nvim_buf_get_text', function() diff --git a/test/functional/api/keymap_spec.lua b/test/functional/api/keymap_spec.lua index eb2a467a8b..a93a4544ff 100644 --- a/test/functional/api/keymap_spec.lua +++ b/test/functional/api/keymap_spec.lua @@ -822,7 +822,7 @@ describe('nvim_set_keymap, nvim_del_keymap', function() vim.api.nvim_set_keymap ('n', 'asdf', '', {callback = function() print('jkl;') end }) ]] assert.truthy(string.match(exec_lua[[return vim.api.nvim_exec(':nmap asdf', true)]], - "^\nn asdf <Lua function %d+>")) + "^\nn asdf <Lua %d+>")) end) it ('mapcheck() returns lua mapping correctly', function() @@ -830,7 +830,7 @@ describe('nvim_set_keymap, nvim_del_keymap', function() vim.api.nvim_set_keymap ('n', 'asdf', '', {callback = function() print('jkl;') end }) ]] assert.truthy(string.match(funcs.mapcheck('asdf', 'n'), - "^<Lua function %d+>")) + "^<Lua %d+>")) end) it ('maparg() returns lua mapping correctly', function() @@ -838,7 +838,7 @@ describe('nvim_set_keymap, nvim_del_keymap', function() vim.api.nvim_set_keymap ('n', 'asdf', '', {callback = function() print('jkl;') end }) ]] assert.truthy(string.match(funcs.maparg('asdf', 'n'), - "^<Lua function %d+>")) + "^<Lua %d+>")) local mapargs = funcs.maparg('asdf', 'n', false, true) assert(type(mapargs.callback) == 'number', 'callback is not luaref number') mapargs.callback = nil diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 17de6730fb..fe623ff824 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -3822,5 +3822,12 @@ describe('API', function() feed("[l") neq(nil, string.find(eval("v:errmsg"), "E5108:")) end) + it('handles 0 range #19608', function() + meths.buf_set_lines(0, 0, -1, false, { "aa" }) + meths.cmd({ cmd = 'delete', range = { 0 } }, {}) + command('undo') + eq({'aa'}, meths.buf_get_lines(0, 0, 1, false)) + assert_alive() + end) end) end) diff --git a/test/functional/core/exit_spec.lua b/test/functional/core/exit_spec.lua index a47e7568a9..4dba58dbfc 100644 --- a/test/functional/core/exit_spec.lua +++ b/test/functional/core/exit_spec.lua @@ -87,14 +87,14 @@ describe(':cquit', function() end) it('exits with redir msg for multiple exit codes after :cquit 1 2', function() - test_cq('cquit 1 2', nil, 'Vim(cquit):E488: Trailing characters: cquit 1 2') + test_cq('cquit 1 2', nil, 'Vim(cquit):E488: Trailing characters: 2: cquit 1 2') end) it('exits with redir msg for non-number exit code after :cquit X', function() - test_cq('cquit X', nil, 'Vim(cquit):E488: Trailing characters: cquit X') + test_cq('cquit X', nil, 'Vim(cquit):E488: Trailing characters: X: cquit X') end) it('exits with redir msg for negative exit code after :cquit -1', function() - test_cq('cquit -1', nil, 'Vim(cquit):E488: Trailing characters: cquit -1') + test_cq('cquit -1', nil, 'Vim(cquit):E488: Trailing characters: -1: cquit -1') end) end) diff --git a/test/functional/editor/completion_spec.lua b/test/functional/editor/completion_spec.lua index e27da0947f..6cdac3c079 100644 --- a/test/functional/editor/completion_spec.lua +++ b/test/functional/editor/completion_spec.lua @@ -1253,4 +1253,10 @@ describe('completion', function() feed('ifoo#<C-X><C-U>') assert_alive() end) + + it('does not crash when using i_CTRL-X_CTRL-V to complete non-existent colorscheme', function() + feed('icolorscheme NOSUCHCOLORSCHEME<C-X><C-V>') + expect('colorscheme NOSUCHCOLORSCHEME') + assert_alive() + end) end) diff --git a/test/functional/editor/tabpage_spec.lua b/test/functional/editor/tabpage_spec.lua index 7dd0b9f154..849a02c28b 100644 --- a/test/functional/editor/tabpage_spec.lua +++ b/test/functional/editor/tabpage_spec.lua @@ -59,7 +59,7 @@ describe('tabpage', function() screen:set_default_attr_ids({ [0] = {bold = true, foreground = Screen.colors.Blue}, [1] = {bold = true, reverse = true}, -- StatusLine - [2] = {reverse = true}, -- StatusLineNC, TabLineFill + [2] = {reverse = true}, -- TabLineFill [3] = {bold = true}, -- TabLineSel [4] = {background = Screen.colors.LightGrey, underline = true}, -- TabLine [5] = {bold = true, foreground = Screen.colors.Magenta}, diff --git a/test/functional/ex_cmds/excmd_spec.lua b/test/functional/ex_cmds/excmd_spec.lua index 33794eb50d..e243f3c524 100644 --- a/test/functional/ex_cmds/excmd_spec.lua +++ b/test/functional/ex_cmds/excmd_spec.lua @@ -16,7 +16,7 @@ describe('Ex cmds', function() command(':echo expand("#<9999999999999999999999999999999999999999")') command(':lockvar 9999999999999999999999999999999999999999') command(':winsize 9999999999999999999999999999999999999999 9999999999999999999999999999999999999999') - eq('Vim(tabnext):E474: Invalid argument', + eq('Vim(tabnext):E475: Invalid argument: 9999999999999999999999999999999999999999', pcall_err(command, ':tabnext 9999999999999999999999999999999999999999')) eq('Vim(Next):E939: Positive count required', pcall_err(command, ':N 9999999999999999999999999999999999999999')) diff --git a/test/functional/legacy/062_tab_pages_spec.lua b/test/functional/legacy/062_tab_pages_spec.lua deleted file mode 100644 index eae0a8d51a..0000000000 --- a/test/functional/legacy/062_tab_pages_spec.lua +++ /dev/null @@ -1,239 +0,0 @@ --- Tests for tab pages - -local helpers = require('test.functional.helpers')(after_each) -local feed, insert, source, clear, command, expect, eval, eq = - helpers.feed, helpers.insert, helpers.source, helpers.clear, - helpers.command, helpers.expect, helpers.eval, helpers.eq -local exc_exec = helpers.exc_exec - -describe('tab pages', function() - before_each(clear) - - it('can be opened and closed', function() - command('tabnew') - eq(2, eval('tabpagenr()')) - command('quit') - eq(1, eval('tabpagenr()')) - end) - - it('can be iterated with :tabdo', function() - source([[ - 0tabnew - 1tabnew - $tabnew - tabdo call append(line('$'), 'this is tab page ' . tabpagenr()) - tabclose! 2 - tabrewind - ]]) - eq('this is tab page 1', eval("getline('$')")) - command('tablast') - eq('this is tab page 4', eval("getline('$')")) - end) - - it('have local variables accasible with settabvar()/gettabvar()', function() - -- Test for settabvar() and gettabvar() functions. Open a new tab page and - -- set 3 variables to a number, string and a list. Verify that the - -- variables are correctly set. - source([[ - tabnew - tabfirst - call settabvar(2, 'val_num', 100) - call settabvar(2, 'val_str', 'SetTabVar test') - call settabvar(2, 'val_list', ['red', 'blue', 'green']) - ]]) - - eq(100, eval('gettabvar(2, "val_num")')) - eq('SetTabVar test', eval('gettabvar(2, "val_str")')) - eq({'red', 'blue', 'green'}, eval('gettabvar(2, "val_list")')) - command('tabnext 2') - eq(100, eval('t:val_num')) - eq('SetTabVar test', eval('t:val_str')) - eq({'red', 'blue', 'green'}, eval('t:val_list')) - end) - - it('work together with the drop feature and loaded buffers', function() - -- Test for ":tab drop exist-file" to keep current window. - command('sp test1') - command('tab drop test1') - eq(1, eval('tabpagenr("$")')) - eq(2, eval('winnr("$")')) - eq(1, eval('winnr()')) - end) - - it('work together with the drop feature and new files', function() - -- Test for ":tab drop new-file" to keep current window of tabpage 1. - command('split') - command('tab drop newfile') - eq(2, eval('tabpagenr("$")')) - eq(2, eval('tabpagewinnr(1, "$")')) - eq(1, eval('tabpagewinnr(1)')) - end) - - it('work together with the drop feature and multi loaded buffers', function() - -- Test for ":tab drop multi-opend-file" to keep current tabpage and - -- window. - command('new test1') - command('tabnew') - command('new test1') - command('tab drop test1') - eq(2, eval('tabpagenr()')) - eq(2, eval('tabpagewinnr(2, "$")')) - eq(1, eval('tabpagewinnr(2)')) - end) - - it('can be navigated with :tabmove', function() - command('lang C') - command('for i in range(9) | tabnew | endfor') - feed('1gt') - eq(1, eval('tabpagenr()')) - command('tabmove 5') - eq(5, eval('tabpagenr()')) - command('.tabmove') - eq(5, eval('tabpagenr()')) - command('tabmove -') - eq(4, eval('tabpagenr()')) - command('tabmove +') - eq(5, eval('tabpagenr()')) - command('tabmove -2') - eq(3, eval('tabpagenr()')) - command('tabmove +4') - eq(7, eval('tabpagenr()')) - command('tabmove') - eq(10, eval('tabpagenr()')) - command('0tabmove') - eq(1, eval('tabpagenr()')) - command('$tabmove') - eq(10, eval('tabpagenr()')) - command('tabmove 0') - eq(1, eval('tabpagenr()')) - command('tabmove $') - eq(10, eval('tabpagenr()')) - command('3tabmove') - eq(4, eval('tabpagenr()')) - command('7tabmove 5') - eq(5, eval('tabpagenr()')) - command('let a="No error caught."') - eq('Vim(tabmove):E474: Invalid argument: tabmove foo', - exc_exec('tabmove foo')) - end) - - it('can trigger certain autocommands', function() - insert('Results:') - - -- Test autocommands. - source([[ - tabonly! - let g:r=[] - command -nargs=1 -bar C :call add(g:r, '=== '.<q-args>.' ===')|<args> - function Test() - autocmd TabEnter * :call add(g:r, 'TabEnter') - autocmd WinEnter * :call add(g:r, 'WinEnter') - autocmd BufEnter * :call add(g:r, 'BufEnter') - autocmd TabLeave * :call add(g:r, 'TabLeave') - autocmd WinLeave * :call add(g:r, 'WinLeave') - autocmd BufLeave * :call add(g:r, 'BufLeave') - let t:a='a' - C tab split - let t:a='b' - C tabnew - let t:a='c' - call add(g:r, join(map(range(1, tabpagenr('$')), - \ 'gettabvar(v:val, "a")'))) - C call map(range(1, tabpagenr('$')), - \ 'settabvar(v:val, ''a'', v:val*2)') - call add(g:r, join(map(range(1, tabpagenr('$')), - \ 'gettabvar(v:val, "a")'))) - let w:a='a' - C vsplit - let w:a='a' - let tabn=tabpagenr() - let winr=range(1, winnr('$')) - C tabnext 1 - call add(g:r, join(map(copy(winr), - \ 'gettabwinvar('.tabn.', v:val, "a")'))) - C call map(copy(winr), - \ 'settabwinvar('.tabn.', v:val, ''a'', v:val*2)') - call add(g:r, join(map(copy(winr), - \ 'gettabwinvar('.tabn.', v:val, "a")'))) - augroup TabDestructive - autocmd TabEnter * :C tabnext 2 | C tabclose 3 - augroup END - C tabnext 3 - let g:r+=[tabpagenr().'/'.tabpagenr('$')] - autocmd! TabDestructive TabEnter - C tabnew - C tabnext 1 - autocmd TabDestructive TabEnter * nested - \ :C tabnext 2 | C tabclose 3 - C tabnext 2 - let g:r+=[tabpagenr().'/'.tabpagenr('$')] - endfunction - call Test() - $ put =g:r - ]]) - - -- Assert buffer contents. - expect([[ - Results: - === tab split === - WinLeave - TabLeave - WinEnter - TabEnter - === tabnew === - WinLeave - TabLeave - WinEnter - TabEnter - BufLeave - BufEnter - a b c - === call map(range(1, tabpagenr('$')), 'settabvar(v:val, ''a'', v:val*2)') === - 2 4 6 - === vsplit === - WinLeave - WinEnter - === tabnext 1 === - BufLeave - WinLeave - TabLeave - WinEnter - TabEnter - BufEnter - a a - === call map(copy(winr), 'settabwinvar('.tabn.', v:val, ''a'', v:val*2)') === - 2 4 - === tabnext 3 === - BufLeave - WinLeave - TabLeave - WinEnter - TabEnter - === tabnext 2 === - === tabclose 3 === - 2/2 - === tabnew === - WinLeave - TabLeave - WinEnter - TabEnter - BufLeave - BufEnter - === tabnext 1 === - BufLeave - WinLeave - TabLeave - WinEnter - TabEnter - BufEnter - === tabnext 2 === - WinLeave - TabLeave - WinEnter - TabEnter - === tabnext 2 === - === tabclose 3 === - 2/2]]) - eq(2, eval("tabpagenr('$')")) - end) -end) diff --git a/test/functional/terminal/window_split_tab_spec.lua b/test/functional/terminal/window_split_tab_spec.lua index c92107082e..b62d173cea 100644 --- a/test/functional/terminal/window_split_tab_spec.lua +++ b/test/functional/terminal/window_split_tab_spec.lua @@ -2,12 +2,14 @@ local helpers = require('test.functional.helpers')(after_each) local thelpers = require('test.functional.terminal.helpers') local assert_alive = helpers.assert_alive local clear = helpers.clear -local feed, nvim = helpers.feed, helpers.nvim +local feed = helpers.feed local feed_command = helpers.feed_command local command = helpers.command local eq = helpers.eq local eval = helpers.eval +local meths = helpers.meths local iswin = helpers.iswin +local sleep = helpers.sleep local retry = helpers.retry describe(':terminal', function() @@ -17,10 +19,10 @@ describe(':terminal', function() clear() -- set the statusline to a constant value because of variables like pid -- and current directory and to improve visibility of splits - nvim('set_option', 'statusline', '==========') - nvim('command', 'highlight StatusLine cterm=NONE') - nvim('command', 'highlight StatusLineNC cterm=NONE') - nvim('command', 'highlight VertSplit cterm=NONE') + meths.set_option('statusline', '==========') + command('highlight StatusLine cterm=NONE') + command('highlight StatusLineNC cterm=NONE') + command('highlight VertSplit cterm=NONE') screen = thelpers.screen_setup(3) end) @@ -68,6 +70,27 @@ describe(':terminal', function() ]]) end) + it('does not change size if updated when not visible in any window #19665', function() + local channel = meths.buf_get_option(0, 'channel') + command('enew') + sleep(100) + meths.chan_send(channel, 'foo') + sleep(100) + command('bprevious') + screen:expect([[ + tty ready | + ^foo{2: } | + | + | + | + | + | + | + | + | + ]]) + end) + it('forwards resize request to the program', function() feed([[<C-\><C-N>G]]) local w1, h1 = screen._width - 3, screen._height - 2 diff --git a/test/functional/ui/statusline_spec.lua b/test/functional/ui/statusline_spec.lua index 69a2d2f4ed..f3735c8e4c 100644 --- a/test/functional/ui/statusline_spec.lua +++ b/test/functional/ui/statusline_spec.lua @@ -407,3 +407,40 @@ it('statusline does not crash if it has Arabic characters #19447', function() command('redraw!') assert_alive() end) + +it('statusline is redrawn with :resize from <Cmd> mapping #19629', function() + clear() + local screen = Screen.new(40, 8) + screen:set_default_attr_ids({ + [0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText + [1] = {bold = true, reverse = true}, -- StatusLine + }) + screen:attach() + exec([[ + set laststatus=2 + nnoremap <Up> <cmd>resize -1<CR> + nnoremap <Down> <cmd>resize +1<CR> + ]]) + feed('<Up>') + screen:expect([[ + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {1:[No Name] }| + | + | + ]]) + feed('<Down>') + screen:expect([[ + ^ | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {1:[No Name] }| + | + ]]) +end) diff --git a/test/functional/vimscript/let_spec.lua b/test/functional/vimscript/let_spec.lua index 86905199a8..164fa86452 100644 --- a/test/functional/vimscript/let_spec.lua +++ b/test/functional/vimscript/let_spec.lua @@ -29,7 +29,7 @@ describe(':let', function() it(":unlet self-referencing node in a List graph #6070", function() -- :unlet-ing a self-referencing List must not allow GC on indirectly -- referenced in-scope Lists. Before #6070 this caused use-after-free. - expect_exit(100, source, [=[ + expect_exit(1000, source, [=[ let [l1, l2] = [[], []] echo 'l1:' . id(l1) echo 'l2:' . id(l2) diff --git a/test/includes/CMakeLists.txt b/test/includes/CMakeLists.txt index 4d7e962fbd..b4da4c0611 100644 --- a/test/includes/CMakeLists.txt +++ b/test/includes/CMakeLists.txt @@ -16,7 +16,7 @@ endforeach() foreach(hfile ${PRE_HEADERS}) string(REGEX REPLACE ^pre/ post/ post_hfile ${hfile}) - get_filename_component(hdir ${CMAKE_CURRENT_BINARY_DIR}/${post_hfile} PATH) + get_filename_component(hdir ${CMAKE_CURRENT_BINARY_DIR}/${post_hfile} DIRECTORY) file(MAKE_DIRECTORY ${hdir}) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${post_hfile} |