From ef16a02a76f45e0c8460321439a697e6901465a6 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 27 Apr 2025 09:46:53 -0700 Subject: [PATCH] test: feed_command is deprecated #33674 --- test/functional/ex_cmds/encoding_spec.lua | 9 +- test/functional/ex_cmds/grep_spec.lua | 10 +-- test/functional/provider/clipboard_spec.lua | 98 ++++++++++----------- 3 files changed, 57 insertions(+), 60 deletions(-) diff --git a/test/functional/ex_cmds/encoding_spec.lua b/test/functional/ex_cmds/encoding_spec.lua index 6b882253b9..a98c3a01e2 100644 --- a/test/functional/ex_cmds/encoding_spec.lua +++ b/test/functional/ex_cmds/encoding_spec.lua @@ -1,7 +1,7 @@ local t = require('test.testutil') local n = require('test.functional.testnvim')() -local clear, feed_command, feed = n.clear, n.feed_command, n.feed +local clear, feed = n.clear, n.feed local eq, neq, eval = t.eq, t.neq, n.eval describe('&encoding', function() @@ -13,10 +13,7 @@ describe('&encoding', function() end) it('cannot be changed after setup', function() - feed_command('set encoding=latin1') - -- error message expected - feed('') - neq(nil, string.find(eval('v:errmsg'), '^E519:')) + t.matches('E519%:', t.pcall_err(n.command, 'set encoding=latin1')) eq('utf-8', eval('&encoding')) -- check nvim is still in utf-8 mode eq(3, eval('strwidth("Bär")')) @@ -32,7 +29,7 @@ describe('&encoding', function() end) it('can be set to utf-8 without error', function() - feed_command('set encoding=utf-8') + n.command('set encoding=utf-8') eq('', eval('v:errmsg')) clear('--cmd', 'set enc=utf-8') diff --git a/test/functional/ex_cmds/grep_spec.lua b/test/functional/ex_cmds/grep_spec.lua index f7d0f43c62..88fab7101e 100644 --- a/test/functional/ex_cmds/grep_spec.lua +++ b/test/functional/ex_cmds/grep_spec.lua @@ -1,7 +1,7 @@ local t = require('test.testutil') local n = require('test.functional.testnvim')() -local clear, feed_command, feed, ok, eval = n.clear, n.feed_command, n.feed, t.ok, n.eval +local clear, ok, eval = n.clear, t.ok, n.eval describe(':grep', function() before_each(clear) @@ -12,11 +12,11 @@ describe(':grep', function() return end - feed_command([[set grepprg=grep\ -r]]) + n.command([[set grepprg=grep\ -r]]) -- Change to test directory so that the test does not run too long. - feed_command('cd test') - feed_command('grep a **/*') - feed('') -- Press ENTER + n.command('cd test') + n.feed(':grep a **/*') + n.feed('') -- Press ENTER ok(eval('len(getqflist())') > 9000) -- IT'S OVER 9000!!1 end) end) diff --git a/test/functional/provider/clipboard_spec.lua b/test/functional/provider/clipboard_spec.lua index 2b54ea93e0..d97014ed3f 100644 --- a/test/functional/provider/clipboard_spec.lua +++ b/test/functional/provider/clipboard_spec.lua @@ -5,7 +5,7 @@ local n = require('test.functional.testnvim')() local Screen = require('test.functional.ui.screen') local clear, feed, insert = n.clear, n.feed, n.insert -local feed_command, expect, eq, eval, source = n.feed_command, n.expect, t.eq, n.eval, n.source +local expect, eq, eval, source = n.expect, t.eq, n.eval, n.source local command = n.command local api = n.api @@ -144,7 +144,7 @@ describe('clipboard', function() it('`:redir @+>` with invalid g:clipboard shows exactly one error #7184', function() command("let g:clipboard = 'bogus'") - feed_command('redir @+> | :silent echo system("cat CONTRIBUTING.md") | redir END') + command('redir @+> | :silent echo system("cat CONTRIBUTING.md") | redir END') screen:expect([[ ^ | {1:~ }|*2 @@ -154,7 +154,7 @@ describe('clipboard', function() it('`:redir @+>|bogus_cmd|redir END` + invalid g:clipboard must not recurse #7184', function() command("let g:clipboard = 'bogus'") - feed_command('redir @+> | bogus_cmd | redir END') + feed(':redir @+> | bogus_cmd | redir END') screen:expect { grid = [[ {3: }| @@ -172,7 +172,7 @@ describe('clipboard', function() command("let g:clipboard = 'bogus'") -- Explicit clipboard attempt, should show a hint message. - feed_command('let @+="foo"') + feed(':let @+="foo"') screen:expect([[ ^ | {1:~ }|*2 @@ -296,12 +296,12 @@ describe('clipboard (with fake clipboard.vim)', function() before_each(function() reset() - feed_command('call getreg("*")') -- force load of provider + command('call getreg("*")') -- force load of provider end) it('`:redir @+>` invokes clipboard once-per-message', function() eq(0, eval('g:clip_called_set')) - feed_command('redir @+> | :silent echo system("cat CONTRIBUTING.md") | redir END') + command('redir @+> | :silent echo system("cat CONTRIBUTING.md") | redir END') -- Assuming CONTRIBUTING.md has >100 lines. assert(eval('g:clip_called_set') > 100) end) @@ -311,13 +311,13 @@ describe('clipboard (with fake clipboard.vim)', function() -- NOT propagate to the clipboard. This is consistent with Vim. command('set clipboard=unnamedplus') eq(0, eval('g:clip_called_set')) - feed_command('redir @"> | :silent echo system("cat CONTRIBUTING.md") | redir END') + command('redir @"> | :silent echo system("cat CONTRIBUTING.md") | redir END') eq(0, eval('g:clip_called_set')) end) it('`:redir @+>|bogus_cmd|redir END` must not recurse #7184', function() local screen = Screen.new(72, 4) - feed_command('redir @+> | bogus_cmd | redir END') + feed(':redir @+> | bogus_cmd | redir END') screen:expect([[ ^ | {1:~ }|*2 @@ -367,8 +367,8 @@ describe('clipboard (with fake clipboard.vim)', function() end) it('autodetects regtype', function() - feed_command("let g:test_clip['*'] = ['linewise stuff','']") - feed_command("let g:test_clip['+'] = ['charwise','stuff']") + command("let g:test_clip['*'] = ['linewise stuff','']") + command("let g:test_clip['+'] = ['charwise','stuff']") eq('V', eval("getregtype('*')")) eq('v', eval("getregtype('+')")) insert('just some text') @@ -383,7 +383,7 @@ describe('clipboard (with fake clipboard.vim)', function() insert([[ much text]]) - feed_command("let g:test_clip['*'] = [['very','block'],'b']") + command("let g:test_clip['*'] = [['very','block'],'b']") feed('gg"*P') expect([[ very much @@ -397,15 +397,15 @@ describe('clipboard (with fake clipboard.vim)', function() end) it('supports setreg()', function() - feed_command('call setreg("*", "setted\\ntext", "c")') - feed_command('call setreg("+", "explicitly\\nlines", "l")') + command('call setreg("*", "setted\\ntext", "c")') + command('call setreg("+", "explicitly\\nlines", "l")') feed('"+P"*p') expect([[ esetted textxplicitly lines ]]) - feed_command('call setreg("+", "blocky\\nindeed", "b")') + command('call setreg("+", "blocky\\nindeed", "b")') feed('"+p') expect([[ esblockyetted @@ -415,13 +415,13 @@ describe('clipboard (with fake clipboard.vim)', function() end) it('supports :let @+ (issue #1427)', function() - feed_command("let @+ = 'some'") - feed_command("let @* = ' other stuff'") + command("let @+ = 'some'") + command("let @* = ' other stuff'") eq({ { 'some' }, 'v' }, eval("g:test_clip['+']")) eq({ { ' other stuff' }, 'v' }, eval("g:test_clip['*']")) feed('"+p"*p') expect('some other stuff') - feed_command("let @+ .= ' more'") + command("let @+ .= ' more'") feed('dd"+p') expect('some more') end) @@ -429,7 +429,7 @@ describe('clipboard (with fake clipboard.vim)', function() it('pastes unnamed register if the provider fails', function() insert('the text') feed('yy') - feed_command('let g:cliperror = 1') + command('let g:cliperror = 1') feed('"*p') expect([[ the text @@ -440,7 +440,7 @@ describe('clipboard (with fake clipboard.vim)', function() -- the basic behavior of unnamed register should be the same -- even when handled by clipboard provider before_each(function() - feed_command('set clipboard=unnamed') + feed(':set clipboard=unnamed') end) it('works', function() @@ -448,7 +448,7 @@ describe('clipboard (with fake clipboard.vim)', function() end) it('works with pure text clipboard', function() - feed_command('let g:cliplossy = 1') + command('let g:cliplossy = 1') -- expect failure for block mode basic_register_test(true) end) @@ -463,7 +463,7 @@ describe('clipboard (with fake clipboard.vim)', function() -- "+ shouldn't have changed eq({ '' }, eval("g:test_clip['+']")) - feed_command("let g:test_clip['*'] = ['linewise stuff','']") + command("let g:test_clip['*'] = ['linewise stuff','']") feed('p') expect([[ words @@ -473,7 +473,7 @@ describe('clipboard (with fake clipboard.vim)', function() it('does not clobber "0 when pasting', function() insert('a line') feed('yy') - feed_command("let g:test_clip['*'] = ['b line','']") + command("let g:test_clip['*'] = ['b line','']") feed('"0pp"0p') expect([[ a line @@ -484,20 +484,20 @@ describe('clipboard (with fake clipboard.vim)', function() it('supports v:register and getreg() without parameters', function() eq('*', eval('v:register')) - feed_command("let g:test_clip['*'] = [['some block',''], 'b']") + command("let g:test_clip['*'] = [['some block',''], 'b']") eq('some block', eval('getreg()')) eq('\02210', eval('getregtype()')) end) it('yanks visual selection when pasting', function() insert('indeed visual') - feed_command("let g:test_clip['*'] = [['clipboard'], 'c']") + command("let g:test_clip['*'] = [['clipboard'], 'c']") feed('viwp') eq({ { 'visual' }, 'v' }, eval("g:test_clip['*']")) expect('indeed clipboard') -- explicit "* should do the same - feed_command("let g:test_clip['*'] = [['star'], 'c']") + command("let g:test_clip['*'] = [['star'], 'c']") feed('viw"*p') eq({ { 'clipboard' }, 'v' }, eval("g:test_clip['*']")) expect('indeed star') @@ -506,7 +506,7 @@ describe('clipboard (with fake clipboard.vim)', function() it('unnamed operations work even if the provider fails', function() insert('the text') feed('yy') - feed_command('let g:cliperror = 1') + command('let g:cliperror = 1') feed('p') expect([[ the text @@ -520,11 +520,11 @@ describe('clipboard (with fake clipboard.vim)', function() match text ]]) - feed_command('g/match/d') + command('g/match/d') eq('match\n', eval('getreg("*")')) feed('u') eval('setreg("*", "---")') - feed_command('g/test/') + command('g/test/') feed('') eq('---', eval('getreg("*")')) end) @@ -554,7 +554,7 @@ describe('clipboard (with fake clipboard.vim)', function() describe('clipboard=unnamedplus', function() before_each(function() - feed_command('set clipboard=unnamedplus') + feed(':set clipboard=unnamedplus') end) it('links the "+ and unnamed registers', function() @@ -567,13 +567,13 @@ describe('clipboard (with fake clipboard.vim)', function() -- "* shouldn't have changed eq({ '' }, eval("g:test_clip['*']")) - feed_command("let g:test_clip['+'] = ['three']") + command("let g:test_clip['+'] = ['three']") feed('p') expect('twothree') end) it('and unnamed, yanks to both', function() - feed_command('set clipboard=unnamedplus,unnamed') + command('set clipboard=unnamedplus,unnamed') insert([[ really unnamed text]]) @@ -587,8 +587,8 @@ describe('clipboard (with fake clipboard.vim)', function() -- unnamedplus takes precedence when pasting eq('+', eval('v:register')) - feed_command("let g:test_clip['+'] = ['the plus','']") - feed_command("let g:test_clip['*'] = ['the star','']") + command("let g:test_clip['+'] = ['the plus','']") + command("let g:test_clip['*'] = ['the star','']") feed('p') expect([[ text @@ -604,11 +604,11 @@ describe('clipboard (with fake clipboard.vim)', function() match text ]]) - feed_command('g/match/d') + command('g/match/d') eq('match\n', eval('getreg("+")')) feed('u') eval('setreg("+", "---")') - feed_command('g/test/') + command('g/test/') feed('') eq('---', eval('getreg("+")')) end) @@ -623,13 +623,13 @@ describe('clipboard (with fake clipboard.vim)', function() it('supports :put', function() insert('a line') - feed_command("let g:test_clip['*'] = ['some text']") - feed_command("let g:test_clip['+'] = ['more', 'text', '']") - feed_command(':put *') + command("let g:test_clip['*'] = ['some text']") + command("let g:test_clip['+'] = ['more', 'text', '']") + command(':put *') expect([[ a line some text]]) - feed_command(':put +') + command(':put +') expect([[ a line some text @@ -639,9 +639,9 @@ describe('clipboard (with fake clipboard.vim)', function() it('supports "+ and "* in registers', function() local screen = Screen.new(60, 10) - feed_command("let g:test_clip['*'] = ['some', 'star data','']") - feed_command("let g:test_clip['+'] = ['such', 'plus', 'stuff']") - feed_command('registers') + feed(":let g:test_clip['*'] = ['some', 'star data','']") + feed(":let g:test_clip['+'] = ['such', 'plus', 'stuff']") + feed(':registers') screen:expect( [[ | @@ -669,17 +669,17 @@ describe('clipboard (with fake clipboard.vim)', function() insert('s/s/t/') feed('gg"*y$:*') expect('t/s/t/') - feed_command("let g:test_clip['*'] = ['s/s/u']") + command("let g:test_clip['*'] = ['s/s/u']") feed(':*') expect('t/u/t/') end) it('supports :redir @*>', function() - feed_command("let g:test_clip['*'] = ['stuff']") - feed_command('redir @*>') + command("let g:test_clip['*'] = ['stuff']") + command('redir @*>') -- it is made empty eq({ { '' }, 'v' }, eval("g:test_clip['*']")) - feed_command('let g:test = doesnotexist') + feed(':let g:test = doesnotexist') feed('') eq( { { @@ -689,7 +689,7 @@ describe('clipboard (with fake clipboard.vim)', function() }, 'v' }, eval("g:test_clip['*']") ) - feed_command(':echo "Howdy!"') + feed(':echo "Howdy!"') eq({ { '', @@ -703,7 +703,7 @@ describe('clipboard (with fake clipboard.vim)', function() end) it('handles middleclick correctly', function() - feed_command('set mouse=a') + command('set mouse=a') local screen = Screen.new(30, 5) insert([[ @@ -724,7 +724,7 @@ describe('clipboard (with fake clipboard.vim)', function() the a target]]) -- on error, fall back to unnamed register - feed_command('let g:cliperror = 1') + command('let g:cliperror = 1') feed('<6,1>') expect([[ the source