From 65fb622000af8e3dbb65480e1581758ecf4ba3e2 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 9 Apr 2017 00:12:26 +0300 Subject: functests: Replace execute with either command or feed_command Hope this will make people using feed_command less likely: this hides bugs. Already found at least two: 1. msgpackparse() will show internal error: hash_add() in case of duplicate keys, though it will still work correctly. Currently silenced. 2. ttimeoutlen was spelled incorrectly, resulting in option not being set when expected. Test was still functioning somehow though. Currently fixed. --- test/functional/normal/count_spec.lua | 4 ++-- test/functional/normal/fold_spec.lua | 34 +++++++++++++++++----------------- test/functional/normal/put_spec.lua | 24 ++++++++++++------------ test/functional/normal/undo_spec.lua | 4 ++-- 4 files changed, 33 insertions(+), 33 deletions(-) (limited to 'test/functional/normal') diff --git a/test/functional/normal/count_spec.lua b/test/functional/normal/count_spec.lua index 700e1f3e81..94f741250a 100644 --- a/test/functional/normal/count_spec.lua +++ b/test/functional/normal/count_spec.lua @@ -4,13 +4,13 @@ local eq = helpers.eq local eval = helpers.eval local feed = helpers.feed local clear = helpers.clear -local execute = helpers.execute +local command = helpers.command describe('v:count/v:count1', function() before_each(function() clear() - execute('map _x :let g:count = "v:count=". v:count .", v:count1=". v:count1') + command('map _x :let g:count = "v:count=". v:count .", v:count1=". v:count1') end) describe('in cmdwin', function() diff --git a/test/functional/normal/fold_spec.lua b/test/functional/normal/fold_spec.lua index fc055c4e7a..85e4631b61 100644 --- a/test/functional/normal/fold_spec.lua +++ b/test/functional/normal/fold_spec.lua @@ -4,7 +4,7 @@ local clear = helpers.clear local insert = helpers.insert local feed = helpers.feed local expect = helpers.expect -local execute = helpers.execute +local feed_command = helpers.feed_command local funcs = helpers.funcs local foldlevel = funcs.foldlevel local foldclosedend = funcs.foldclosedend @@ -13,7 +13,7 @@ local eq = helpers.eq describe('Folds', function() local tempfname = 'Xtest-fold.txt' clear() - before_each(function() execute('enew!') end) + before_each(function() feed_command('enew!') end) after_each(function() os.remove(tempfname) end) it('manual folding adjusts with filter', function() insert([[ @@ -37,8 +37,8 @@ describe('Folds', function() 18 19 20]]) - execute('4,$fold', '%foldopen', '10,$fold', '%foldopen') - execute('1,8! cat') + feed_command('4,$fold', '%foldopen', '10,$fold', '%foldopen') + feed_command('1,8! cat') feed('5ggzdzMGdd') expect([[ 1 @@ -54,13 +54,13 @@ describe('Folds', function() describe('adjusting folds after :move', function() local function manually_fold_indent() -- setting foldmethod twice is a trick to get vim to set the folds for me - execute('set foldmethod=indent', 'set foldmethod=manual') + feed_command('set foldmethod=indent', 'set foldmethod=manual') -- Ensure that all folds will get closed (makes it easier to test the -- length of folds). - execute('set foldminlines=0') + feed_command('set foldminlines=0') -- Start with all folds open (so :move ranges aren't affected by closed -- folds). - execute('%foldopen!') + feed_command('%foldopen!') end local function get_folds() @@ -75,16 +75,16 @@ describe('Folds', function() -- This test is easy because we just need to ensure that the resulting -- fold is the same as calculated when creating folds from scratch. insert(insert_string) - execute(move_command) + feed_command(move_command) local after_move_folds = get_folds() -- Doesn't change anything, but does call foldUpdateAll() - execute('set foldminlines=0') + feed_command('set foldminlines=0') eq(after_move_folds, get_folds()) -- Set up the buffer with insert_string for the manual fold testing. - execute('enew!') + feed_command('enew!') insert(insert_string) manually_fold_indent() - execute(move_command) + feed_command(move_command) end it('neither closes nor corrupts folds', function() @@ -246,8 +246,8 @@ a]], '2,3m0') a a ]]) - execute('set foldmethod=indent', '2', '%foldopen') - execute('read ' .. tempfname) + feed_command('set foldmethod=indent', '2', '%foldopen') + feed_command('read ' .. tempfname) -- Just to check we have the correct file text. expect([[ a @@ -281,7 +281,7 @@ a]], '2,3m0') a a ]]) - execute('set foldmethod=indent', '3,5d') + feed_command('set foldmethod=indent', '3,5d') eq(5, funcs.foldclosedend(1)) end) it("doesn't combine folds that have a specified end", function() @@ -295,7 +295,7 @@ a]], '2,3m0') }}} ]]) - execute('set foldmethod=marker', '3,5d', '%foldclose') + feed_command('set foldmethod=marker', '3,5d', '%foldclose') eq(2, funcs.foldclosedend(1)) end) it('splits folds according to >N and u') funcs.setreg('a', 'test_stringa', 'V') funcs.setreg('b', 'test_stringb\ntest_stringb\ntest_stringb', 'b') funcs.setreg('"', 'test_string"', 'v') - execute('set virtualedit=') + feed_command('set virtualedit=') end -- We check the last inserted register ". in each of these tests because it is @@ -164,7 +164,7 @@ describe('put command', function() local function create_put_action(command_base, substitution) local temp_val = command_base:gsub('put', substitution) return function() - execute(temp_val) + feed_command(temp_val) return true end end @@ -642,7 +642,7 @@ describe('put command', function() -- Set curswant to '8' to be at the end of the tab character -- This is where the cursor is put back after the 'u' command. funcs.setpos('.', {0, 2, 1, 0, 8}) - execute('set autoindent') + feed_command('set autoindent') end ) end) @@ -653,7 +653,7 @@ describe('put command', function() test_stringx" Line of words 2]] run_normal_mode_tests(test_string, 'p', function() funcs.setline('$', ' Line of words 2') - execute('set virtualedit=all') + feed_command('set virtualedit=all') funcs.setpos('.', {0, 2, 1, 2, 3}) end) end) @@ -664,7 +664,7 @@ describe('put command', function() Line of words 2]] run_normal_mode_tests(test_string, 'p', function() funcs.setline('$', ' Line of words 2') - execute('set virtualedit=all') + feed_command('set virtualedit=all') funcs.setpos('.', {0, 1, 16, 1, 17}) end, true) end) @@ -829,7 +829,7 @@ describe('put command', function() 'vp', function() funcs.setline('$', ' Line of words 2') - execute('set virtualedit=all') + feed_command('set virtualedit=all') funcs.setpos('.', {0, 2, 1, 2, 3}) end, nil, @@ -844,7 +844,7 @@ describe('put command', function() base_expect_string, 'vp', function() - execute('set virtualedit=all') + feed_command('set virtualedit=all') funcs.setpos('.', {0, 1, 16, 2, 18}) end, true, @@ -906,7 +906,7 @@ describe('put command', function() end) it('should ring the bell when deleting if not appropriate', function() - execute('goto 2') + feed_command('goto 2') feed('i') expect([[ ine of words 1 @@ -921,7 +921,7 @@ describe('put command', function() end) it("should be unaffected by 'autoindent' with V\".2p", function() - execute('set autoindent') + feed_command('set autoindent') feed('i test_string.u') feed('V".2p') expect([[ diff --git a/test/functional/normal/undo_spec.lua b/test/functional/normal/undo_spec.lua index 55429f2e1e..a023ca3d90 100644 --- a/test/functional/normal/undo_spec.lua +++ b/test/functional/normal/undo_spec.lua @@ -1,7 +1,7 @@ local helpers = require('test.functional.helpers')(after_each) local clear = helpers.clear -local execute = helpers.execute +local command = helpers.command local expect = helpers.expect local feed = helpers.feed local insert = helpers.insert @@ -23,7 +23,7 @@ describe('u CTRL-R g- g+', function() end local function undo_and_redo(hist_pos, undo, redo, expect_str) - execute('enew!') + command('enew!') create_history(hist_pos) local cur_contents = helpers.curbuf_contents() feed(undo) -- cgit