mirror of
https://github.com/neovim/neovim.git
synced 2025-10-02 16:08:36 +00:00
vim-patch:7.4.1132
Problem: Old style tests for the argument list.
Solution: Add more new style tests. (Yegappan Lakshmanan)
99dbe291f5
This commit is contained in:
@@ -550,7 +550,7 @@ static int included_patches[] = {
|
|||||||
// 1135 NA
|
// 1135 NA
|
||||||
// 1134 NA
|
// 1134 NA
|
||||||
// 1133 NA
|
// 1133 NA
|
||||||
// 1132,
|
1132,
|
||||||
// 1131 NA
|
// 1131 NA
|
||||||
// 1130,
|
// 1130,
|
||||||
// 1129 NA
|
// 1129 NA
|
||||||
|
@@ -3,16 +3,15 @@
|
|||||||
local helpers = require('test.functional.helpers')
|
local helpers = require('test.functional.helpers')
|
||||||
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
|
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
|
||||||
local execute, expect = helpers.execute, helpers.expect
|
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()
|
describe('argument list commands', function()
|
||||||
before_each(clear)
|
before_each(clear)
|
||||||
|
|
||||||
function assert_argc(l)
|
function assert_argc(l)
|
||||||
eq(#l, eval('argc()'))
|
eq(#l, eval('argc()'))
|
||||||
for i = 1, #l do
|
eq(l, eval('argv()'))
|
||||||
eq(l[i], eval('argv(' .. (i - 1) .. ')'))
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function init_abc()
|
function init_abc()
|
||||||
@@ -20,6 +19,14 @@ describe('argument list commands', function()
|
|||||||
execute('next')
|
execute('next')
|
||||||
end
|
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()
|
it('test that argidx() works', function()
|
||||||
execute('args a b c')
|
execute('args a b c')
|
||||||
execute('last')
|
execute('last')
|
||||||
@@ -78,4 +85,180 @@ describe('argument list commands', function()
|
|||||||
assert_argc({'a', 'b', 'c', 'x', 'y'})
|
assert_argc({'a', 'b', 'c', 'x', 'y'})
|
||||||
eq(1, eval('argidx()'))
|
eq(1, eval('argidx()'))
|
||||||
end)
|
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)
|
end)
|
||||||
|
@@ -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)
|
|
@@ -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)
|
|
Reference in New Issue
Block a user