mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	functests: Refactor legacy/029_join test
This commit is contained in:
		| @@ -304,7 +304,7 @@ end | |||||||
|  |  | ||||||
| -- Executes an ex-command by user input. Because nvim_input() is used, VimL | -- 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. | -- errors will not manifest as client (lua) errors. Use command() for that. | ||||||
| local function execute(...) | local function feed_command(...) | ||||||
|   for _, v in ipairs({...}) do |   for _, v in ipairs({...}) do | ||||||
|     if v:sub(1, 1) ~= '/' then |     if v:sub(1, 1) ~= '/' then | ||||||
|       -- not a search command, prefix with colon |       -- not a search command, prefix with colon | ||||||
| @@ -565,7 +565,8 @@ local M = { | |||||||
|   insert = insert, |   insert = insert, | ||||||
|   iswin = iswin, |   iswin = iswin, | ||||||
|   feed = feed, |   feed = feed, | ||||||
|   execute = execute, |   feed_command = feed_command, | ||||||
|  |   execute = feed_command,  -- FIXME Remove | ||||||
|   eval = nvim_eval, |   eval = nvim_eval, | ||||||
|   call = nvim_call, |   call = nvim_call, | ||||||
|   command = nvim_command, |   command = nvim_command, | ||||||
|   | |||||||
| @@ -1,8 +1,12 @@ | |||||||
| -- Test for joining lines with marks in them (and with 'joinspaces' set/reset) | -- Test for joining lines with marks in them (and with 'joinspaces' set/reset) | ||||||
|  |  | ||||||
| local helpers = require('test.functional.helpers')(after_each) | 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() | describe('joining lines', function() | ||||||
|   before_each(clear) |   before_each(clear) | ||||||
| @@ -46,19 +50,19 @@ describe('joining lines', function() | |||||||
|  |  | ||||||
|     -- Switch off 'joinspaces', then join some lines in the buffer using "J". |     -- Switch off 'joinspaces', then join some lines in the buffer using "J". | ||||||
|     -- Also set a few marks and record their movement when joining lines. |     -- Also set a few marks and record their movement when joining lines. | ||||||
|     execute('set nojoinspaces') |     feed_command('set nojoinspaces') | ||||||
|     execute('/firstline/') |     feed_command('/firstline/') | ||||||
|     feed('j"td/^$/<cr>') |     feed('j"td/^$/<cr>') | ||||||
|     feed('PJjJjJjJjJjJjJjJjJjJjJjJjJjJ') |     feed('PJjJjJjJjJjJjJjJjJjJjJjJjJjJ') | ||||||
|     feed('j05lmx2j06lmy2k4Jy3l$p`xyl$p`yy2l$p') |     feed('j05lmx2j06lmy2k4Jy3l$p`xyl$p`yy2l$p') | ||||||
|  |  | ||||||
|     -- Do the same with 'joinspaces' on. |     -- Do the same with 'joinspaces' on. | ||||||
|     execute('set joinspaces') |     feed_command('set joinspaces') | ||||||
|     feed('j"tp') |     feed('j"tp') | ||||||
|     feed('JjJjJjJjJjJjJjJjJjJjJjJjJjJ') |     feed('JjJjJjJjJjJjJjJjJjJjJjJjJjJ') | ||||||
|     feed('j05lmx2j06lmy2k4Jy3l$p`xyl$p`yy2l$po<esc>') |     feed('j05lmx2j06lmy2k4Jy3l$p`xyl$p`yy2l$po<esc>') | ||||||
|  |  | ||||||
|     execute('1d') |     feed_command('1d') | ||||||
|  |  | ||||||
|     expect([[ |     expect([[ | ||||||
|       asdfasdf. asdf |       asdfasdf. asdf | ||||||
| @@ -129,20 +133,20 @@ describe('joining lines', function() | |||||||
|       } |       } | ||||||
|       ]]) |       ]]) | ||||||
|  |  | ||||||
|     execute('/^{/+1') |     feed_command('/^{/+1') | ||||||
|     execute('set comments=s1:/*,mb:*,ex:*/,://') |     feed_command('set comments=s1:/*,mb:*,ex:*/,://') | ||||||
|     execute('set nojoinspaces') |     feed_command('set nojoinspaces') | ||||||
|     execute('set backspace=eol,start') |     feed_command('set backspace=eol,start') | ||||||
|  |  | ||||||
|     -- With 'joinspaces' switched off, join lines using both "J" and :join and |     -- With 'joinspaces' switched off, join lines using both "J" and :join and | ||||||
|     -- verify that comment leaders are stripped or kept as appropriate. |     -- verify that comment leaders are stripped or kept as appropriate. | ||||||
|     execute('.,+3join') |     feed_command('.,+3join') | ||||||
|     feed('j4J<cr>') |     feed('j4J<cr>') | ||||||
|     execute('.,+2join') |     feed_command('.,+2join') | ||||||
|     feed('j3J<cr>') |     feed('j3J<cr>') | ||||||
|     execute('.,+2join') |     feed_command('.,+2join') | ||||||
|     feed('j3J<cr>') |     feed('j3J<cr>') | ||||||
|     execute('.,+2join') |     feed_command('.,+2join') | ||||||
|     feed('jj3J<cr>') |     feed('jj3J<cr>') | ||||||
|  |  | ||||||
|     expect([[ |     expect([[ | ||||||
| @@ -180,22 +184,22 @@ describe('joining lines', function() | |||||||
|  |  | ||||||
|     -- As mentioned above, we mimic the wrong initial cursor position in the old |     -- As mentioned above, we mimic the wrong initial cursor position in the old | ||||||
|     -- test by advancing one line further. |     -- test by advancing one line further. | ||||||
|     execute([[/^\d\+ this]], '+1') |     feed_command([[/^\d\+ this]], '+1') | ||||||
|  |  | ||||||
|     -- Test with the default 'backspace' setting. |     -- Test with the default 'backspace' setting. | ||||||
|     feed('Avim1<c-u><esc><cr>') |     feed('Avim1<c-u><esc><cr>') | ||||||
|     feed('Avim2<c-g>u<c-u><esc><cr>') |     feed('Avim2<c-g>u<c-u><esc><cr>') | ||||||
|     execute('set cpo-=<') |     feed_command('set cpo-=<') | ||||||
|     execute('inoremap <c-u> <left><c-u>') |     feed_command('inoremap <c-u> <left><c-u>') | ||||||
|     feed('Avim3<c-u><esc><cr>') |     feed('Avim3<c-u><esc><cr>') | ||||||
|     execute('iunmap <c-u>') |     feed_command('iunmap <c-u>') | ||||||
|     feed('Avim4<c-u><c-u><esc><cr>') |     feed('Avim4<c-u><c-u><esc><cr>') | ||||||
|  |  | ||||||
|     -- Test with 'backspace' set to the compatible setting. |     -- 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 vim5<esc>A<c-u><c-u><esc><cr>') | ||||||
|     feed('A vim6<esc>Azwei<c-g>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>') |     feed('A vim7<c-u><c-u><esc><cr>') | ||||||
|  |  | ||||||
|     expect([[ |     expect([[ | ||||||
| @@ -283,29 +287,29 @@ describe('joining lines', function() | |||||||
|       } |       } | ||||||
|       ]]) |       ]]) | ||||||
|  |  | ||||||
|     execute('/^{/+1') |     feed_command('/^{/+1') | ||||||
|     execute([[set comments=sO:*\ -,mO:*\ \ ,exO:*/]]) |     feed_command([[set comments=sO:*\ -,mO:*\ \ ,exO:*/]]) | ||||||
|     execute('set comments+=s1:/*,mb:*,ex:*/,://') |     feed_command('set comments+=s1:/*,mb:*,ex:*/,://') | ||||||
|     execute('set comments+=s1:>#,mb:#,ex:#<,:<') |     feed_command('set comments+=s1:>#,mb:#,ex:#<,:<') | ||||||
|     execute('set backspace=eol,start') |     feed_command('set backspace=eol,start') | ||||||
|  |  | ||||||
|     -- With 'joinspaces' on (the default setting), again join lines and verify |     -- With 'joinspaces' on (the default setting), again join lines and verify | ||||||
|     -- that comment leaders are stripped or kept as appropriate. |     -- that comment leaders are stripped or kept as appropriate. | ||||||
|     execute('.,+3join') |     feed_command('.,+3join') | ||||||
|     feed('j4J<cr>') |     feed('j4J<cr>') | ||||||
|     execute('.,+8join') |     feed_command('.,+8join') | ||||||
|     feed('j9J<cr>') |     feed('j9J<cr>') | ||||||
|     execute('.,+2join') |     feed_command('.,+2join') | ||||||
|     feed('j3J<cr>') |     feed('j3J<cr>') | ||||||
|     execute('.,+2join') |     feed_command('.,+2join') | ||||||
|     feed('j3J<cr>') |     feed('j3J<cr>') | ||||||
|     execute('.,+2join') |     feed_command('.,+2join') | ||||||
|     feed('jj3J<cr>') |     feed('jj3J<cr>') | ||||||
|     feed('j') |     feed('j') | ||||||
|     execute('.,+2join') |     feed_command('.,+2join') | ||||||
|     feed('jj3J<cr>') |     feed('jj3J<cr>') | ||||||
|     feed('j') |     feed('j') | ||||||
|     execute('.,+5join') |     feed_command('.,+5join') | ||||||
|     feed('j6J<cr>') |     feed('j6J<cr>') | ||||||
|     feed('oSome code!<cr>// Make sure backspacing does not remove this comment leader.<esc>0i<bs><esc>') |     feed('oSome code!<cr>// Make sure backspacing does not remove this comment leader.<esc>0i<bs><esc>') | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 ZyX
					ZyX