diff options
author | ZyX <kp-pav@yandex.ru> | 2017-12-03 16:49:30 +0300 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2017-12-03 16:49:30 +0300 |
commit | c49e22d3964d6c7ae1c24e8ad01b5fec4ca40b57 (patch) | |
tree | b7e59c416d1435725c65f8952b6e55c70544d97e /test/functional/legacy/arglist_spec.lua | |
parent | 62108c3b0be46936c83f6d4c98b44ceb5e6f77fd (diff) | |
parent | 27a577586eace687c47e7398845178208cae524a (diff) | |
download | rneovim-c49e22d3964d6c7ae1c24e8ad01b5fec4ca40b57.tar.gz rneovim-c49e22d3964d6c7ae1c24e8ad01b5fec4ca40b57.tar.bz2 rneovim-c49e22d3964d6c7ae1c24e8ad01b5fec4ca40b57.zip |
Merge branch 'master' into s-dash-stdin
Diffstat (limited to 'test/functional/legacy/arglist_spec.lua')
-rw-r--r-- | test/functional/legacy/arglist_spec.lua | 243 |
1 files changed, 137 insertions, 106 deletions
diff --git a/test/functional/legacy/arglist_spec.lua b/test/functional/legacy/arglist_spec.lua index f5e3522972..191f145095 100644 --- a/test/functional/legacy/arglist_spec.lua +++ b/test/functional/legacy/arglist_spec.lua @@ -1,7 +1,7 @@ -- Test argument list commands local helpers = require('test.functional.helpers')(after_each) -local clear, execute, eq = helpers.clear, helpers.execute, helpers.eq +local clear, command, eq = helpers.clear, helpers.command, helpers.eq local eval, exc_exec, neq = helpers.eval, helpers.exc_exec, helpers.neq if helpers.pending_win32(pending) then return end @@ -10,12 +10,12 @@ describe('argument list commands', function() before_each(clear) local function init_abc() - execute('args a b c') - execute('next') + command('args a b c') + command('next') end local function reset_arglist() - execute('arga a | %argd') + command('arga a | %argd') end local function assert_fails(cmd, err) @@ -23,183 +23,185 @@ describe('argument list commands', function() end it('test that argidx() works', function() - execute('args a b c') - execute('last') + command('args a b c') + command('last') eq(2, eval('argidx()')) - execute('%argdelete') + command('%argdelete') eq(0, eval('argidx()')) - execute('args a b c') + command('args a b c') eq(0, eval('argidx()')) - execute('next') + command('next') eq(1, eval('argidx()')) - execute('next') + command('next') eq(2, eval('argidx()')) - execute('1argdelete') + command('1argdelete') eq(1, eval('argidx()')) - execute('1argdelete') + command('1argdelete') eq(0, eval('argidx()')) - execute('1argdelete') + command('1argdelete') eq(0, eval('argidx()')) end) it('test that argadd() works', function() - execute('%argdelete') - execute('argadd a b c') + -- Fails with “E474: Invalid argument”. Not sure whether it is how it is + -- supposed to behave. + -- command('%argdelete') + command('argadd a b c') eq(0, eval('argidx()')) - execute('%argdelete') - execute('argadd a') + command('%argdelete') + command('argadd a') eq(0, eval('argidx()')) - execute('argadd b c d') + command('argadd b c d') eq(0, eval('argidx()')) init_abc() - execute('argadd x') + command('argadd x') eq({'a', 'b', 'x', 'c'}, eval('argv()')) eq(1, eval('argidx()')) init_abc() - execute('0argadd x') + command('0argadd x') eq({'x', 'a', 'b', 'c'}, eval('argv()')) eq(2, eval('argidx()')) init_abc() - execute('1argadd x') + command('1argadd x') eq({'a', 'x', 'b', 'c'}, eval('argv()')) eq(2, eval('argidx()')) init_abc() - execute('$argadd x') + command('$argadd x') eq({'a', 'b', 'c', 'x'}, eval('argv()')) eq(1, eval('argidx()')) init_abc() - execute('$argadd x') - execute('+2argadd y') + command('$argadd x') + command('+2argadd y') eq({'a', 'b', 'c', 'x', 'y'}, eval('argv()')) eq(1, eval('argidx()')) - execute('%argd') - execute('edit d') - execute('arga') + command('%argd') + command('edit d') + command('arga') eq(1, eval('len(argv())')) eq('d', eval('get(argv(), 0, "")')) - execute('%argd') - execute('new') - execute('arga') + command('%argd') + command('new') + command('arga') eq(0, eval('len(argv())')) end) it('test for [count]argument and [count]argdelete commands', function() reset_arglist() - execute('let save_hidden = &hidden') - execute('set hidden') - execute('let g:buffers = []') - execute('augroup TEST') - execute([[au BufEnter * call add(buffers, expand('%:t'))]]) - execute('augroup END') - - execute('argadd a b c d') - execute('$argu') - execute('$-argu') - execute('-argu') - execute('1argu') - execute('+2argu') - - execute('augroup TEST') - execute('au!') - execute('augroup END') + command('let save_hidden = &hidden') + command('set hidden') + command('let g:buffers = []') + command('augroup TEST') + command([[au BufEnter * call add(buffers, expand('%:t'))]]) + command('augroup END') + + command('argadd a b c d') + command('$argu') + command('$-argu') + command('-argu') + command('1argu') + command('+2argu') + + command('augroup TEST') + command('au!') + command('augroup END') eq({'d', 'c', 'b', 'a', 'c'}, eval('g:buffers')) - execute('redir => result') - execute('ar') - execute('redir END') + command('redir => result') + command('ar') + command('redir END') eq(1, eval([[result =~# 'a b \[c] d']])) - execute('.argd') + command('.argd') eq({'a', 'b', 'd'}, eval('argv()')) - execute('-argd') + command('-argd') eq({'a', 'd'}, eval('argv()')) - execute('$argd') + command('$argd') eq({'a'}, eval('argv()')) - execute('1arga c') - execute('1arga b') - execute('$argu') - execute('$arga x') + command('1arga c') + command('1arga b') + command('$argu') + command('$arga x') eq({'a', 'b', 'c', 'x'}, eval('argv()')) - execute('0arga Y') + command('0arga Y') eq({'Y', 'a', 'b', 'c', 'x'}, eval('argv()')) - execute('%argd') + command('%argd') eq({}, eval('argv()')) - execute('arga a b c d e f') - execute('2,$-argd') + command('arga a b c d e f') + command('2,$-argd') eq({'a', 'f'}, eval('argv()')) - execute('let &hidden = save_hidden') + command('let &hidden = save_hidden') -- Setting the argument list should fail when the current buffer has -- unsaved changes - execute('%argd') - execute('enew!') - execute('set modified') + command('%argd') + command('enew!') + command('set modified') assert_fails('args x y z', 'E37:') - execute('args! x y z') + command('args! x y z') eq({'x', 'y', 'z'}, eval('argv()')) eq('x', eval('expand("%:t")')) - execute('%argdelete') + command('%argdelete') assert_fails('argument', 'E163:') end) it('test for 0argadd and 0argedit', function() reset_arglist() - execute('arga a b c d') - execute('2argu') - execute('0arga added') + command('arga a b c d') + command('2argu') + command('0arga added') eq({'added', 'a', 'b', 'c', 'd'}, eval('argv()')) - execute('%argd') - execute('arga a b c d') - execute('2argu') - execute('0arge edited') + command('%argd') + command('arga a b c d') + command('2argu') + command('0arge edited') eq({'edited', 'a', 'b', 'c', 'd'}, eval('argv()')) - execute('2argu') - execute('arga third') + command('2argu') + command('arga third') eq({'edited', 'a', 'third', 'b', 'c', 'd'}, eval('argv()')) end) it('test for argc()', function() reset_arglist() eq(0, eval('argc()')) - execute('argadd a b') + command('argadd a b') eq(2, eval('argc()')) end) it('test for arglistid()', function() reset_arglist() - execute('arga a b') + command('arga a b') eq(0, eval('arglistid()')) - execute('split') - execute('arglocal') + command('split') + command('arglocal') eq(1, eval('arglistid()')) - execute('tabnew | tabfirst') + command('tabnew | tabfirst') eq(0, eval('arglistid(2)')) eq(1, eval('arglistid(1, 1)')) eq(0, eval('arglistid(2, 1)')) eq(1, eval('arglistid(1, 2)')) - execute('tabonly | only | enew!') - execute('argglobal') + command('tabonly | only | enew!') + command('argglobal') eq(0, eval('arglistid()')) end) @@ -207,66 +209,95 @@ describe('argument list commands', function() reset_arglist() eq({}, eval('argv()')) eq('', eval('argv(2)')) - execute('argadd a b c d') + command('argadd a b c d') eq('c', eval('argv(2)')) end) it('test for :argedit command', function() reset_arglist() - execute('argedit a') + command('argedit a') eq({'a'}, eval('argv()')) eq('a', eval('expand("%:t")')) - execute('argedit b') + command('argedit b') eq({'a', 'b'}, eval('argv()')) eq('b', eval('expand("%:t")')) - execute('argedit a') + command('argedit a') eq({'a', 'b'}, eval('argv()')) eq('a', eval('expand("%:t")')) - execute('argedit c') + command('argedit c') eq({'a', 'c', 'b'}, eval('argv()')) - execute('0argedit x') + command('0argedit x') eq({'x', 'a', 'c', 'b'}, eval('argv()')) - execute('enew! | set modified') + command('enew! | set modified') assert_fails('argedit y', 'E37:') - execute('argedit! y') + command('argedit! y') eq({'x', 'y', 'a', 'c', 'b'}, eval('argv()')) - execute('%argd') + command('%argd') -- Nvim allows unescaped spaces in filename on all platforms. #6010 - execute('argedit a b') + command('argedit a b') eq({'a b'}, eval('argv()')) end) it('test for :argdelete command', function() reset_arglist() - execute('args aa a aaa b bb') - execute('argdelete a*') + command('args aa a aaa b bb') + command('argdelete a*') eq({'b', 'bb'}, eval('argv()')) eq('aa', eval('expand("%:t")')) - execute('last') - execute('argdelete %') + command('last') + command('argdelete %') eq({'b'}, eval('argv()')) assert_fails('argdelete', 'E471:') assert_fails('1,100argdelete', 'E16:') - execute('%argd') + command('%argd') end) it('test for the :next, :prev, :first, :last, :rewind commands', function() reset_arglist() - execute('args a b c d') - execute('last') + command('args a b c d') + command('last') eq(3, eval('argidx()')) assert_fails('next', 'E165:') - execute('prev') + command('prev') eq(2, eval('argidx()')) - execute('Next') + command('Next') eq(1, eval('argidx()')) - execute('first') + command('first') eq(0, eval('argidx()')) assert_fails('prev', 'E164:') - execute('3next') + command('3next') eq(3, eval('argidx()')) - execute('rewind') + command('rewind') eq(0, eval('argidx()')) - execute('%argd') + command('%argd') + end) + + + it('test for autocommand that redefines the argument list, when doing ":all"', function() + command('autocmd BufReadPost Xxx2 next Xxx2 Xxx1') + command("call writefile(['test file Xxx1'], 'Xxx1')") + command("call writefile(['test file Xxx2'], 'Xxx2')") + command("call writefile(['test file Xxx3'], 'Xxx3')") + + command('new') + -- redefine arglist; go to Xxx1 + command('next! Xxx1 Xxx2 Xxx3') + -- open window for all args + command('all') + eq('test file Xxx1', eval('getline(1)')) + command('wincmd w') + command('wincmd w') + eq('test file Xxx1', eval('getline(1)')) + -- should now be in Xxx2 + command('rewind') + eq('test file Xxx2', eval('getline(1)')) + + command('autocmd! BufReadPost Xxx2') + command('enew! | only') + command("call delete('Xxx1')") + command("call delete('Xxx2')") + command("call delete('Xxx3')") + command('argdelete Xxx*') + command('bwipe! Xxx1 Xxx2 Xxx3') end) end) |