diff options
Diffstat (limited to 'test/functional')
-rw-r--r-- | test/functional/autocmd/autocmd_spec.lua | 31 | ||||
-rw-r--r-- | test/functional/autocmd/tabnew_spec.lua | 44 | ||||
-rw-r--r-- | test/functional/legacy/062_tab_pages_spec.lua | 4 | ||||
-rw-r--r-- | test/functional/viml/errorlist_spec.lua | 50 |
4 files changed, 93 insertions, 36 deletions
diff --git a/test/functional/autocmd/autocmd_spec.lua b/test/functional/autocmd/autocmd_spec.lua new file mode 100644 index 0000000000..3c813abc2e --- /dev/null +++ b/test/functional/autocmd/autocmd_spec.lua @@ -0,0 +1,31 @@ +local helpers = require('test.functional.helpers') + +local clear = helpers.clear +local command = helpers.command +local eval = helpers.eval + +describe('autocmds:', function() + before_each(clear) + + it(':tabnew triggers events in the correct order', function() + local expected = { + 'WinLeave', + 'TabLeave', + 'TabNew', + 'WinEnter', + 'TabEnter', + 'BufLeave', + 'BufEnter' + } + command('let g:foo = []') + command('autocmd BufEnter * :call add(g:foo, "BufEnter")') + command('autocmd BufLeave * :call add(g:foo, "BufLeave")') + command('autocmd TabEnter * :call add(g:foo, "TabEnter")') + command('autocmd TabLeave * :call add(g:foo, "TabLeave")') + command('autocmd TabNew * :call add(g:foo, "TabNew")') + command('autocmd WinEnter * :call add(g:foo, "WinEnter")') + command('autocmd WinLeave * :call add(g:foo, "WinLeave")') + command('tabnew') + assert.same(expected, eval('g:foo')) + end) +end) diff --git a/test/functional/autocmd/tabnew_spec.lua b/test/functional/autocmd/tabnew_spec.lua index 5ab504889b..aaf9db0a99 100644 --- a/test/functional/autocmd/tabnew_spec.lua +++ b/test/functional/autocmd/tabnew_spec.lua @@ -1,22 +1,28 @@ local helpers = require('test.functional.helpers') -local clear, nvim, eq = helpers.clear, helpers.nvim, helpers.eq -describe('TabNew', function() - setup(clear) - describe('au TabNew', function() - describe('with * as <afile>', function() - it('matches when opening any new tab', function() - nvim('command', 'au! TabNew * echom "tabnew:".tabpagenr().":".bufnr("")') - eq("\ntabnew:2:1", nvim('command_output', 'tabnew')) - eq("\ntabnew:3:2\n\"test.x\" [New File]", nvim('command_output', 'tabnew test.x')) - end) - end) - describe('with FILE as <afile>', function() - it('matches when opening a new tab for FILE', function() - local tmp_path = nvim('eval', 'tempname()') - nvim('command', 'au! TabNew '..tmp_path..' echom "tabnew:match"') - eq("\ntabnew:4:3\ntabnew:match\n\""..tmp_path.."\" [New File]", nvim('command_output', 'tabnew '..tmp_path)) - end) - end) - end) +local clear = helpers.clear +local command = helpers.command +local eq = helpers.eq +local eval = helpers.eval + +describe('autocmd TabNew', function() + before_each(clear) + + it('matches when opening any new tab', function() + command('autocmd! TabNew * let g:test = "tabnew:".tabpagenr().":".bufnr("")') + command('tabnew') + eq('tabnew:2:1', eval('g:test')) + command('tabnew test.x') + eq('tabnew:3:2', eval('g:test')) + end) + + it('matches when opening a new tab for FILE', function() + local tmp_path = helpers.funcs.tempname() + command('let g:test = "foo"') + command('autocmd! TabNew ' .. tmp_path .. ' let g:test = "bar"') + command('tabnew ' .. tmp_path ..'X') + eq('foo', eval('g:test')) + command('tabnew ' .. tmp_path) + eq('bar', eval('g:test')) + end) end) diff --git a/test/functional/legacy/062_tab_pages_spec.lua b/test/functional/legacy/062_tab_pages_spec.lua index c3cdcac471..f1c8b8d58b 100644 --- a/test/functional/legacy/062_tab_pages_spec.lua +++ b/test/functional/legacy/062_tab_pages_spec.lua @@ -139,7 +139,6 @@ describe('tab pages', function() autocmd TabLeave * :call add(g:r, 'TabLeave') autocmd WinLeave * :call add(g:r, 'WinLeave') autocmd BufLeave * :call add(g:r, 'BufLeave') - autocmd TabNew * :call add(g:r, 'TabNew') let t:a='a' C tab split let t:a='b' @@ -186,13 +185,11 @@ describe('tab pages', function() === tab split === WinLeave TabLeave - TabNew WinEnter TabEnter === tabnew === WinLeave TabLeave - TabNew WinEnter TabEnter BufLeave @@ -225,7 +222,6 @@ describe('tab pages', function() === tabnew === WinLeave TabLeave - TabNew WinEnter TabEnter BufLeave diff --git a/test/functional/viml/errorlist_spec.lua b/test/functional/viml/errorlist_spec.lua index 78e25297f2..30cb86f8d1 100644 --- a/test/functional/viml/errorlist_spec.lua +++ b/test/functional/viml/errorlist_spec.lua @@ -3,32 +3,44 @@ local helpers = require('test.functional.helpers') local clear = helpers.clear local command = helpers.command local eq = helpers.eq +local exc_exec = helpers.exc_exec local get_cur_win_var = helpers.curwinmeths.get_var --- local exc_exec = helpers.exc_exec describe('setqflist()', function() local setqflist = helpers.funcs.setqflist before_each(clear) + it('requires a list for {list}', function() + eq('Vim(call):E714: List required', exc_exec('call setqflist("foo")')) + eq('Vim(call):E714: List required', exc_exec('call setqflist(5)')) + eq('Vim(call):E714: List required', exc_exec('call setqflist({})')) + end) + + it('requires a string for {action}', function() + eq('Vim(call):E114: String required', exc_exec('call setqflist([], 5)')) + eq('Vim(call):E114: String required', exc_exec('call setqflist([], [])')) + eq('Vim(call):E114: String required', exc_exec('call setqflist([], {})')) + end) + it('sets w:quickfix_title', function() setqflist({''}, 'r', 'foo') command('copen') eq(':foo', get_cur_win_var('quickfix_title')) end) - it('expects a proper type for {title}', function() + it('requires string or number for {title}', function() command('copen') - setqflist({''}, 'r', '5') + setqflist({}, 'r', '5') eq(':5', get_cur_win_var('quickfix_title')) - setqflist({''}, 'r', 6) - eq(':setqflist()', get_cur_win_var('quickfix_title')) - -- local exc = exc_exec('call setqflist([""], "r", function("function"))') - -- eq('Vim(call):E729: using Funcref as a String', exc) - -- exc = exc_exec('call setqflist([""], "r", [])') - -- eq('Vim(call):E730: using List as a String', exc) - -- exc = exc_exec('call setqflist([""], "r", {})') - -- eq('Vim(call):E731: using Dictionary as a String', exc) + setqflist({}, 'r', 6) + eq(':6', get_cur_win_var('quickfix_title')) + local exc = exc_exec('call setqflist([], "r", function("function"))') + eq('Vim(call):E729: using Funcref as a String', exc) + exc = exc_exec('call setqflist([], "r", [])') + eq('Vim(call):E730: using List as a String', exc) + exc = exc_exec('call setqflist([], "r", {})') + eq('Vim(call):E731: using Dictionary as a String', exc) end) end) @@ -37,10 +49,22 @@ describe('setloclist()', function() before_each(clear) + it('requires a list for {list}', function() + eq('Vim(call):E714: List required', exc_exec('call setloclist(0, "foo")')) + eq('Vim(call):E714: List required', exc_exec('call setloclist(0, 5)')) + eq('Vim(call):E714: List required', exc_exec('call setloclist(0, {})')) + end) + + it('requires a string for {action}', function() + eq('Vim(call):E114: String required', exc_exec('call setloclist(0, [], 5)')) + eq('Vim(call):E114: String required', exc_exec('call setloclist(0, [], [])')) + eq('Vim(call):E114: String required', exc_exec('call setloclist(0, [], {})')) + end) + it('sets w:quickfix_title for the correct window', function() command('rightbelow vsplit') - setloclist(1, {''}, 'r', 'foo') - setloclist(2, {''}, 'r', 'bar') + setloclist(1, {}, 'r', 'foo') + setloclist(2, {}, 'r', 'bar') command('lopen') eq(':bar', get_cur_win_var('quickfix_title')) command('lclose | wincmd w | lopen') |