functests: Refactor legacy/029_join test

This commit is contained in:
ZyX
2017-04-08 22:00:50 +03:00
parent 47b451c52b
commit e31aab8b61
2 changed files with 39 additions and 34 deletions

View File

@@ -304,7 +304,7 @@ end
-- Executes an ex-command by user input. Because nvim_input() is used, VimL
-- errors will not manifest as client (lua) errors. Use command() for that.
local function execute(...)
local function feed_command(...)
for _, v in ipairs({...}) do
if v:sub(1, 1) ~= '/' then
-- not a search command, prefix with colon
@@ -565,7 +565,8 @@ local M = {
insert = insert,
iswin = iswin,
feed = feed,
execute = execute,
feed_command = feed_command,
execute = feed_command, -- FIXME Remove
eval = nvim_eval,
call = nvim_call,
command = nvim_command,

View File

@@ -1,8 +1,12 @@
-- Test for joining lines with marks in them (and with 'joinspaces' set/reset)
local helpers = require('test.functional.helpers')(after_each)
local feed, insert = helpers.feed, helpers.insert
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
local feed = helpers.feed
local clear = helpers.clear
local insert = helpers.insert
local expect = helpers.expect
local feed_command = helpers.feed_command
describe('joining lines', function()
before_each(clear)
@@ -46,19 +50,19 @@ describe('joining lines', function()
-- Switch off 'joinspaces', then join some lines in the buffer using "J".
-- Also set a few marks and record their movement when joining lines.
execute('set nojoinspaces')
execute('/firstline/')
feed_command('set nojoinspaces')
feed_command('/firstline/')
feed('j"td/^$/<cr>')
feed('PJjJjJjJjJjJjJjJjJjJjJjJjJjJ')
feed('j05lmx2j06lmy2k4Jy3l$p`xyl$p`yy2l$p')
-- Do the same with 'joinspaces' on.
execute('set joinspaces')
feed_command('set joinspaces')
feed('j"tp')
feed('JjJjJjJjJjJjJjJjJjJjJjJjJjJ')
feed('j05lmx2j06lmy2k4Jy3l$p`xyl$p`yy2l$po<esc>')
execute('1d')
feed_command('1d')
expect([[
asdfasdf. asdf
@@ -129,20 +133,20 @@ describe('joining lines', function()
}
]])
execute('/^{/+1')
execute('set comments=s1:/*,mb:*,ex:*/,://')
execute('set nojoinspaces')
execute('set backspace=eol,start')
feed_command('/^{/+1')
feed_command('set comments=s1:/*,mb:*,ex:*/,://')
feed_command('set nojoinspaces')
feed_command('set backspace=eol,start')
-- With 'joinspaces' switched off, join lines using both "J" and :join and
-- verify that comment leaders are stripped or kept as appropriate.
execute('.,+3join')
feed_command('.,+3join')
feed('j4J<cr>')
execute('.,+2join')
feed_command('.,+2join')
feed('j3J<cr>')
execute('.,+2join')
feed_command('.,+2join')
feed('j3J<cr>')
execute('.,+2join')
feed_command('.,+2join')
feed('jj3J<cr>')
expect([[
@@ -180,22 +184,22 @@ describe('joining lines', function()
-- As mentioned above, we mimic the wrong initial cursor position in the old
-- test by advancing one line further.
execute([[/^\d\+ this]], '+1')
feed_command([[/^\d\+ this]], '+1')
-- Test with the default 'backspace' setting.
feed('Avim1<c-u><esc><cr>')
feed('Avim2<c-g>u<c-u><esc><cr>')
execute('set cpo-=<')
execute('inoremap <c-u> <left><c-u>')
feed_command('set cpo-=<')
feed_command('inoremap <c-u> <left><c-u>')
feed('Avim3<c-u><esc><cr>')
execute('iunmap <c-u>')
feed_command('iunmap <c-u>')
feed('Avim4<c-u><c-u><esc><cr>')
-- Test with 'backspace' set to the compatible setting.
execute('set backspace=')
feed_command('set backspace=')
feed('A vim5<esc>A<c-u><c-u><esc><cr>')
feed('A vim6<esc>Azwei<c-g>u<c-u><esc><cr>')
execute('inoremap <c-u> <left><c-u>')
feed_command('inoremap <c-u> <left><c-u>')
feed('A vim7<c-u><c-u><esc><cr>')
expect([[
@@ -283,29 +287,29 @@ describe('joining lines', function()
}
]])
execute('/^{/+1')
execute([[set comments=sO:*\ -,mO:*\ \ ,exO:*/]])
execute('set comments+=s1:/*,mb:*,ex:*/,://')
execute('set comments+=s1:>#,mb:#,ex:#<,:<')
execute('set backspace=eol,start')
feed_command('/^{/+1')
feed_command([[set comments=sO:*\ -,mO:*\ \ ,exO:*/]])
feed_command('set comments+=s1:/*,mb:*,ex:*/,://')
feed_command('set comments+=s1:>#,mb:#,ex:#<,:<')
feed_command('set backspace=eol,start')
-- With 'joinspaces' on (the default setting), again join lines and verify
-- that comment leaders are stripped or kept as appropriate.
execute('.,+3join')
feed_command('.,+3join')
feed('j4J<cr>')
execute('.,+8join')
feed_command('.,+8join')
feed('j9J<cr>')
execute('.,+2join')
feed_command('.,+2join')
feed('j3J<cr>')
execute('.,+2join')
feed_command('.,+2join')
feed('j3J<cr>')
execute('.,+2join')
feed_command('.,+2join')
feed('jj3J<cr>')
feed('j')
execute('.,+2join')
feed_command('.,+2join')
feed('jj3J<cr>')
feed('j')
execute('.,+5join')
feed_command('.,+5join')
feed('j6J<cr>')
feed('oSome code!<cr>// Make sure backspacing does not remove this comment leader.<esc>0i<bs><esc>')