From 1573aa0b0a0a17da93e4fb2220fd5d6ecbd6d267 Mon Sep 17 00:00:00 2001 From: Jurica Bradaric Date: Sat, 14 May 2016 12:26:03 +0200 Subject: vim-patch:7.4.1119 Problem: argidx() has a wrong value after ":%argdelete". (Yegappan Lakshmanan) Solution: Correct the value of w_arg_idx. Add a test. https://github.com/vim/vim/commit/72defda84eb26be9e2ade56c7877b912f818026e --- test/functional/legacy/arglist_spec.lua | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 test/functional/legacy/arglist_spec.lua (limited to 'test/functional/legacy') diff --git a/test/functional/legacy/arglist_spec.lua b/test/functional/legacy/arglist_spec.lua new file mode 100644 index 0000000000..a569479b62 --- /dev/null +++ b/test/functional/legacy/arglist_spec.lua @@ -0,0 +1,31 @@ +-- Test argument list commands + +local helpers = require('test.functional.helpers') +local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert +local execute, expect = helpers.execute, helpers.expect +local eq, eval = helpers.eq, helpers.eval + +describe('argument list commands', function() + before_each(clear) + + it('is working', function() + execute('args a b c') + execute('last') + eq(2, eval('argidx()')) + execute('%argdelete') + eq(0, eval('argidx()')) + + execute('args a b c') + eq(0, eval('argidx()')) + execute('next') + eq(1, eval('argidx()')) + execute('next') + eq(2, eval('argidx()')) + execute('1argdelete') + eq(1, eval('argidx()')) + execute('1argdelete') + eq(0, eval('argidx()')) + execute('1argdelete') + eq(0, eval('argidx()')) + end) +end) -- cgit From dfdf7c02be1758f4adfe487a36f372f514dda39a Mon Sep 17 00:00:00 2001 From: Jurica Bradaric Date: Sat, 14 May 2016 12:40:05 +0200 Subject: vim-patch:7.4.1123 Problem: Using ":argadd" when there are no arguments results in the second argument to be the current one. (Yegappan Lakshmanan) Solution: Correct the w_arg_idx value. https://github.com/vim/vim/commit/a24f0a550fed3d9773800cf6be4efd072fff20ec --- test/functional/legacy/arglist_spec.lua | 52 ++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) (limited to 'test/functional/legacy') diff --git a/test/functional/legacy/arglist_spec.lua b/test/functional/legacy/arglist_spec.lua index a569479b62..e85d8a7aca 100644 --- a/test/functional/legacy/arglist_spec.lua +++ b/test/functional/legacy/arglist_spec.lua @@ -8,7 +8,19 @@ local eq, eval = helpers.eq, helpers.eval describe('argument list commands', function() before_each(clear) - it('is working', function() + function assert_argc(l) + eq(#l, eval('argc()')) + for i = 1, #l do + eq(l[i], eval('argv(' .. (i - 1) .. ')')) + end + end + + function init_abc() + execute('args a b c') + execute('next') + end + + it('test that argidx() works', function() execute('args a b c') execute('last') eq(2, eval('argidx()')) @@ -28,4 +40,42 @@ describe('argument list commands', function() execute('1argdelete') eq(0, eval('argidx()')) end) + + it('test that argadd() works', function() + execute('%argdelete') + execute('argadd a b c') + eq(0, eval('argidx()')) + + execute('%argdelete') + execute('argadd a') + eq(0, eval('argidx()')) + execute('argadd b c d') + eq(0, eval('argidx()')) + + init_abc() + execute('argadd x') + assert_argc({'a', 'b', 'x', 'c'}) + eq(1, eval('argidx()')) + + init_abc() + execute('0argadd x') + assert_argc({'x', 'a', 'b', 'c'}) + eq(2, eval('argidx()')) + + init_abc() + execute('1argadd x') + assert_argc({'a', 'x', 'b', 'c'}) + eq(2, eval('argidx()')) + + init_abc() + execute('$argadd x') + assert_argc({'a', 'b', 'c', 'x'}) + eq(1, eval('argidx()')) + + init_abc() + execute('$argadd x') + execute('+2argadd y') + assert_argc({'a', 'b', 'c', 'x', 'y'}) + eq(1, eval('argidx()')) + end) end) -- cgit From 02fb6ee45843ac0b759f5bb15bbb3f3f418f0e74 Mon Sep 17 00:00:00 2001 From: Jurica Bradaric Date: Sat, 14 May 2016 13:26:27 +0200 Subject: vim-patch:7.4.1132 Problem: Old style tests for the argument list. Solution: Add more new style tests. (Yegappan Lakshmanan) https://github.com/vim/vim/commit/99dbe291f55022bd5166c9c3c7967b8693cd9d1b --- test/functional/legacy/arglist_spec.lua | 191 +++++++++++++++++++++++- test/functional/legacy/argument_0count_spec.lua | 28 ---- test/functional/legacy/argument_count_spec.lua | 47 ------ 3 files changed, 187 insertions(+), 79 deletions(-) delete mode 100644 test/functional/legacy/argument_0count_spec.lua delete mode 100644 test/functional/legacy/argument_count_spec.lua (limited to 'test/functional/legacy') diff --git a/test/functional/legacy/arglist_spec.lua b/test/functional/legacy/arglist_spec.lua index e85d8a7aca..60485e8902 100644 --- a/test/functional/legacy/arglist_spec.lua +++ b/test/functional/legacy/arglist_spec.lua @@ -3,16 +3,15 @@ local helpers = require('test.functional.helpers') local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert local execute, expect = helpers.execute, helpers.expect -local eq, eval = helpers.eq, helpers.eval +local eq, eval, neq = helpers.eq, helpers.eval, helpers.neq +local exc_exec = helpers.exc_exec describe('argument list commands', function() before_each(clear) function assert_argc(l) eq(#l, eval('argc()')) - for i = 1, #l do - eq(l[i], eval('argv(' .. (i - 1) .. ')')) - end + eq(l, eval('argv()')) end function init_abc() @@ -20,6 +19,14 @@ describe('argument list commands', function() execute('next') end + function reset_arglist() + execute('arga a | %argd') + end + + function assert_fails(cmd, err) + neq(exc_exec(cmd):find(err), nil) + end + it('test that argidx() works', function() execute('args a b c') execute('last') @@ -78,4 +85,180 @@ describe('argument list commands', function() assert_argc({'a', 'b', 'c', 'x', 'y'}) eq(1, eval('argidx()')) 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') + + eq({'d', 'c', 'b', 'a', 'c'}, eval('g:buffers')) + + execute('redir => result') + execute('ar') + execute('redir END') + eq(1, eval([[result =~# 'a b \[c] d']])) + + execute('.argd') + eq({'a', 'b', 'd'}, eval('argv()')) + + execute('-argd') + eq({'a', 'd'}, eval('argv()')) + + execute('$argd') + eq({'a'}, eval('argv()')) + + execute('1arga c') + execute('1arga b') + execute('$argu') + execute('$arga x') + eq({'a', 'b', 'c', 'x'}, eval('argv()')) + + execute('0arga Y') + eq({'Y', 'a', 'b', 'c', 'x'}, eval('argv()')) + + execute('%argd') + eq({}, eval('argv()')) + + execute('arga a b c d e f') + execute('2,$-argd') + eq({'a', 'f'}, eval('argv()')) + + execute('let &hidden = save_hidden') + + -- Setting the argument list should fail when the current buffer has + -- unsaved changes + execute('%argd') + execute('enew!') + execute('set modified') + assert_fails('args x y z', 'E37:') + execute('args! x y z') + eq({'x', 'y', 'z'}, eval('argv()')) + eq('x', eval('expand("%:t")')) + + execute('%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') + eq({'added', 'a', 'b', 'c', 'd'}, eval('argv()')) + + execute('%argd') + execute('arga a b c d') + execute('2argu') + execute('0arge edited') + eq({'edited', 'a', 'b', 'c', 'd'}, eval('argv()')) + + execute('2argu') + execute('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') + eq(2, eval('argc()')) + end) + + it('test for arglistid()', function() + reset_arglist() + execute('arga a b') + eq(0, eval('arglistid()')) + execute('split') + execute('arglocal') + eq(1, eval('arglistid()')) + execute('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') + eq(0, eval('arglistid()')) + end) + + it('test for argv()', function() + reset_arglist() + eq({}, eval('argv()')) + eq('', eval('argv(2)')) + execute('argadd a b c d') + eq('c', eval('argv(2)')) + end) + + it('test for :argedit command', function() + reset_arglist() + execute('argedit a') + eq({'a'}, eval('argv()')) + eq('a', eval('expand("%:t")')) + execute('argedit b') + eq({'a', 'b'}, eval('argv()')) + eq('b', eval('expand("%:t")')) + execute('argedit a') + eq({'a', 'b'}, eval('argv()')) + eq('a', eval('expand("%:t")')) + assert_fails('argedit a b', 'E172:') + execute('argedit c') + eq({'a', 'c', 'b'}, eval('argv()')) + execute('0argedit x') + eq({'x', 'a', 'c', 'b'}, eval('argv()')) + execute('enew! | set modified') + assert_fails('argedit y', 'E37:') + execute('argedit! y') + eq({'x', 'y', 'a', 'c', 'b'}, eval('argv()')) + execute('%argd') + end) + + it('test for :argdelete command', function() + reset_arglist() + execute('args aa a aaa b bb') + execute('argdelete a*') + eq({'b', 'bb'}, eval('argv()')) + eq('aa', eval('expand("%:t")')) + execute('last') + execute('argdelete %') + eq({'b'}, eval('argv()')) + assert_fails('argdelete', 'E471:') + assert_fails('1,100argdelete', 'E16:') + execute('%argd') + end) + + it('test for the :next, :prev, :first, :last, :rewind commands', function() + reset_arglist() + execute('args a b c d') + execute('last') + eq(3, eval('argidx()')) + assert_fails('next', 'E165:') + execute('prev') + eq(2, eval('argidx()')) + execute('Next') + eq(1, eval('argidx()')) + execute('first') + eq(0, eval('argidx()')) + assert_fails('prev', 'E164:') + execute('3next') + eq(3, eval('argidx()')) + execute('rewind') + eq(0, eval('argidx()')) + execute('%argd') + end) end) diff --git a/test/functional/legacy/argument_0count_spec.lua b/test/functional/legacy/argument_0count_spec.lua deleted file mode 100644 index 6e8b60547b..0000000000 --- a/test/functional/legacy/argument_0count_spec.lua +++ /dev/null @@ -1,28 +0,0 @@ --- Tests for :0argadd and :0argedit - -local helpers = require('test.functional.helpers') -local eq, eval, clear, execute = - helpers.eq, helpers.eval, helpers.clear, helpers.execute - -describe('argument_0count', function() - setup(clear) - - it('is working', function() - execute('arga a b c d') - eq({'a', 'b', 'c', 'd'}, eval('argv()')) - execute('2argu') - execute('0arga added') - eq({'added', 'a', 'b', 'c', 'd'}, eval('argv()')) - execute('2argu') - execute('arga third') - eq({'added', 'a', 'third', 'b', 'c', 'd'}, eval('argv()')) - execute('%argd') - execute('arga a b c d') - execute('2argu') - execute('0arge edited') - eq({'edited', 'a', 'b', 'c', 'd'}, eval('argv()')) - execute('2argu') - execute('arga third') - eq({'edited', 'a', 'third', 'b', 'c', 'd'}, eval('argv()')) - end) -end) diff --git a/test/functional/legacy/argument_count_spec.lua b/test/functional/legacy/argument_count_spec.lua deleted file mode 100644 index 182cce9475..0000000000 --- a/test/functional/legacy/argument_count_spec.lua +++ /dev/null @@ -1,47 +0,0 @@ --- Tests for :[count]argument! and :[count]argdelete - -local helpers = require('test.functional.helpers') -local clear, execute, eq, eval = - helpers.clear, helpers.execute, helpers.eq, helpers.eval - -describe('argument_count', function() - setup(clear) - - it('is working', function() - execute('%argd') - execute('argadd a b c d') - eq({'a', 'b', 'c', 'd'}, eval('argv()')) - execute('set hidden') - execute('let buffers = []') - execute('augroup TEST') - execute([[au BufEnter * call add(buffers, expand('%:t'))]]) - execute('augroup END') - execute('$argu') - execute('$-argu') - execute('-argu') - execute('1argu') - execute('+2argu') - execute('augroup TEST') - execute('au!') - execute('augroup END') - eq({'d', 'c', 'b', 'a', 'c'}, eval('buffers')) - execute('.argd') - eq({'a', 'b', 'd'}, eval('argv()')) - execute('-argd') - eq({'a', 'd'}, eval('argv()')) - execute('$argd') - eq({'a'}, eval('argv()')) - execute('1arga c') - execute('1arga b') - execute('$argu') - execute('$arga x') - eq({'a', 'b', 'c', 'x'}, eval('argv()')) - execute('0arga Y') - eq({'Y', 'a', 'b', 'c', 'x'}, eval('argv()')) - execute('%argd') - eq({}, eval('argv()')) - execute('arga a b c d e f') - execute('2,$-argd') - eq({'a', 'f'}, eval('argv()')) - end) -end) -- cgit From 055c9e1be6d73fa4a4f84299dbdbcaf8e2db140a Mon Sep 17 00:00:00 2001 From: Jurica Bradaric Date: Sat, 14 May 2016 15:51:44 +0200 Subject: vim-patch:7.4.1161 Problem: ":argadd" without argument is supposed to add the current buffer name to the arglist. Solution: Make it work as documented. (Coot, closes vim/vim#577) https://github.com/vim/vim/commit/2faa29f896252073b53f387406109e331fbbe5f8 --- test/functional/legacy/arglist_spec.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test/functional/legacy') diff --git a/test/functional/legacy/arglist_spec.lua b/test/functional/legacy/arglist_spec.lua index 60485e8902..d2e3e511d2 100644 --- a/test/functional/legacy/arglist_spec.lua +++ b/test/functional/legacy/arglist_spec.lua @@ -84,6 +84,17 @@ describe('argument list commands', function() execute('+2argadd y') assert_argc({'a', 'b', 'c', 'x', 'y'}) eq(1, eval('argidx()')) + + execute('%argd') + execute('edit d') + execute('arga') + eq(1, eval('len(argv())')) + eq('d', eval('get(argv(), 0, "")')) + + execute('%argd') + execute('new') + execute('arga') + eq(0, eval('len(argv())')) end) it('test for [count]argument and [count]argdelete commands', function() -- cgit From 36a57a9e8a311451cd40b7f8b2394fae6a67726f Mon Sep 17 00:00:00 2001 From: Jurica Bradaric Date: Sat, 14 May 2016 16:05:41 +0200 Subject: Fix linter warnings in test. --- test/functional/legacy/arglist_spec.lua | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) (limited to 'test/functional/legacy') diff --git a/test/functional/legacy/arglist_spec.lua b/test/functional/legacy/arglist_spec.lua index d2e3e511d2..b13b621b2c 100644 --- a/test/functional/legacy/arglist_spec.lua +++ b/test/functional/legacy/arglist_spec.lua @@ -1,29 +1,22 @@ -- Test argument list commands local helpers = require('test.functional.helpers') -local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local execute, expect = helpers.execute, helpers.expect -local eq, eval, neq = helpers.eq, helpers.eval, helpers.neq -local exc_exec = helpers.exc_exec +local clear, execute, eq = helpers.clear, helpers.execute, helpers.eq +local eval, exc_exec, neq = helpers.eval, helpers.exc_exec, helpers.neq describe('argument list commands', function() before_each(clear) - function assert_argc(l) - eq(#l, eval('argc()')) - eq(l, eval('argv()')) - end - - function init_abc() + local function init_abc() execute('args a b c') execute('next') end - function reset_arglist() + local function reset_arglist() execute('arga a | %argd') end - function assert_fails(cmd, err) + local function assert_fails(cmd, err) neq(exc_exec(cmd):find(err), nil) end @@ -61,28 +54,28 @@ describe('argument list commands', function() init_abc() execute('argadd x') - assert_argc({'a', 'b', 'x', 'c'}) + eq({'a', 'b', 'x', 'c'}, eval('argv()')) eq(1, eval('argidx()')) init_abc() execute('0argadd x') - assert_argc({'x', 'a', 'b', 'c'}) + eq({'x', 'a', 'b', 'c'}, eval('argv()')) eq(2, eval('argidx()')) init_abc() execute('1argadd x') - assert_argc({'a', 'x', 'b', 'c'}) + eq({'a', 'x', 'b', 'c'}, eval('argv()')) eq(2, eval('argidx()')) init_abc() execute('$argadd x') - assert_argc({'a', 'b', 'c', 'x'}) + eq({'a', 'b', 'c', 'x'}, eval('argv()')) eq(1, eval('argidx()')) init_abc() execute('$argadd x') execute('+2argadd y') - assert_argc({'a', 'b', 'c', 'x', 'y'}) + eq({'a', 'b', 'c', 'x', 'y'}, eval('argv()')) eq(1, eval('argidx()')) execute('%argd') -- cgit