From 04f2f864e270e772c6326cefdf24947f0130e492 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 3 Jan 2024 02:09:18 +0100 Subject: refactor: format test/* --- test/functional/ex_cmds/cmd_map_spec.lua | 94 ++++++++++++++++---------------- 1 file changed, 47 insertions(+), 47 deletions(-) (limited to 'test/functional/ex_cmds/cmd_map_spec.lua') diff --git a/test/functional/ex_cmds/cmd_map_spec.lua b/test/functional/ex_cmds/cmd_map_spec.lua index 306cba85d5..c1a4fee38d 100644 --- a/test/functional/ex_cmds/cmd_map_spec.lua +++ b/test/functional/ex_cmds/cmd_map_spec.lua @@ -16,24 +16,24 @@ describe('mappings with ', function() local tmpfile = 'X_ex_cmds_cmd_map' local function cmdmap(lhs, rhs) - command('noremap '..lhs..' '..rhs..'') - command('noremap! '..lhs..' '..rhs..'') + command('noremap ' .. lhs .. ' ' .. rhs .. '') + command('noremap! ' .. lhs .. ' ' .. rhs .. '') end before_each(function() clear() screen = Screen.new(65, 8) screen:set_default_attr_ids({ - [1] = {bold = true, foreground = Screen.colors.Blue1}, - [2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}, - [3] = {bold = true, foreground = Screen.colors.SeaGreen4}, - [4] = {bold = true}, - [5] = {background = Screen.colors.LightGrey}, - [6] = {foreground = Screen.colors.Blue1}, - [7] = {bold = true, reverse = true}, - [8] = {background = Screen.colors.WebGray}, - [9] = {background = Screen.colors.LightMagenta}, - [10] = {foreground = Screen.colors.Red}, + [1] = { bold = true, foreground = Screen.colors.Blue1 }, + [2] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red }, + [3] = { bold = true, foreground = Screen.colors.SeaGreen4 }, + [4] = { bold = true }, + [5] = { background = Screen.colors.LightGrey }, + [6] = { foreground = Screen.colors.Blue1 }, + [7] = { bold = true, reverse = true }, + [8] = { background = Screen.colors.WebGray }, + [9] = { background = Screen.colors.LightMagenta }, + [10] = { foreground = Screen.colors.Red }, }) screen:attach() @@ -57,7 +57,7 @@ describe('mappings with ', function() feed('gg') cmdmap('', 'startinsert') cmdmap('', 'stopinsert') - command("abbr foo let g:y = 17bar") + command('abbr foo let g:y = 17bar') end) after_each(function() @@ -121,7 +121,7 @@ describe('mappings with ', function() feed('') eq('foo…bar', eval('g:str')) local str = eval([["foo\bar"]]) - command([[noremap let g:str = ']]..str..[[']]) + command([[noremap let g:str = ']] .. str .. [[']]) feed('') eq(str, eval('g:str')) command([[noremap let g:str = 'foobar']]) @@ -160,7 +160,7 @@ describe('mappings with ', function() eq('n', eval('mode(1)')) -- operator-pending mode - feed("d") + feed('d') eq('no', eval('m')) -- did leave operator-pending mode eq('n', eval('mode(1)')) @@ -171,21 +171,21 @@ describe('mappings with ', function() eq('i', eval('mode(1)')) -- replace mode - feed("") + feed('') eq('R', eval('m')) eq('R', eval('mode(1)')) feed('') eq('n', eval('mode(1)')) -- virtual replace mode - feed("gR") + feed('gR') eq('Rv', eval('m')) eq('Rv', eval('mode(1)')) feed('') eq('n', eval('mode(1)')) -- langmap works, but is not distinguished in mode(1) - feed(":set iminsert=1i") + feed(':set iminsert=1i') eq('i', eval('m')) eq('i', eval('mode(1)')) feed('') @@ -212,15 +212,15 @@ describe('mappings with ', function() -- check v:count and v:register works feed('') - eq({'n', 0, '"'}, eval('s')) + eq({ 'n', 0, '"' }, eval('s')) feed('7') - eq({'n', 7, '"'}, eval('s')) + eq({ 'n', 7, '"' }, eval('s')) feed('"e') - eq({'n', 0, 'e'}, eval('s')) + eq({ 'n', 0, 'e' }, eval('s')) feed('5"k') - eq({'n', 5, 'k'}, eval('s')) + eq({ 'n', 5, 'k' }, eval('s')) feed('"+2') - eq({'n', 2, '+'}, eval('s')) + eq({ 'n', 2, '+' }, eval('s')) -- text object enters visual mode feed('') @@ -249,7 +249,7 @@ describe('mappings with ', function() {4:-- INSERT --} | ]]) -- feedkeys were not executed immediately - eq({'n', 'of test text'}, eval('[m,a]')) + eq({ 'n', 'of test text' }, eval('[m,a]')) eq('i', eval('mode(1)')) feed('') @@ -261,7 +261,7 @@ describe('mappings with ', function() | ]]) -- feedkeys(..., 'x') was executed immediately, but insert mode gets aborted - eq({'n', 'of alphabetatest text'}, eval('[m,b]')) + eq({ 'n', 'of alphabetatest text' }, eval('[m,b]')) eq('n', eval('mode(1)')) end) @@ -270,9 +270,11 @@ describe('mappings with ', function() command('noremap ,f nosuchcommand') command('noremap ,e throw "very error"\\| call append(1, "yy")') command('noremap ,m echoerr "The message."\\| call append(1, "zz")') - command('noremap ,w for i in range(5)\\|if i==1\\|echoerr "Err"\\|endif\\|call append(1, i)\\|endfor') + command( + 'noremap ,w for i in range(5)\\|if i==1\\|echoerr "Err"\\|endif\\|call append(1, i)\\|endfor' + ) - feed(":normal ,x") + feed(':normal ,x') screen:expect([[ ^some short lines | aa | @@ -282,9 +284,9 @@ describe('mappings with ', function() :normal ,x | ]]) - eq('Vim:E492: Not an editor command: nosuchcommand', exc_exec("normal ,f")) - eq('very error', exc_exec("normal ,e")) - eq('Vim(echoerr):The message.', exc_exec("normal ,m")) + eq('Vim:E492: Not an editor command: nosuchcommand', exc_exec('normal ,f')) + eq('very error', exc_exec('normal ,e')) + eq('Vim(echoerr):The message.', exc_exec('normal ,m')) feed('w') screen:expect([[ some ^short lines | @@ -296,7 +298,7 @@ describe('mappings with ', function() ]]) command(':%d') - eq('Vim(echoerr):Err', exc_exec("normal ,w")) + eq('Vim(echoerr):Err', exc_exec('normal ,w')) screen:expect([[ ^ | 0 | @@ -332,7 +334,7 @@ describe('mappings with ', function() -- can invoke operator, ending visual mode feed('') eq('n', funcs.mode(1)) - eq({'some short l'}, funcs.getreg('a',1,1)) + eq({ 'some short l' }, funcs.getreg('a', 1, 1)) -- error doesn't interrupt visual mode feed('ggvw') @@ -393,12 +395,12 @@ describe('mappings with ', function() -- visual mapping in select mode restart select mode after operator feed('') eq('s', funcs.mode(1)) - eq({'some short l'}, funcs.getreg('a',1,1)) + eq({ 'some short l' }, funcs.getreg('a', 1, 1)) -- select mode mapping works, and does not restart select mode feed('') eq('n', funcs.mode(1)) - eq({'some short l'}, funcs.getreg('b',1,1)) + eq({ 'some short l' }, funcs.getreg('b', 1, 1)) -- error doesn't interrupt temporary visual mode feed('ggvw') @@ -468,17 +470,16 @@ describe('mappings with ', function() eq('i', eval('mode(1)')) end) - it('works in operator-pending mode', function() feed('d') expect([[ lines of test text]]) - eq({'some short '}, funcs.getreg('"',1,1)) + eq({ 'some short ' }, funcs.getreg('"', 1, 1)) feed('.') expect([[ test text]]) - eq({'lines', 'of '}, funcs.getreg('"',1,1)) + eq({ 'lines', 'of ' }, funcs.getreg('"', 1, 1)) feed('uu') expect([[ some short lines @@ -504,7 +505,7 @@ describe('mappings with ', function() feed('"bd') expect([[ soest text]]) - eq(funcs.getreg('b',1,1), {'me short lines', 'of t'}) + eq(funcs.getreg('b', 1, 1), { 'me short lines', 'of t' }) -- startinsert aborts operator feed('d') @@ -514,7 +515,6 @@ describe('mappings with ', function() end) it('works in insert mode', function() - -- works the same as ww feed('iindeed little ') screen:expect([[ @@ -535,7 +535,6 @@ describe('mappings with ', function() {3:Press ENTER or type command to continue}^ | ]]) - feed('') eq('E605: Exception not caught: very error', eval('v:errmsg')) -- still in insert @@ -562,7 +561,7 @@ describe('mappings with ', function() of stuff test text]]) feed('') - eq(funcs.getreg('a',1,1), {'deed some short little lines', 'of stuff t'}) + eq(funcs.getreg('a', 1, 1), { 'deed some short little lines', 'of stuff t' }) -- still in insert screen:expect([[ @@ -704,7 +703,6 @@ describe('mappings with ', function() ]]) eq('i', eval('mode(1)')) eq(9, eval('g:y')) - end) it("doesn't crash when invoking cmdline mode recursively #8859", function() @@ -726,18 +724,20 @@ describe('mappings with ', function() ]]) end) - it("works with mappings", function() + it('works with mappings', function() command('new!') - write_file(tmpfile, [[ + write_file( + tmpfile, + [[ map call do_it() function! s:do_it() let g:x = 10 endfunction - ]]) - command('source '..tmpfile) + ]] + ) + command('source ' .. tmpfile) feed('') eq('', eval('v:errmsg')) eq(10, eval('g:x')) end) end) - -- cgit