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/viml/completion_spec.lua | 52 ++++++++++++++++---------------- test/functional/viml/lang_spec.lua | 5 ++- 2 files changed, 28 insertions(+), 29 deletions(-) (limited to 'test/functional/viml') diff --git a/test/functional/viml/completion_spec.lua b/test/functional/viml/completion_spec.lua index 5a37cb8f43..b35e8d4f94 100644 --- a/test/functional/viml/completion_spec.lua +++ b/test/functional/viml/completion_spec.lua @@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local clear, feed = helpers.clear, helpers.feed local eval, eq, neq = helpers.eval, helpers.eq, helpers.neq -local execute, source, expect = helpers.execute, helpers.source, helpers.expect +local feed_command, source, expect = helpers.feed_command, helpers.source, helpers.expect local meths = helpers.meths if helpers.pending_win32(pending) then return end @@ -67,25 +67,25 @@ describe('completion', function() it('is readonly', function() screen:try_resize(80, 8) feed('ifooo') - execute('let v:completed_item.word = "bar"') + feed_command('let v:completed_item.word = "bar"') neq(nil, string.find(eval('v:errmsg'), '^E46: ')) - execute('let v:errmsg = ""') + feed_command('let v:errmsg = ""') - execute('let v:completed_item.abbr = "bar"') + feed_command('let v:completed_item.abbr = "bar"') neq(nil, string.find(eval('v:errmsg'), '^E46: ')) - execute('let v:errmsg = ""') + feed_command('let v:errmsg = ""') - execute('let v:completed_item.menu = "bar"') + feed_command('let v:completed_item.menu = "bar"') neq(nil, string.find(eval('v:errmsg'), '^E46: ')) - execute('let v:errmsg = ""') + feed_command('let v:errmsg = ""') - execute('let v:completed_item.info = "bar"') + feed_command('let v:completed_item.info = "bar"') neq(nil, string.find(eval('v:errmsg'), '^E46: ')) - execute('let v:errmsg = ""') + feed_command('let v:errmsg = ""') - execute('let v:completed_item.kind = "bar"') + feed_command('let v:completed_item.kind = "bar"') neq(nil, string.find(eval('v:errmsg'), '^E46: ')) - execute('let v:errmsg = ""') + feed_command('let v:errmsg = ""') end) it('returns expected dict in omni completion', function() source([[ @@ -125,7 +125,7 @@ describe('completion', function() end) it('inserts the first candidate if default', function() - execute('set completeopt+=menuone') + feed_command('set completeopt+=menuone') feed('ifooo') screen:expect([[ foo | @@ -176,7 +176,7 @@ describe('completion', function() eq('foo', eval('getline(3)')) end) it('selects the first candidate if noinsert', function() - execute('set completeopt+=menuone,noinsert') + feed_command('set completeopt+=menuone,noinsert') feed('ifooo') screen:expect([[ foo | @@ -216,7 +216,7 @@ describe('completion', function() eq('foo', eval('getline(3)')) end) it('does not insert the first candidate if noselect', function() - execute('set completeopt+=menuone,noselect') + feed_command('set completeopt+=menuone,noselect') feed('ifooo') screen:expect([[ foo | @@ -256,7 +256,7 @@ describe('completion', function() eq('bar', eval('getline(3)')) end) it('does not select/insert the first candidate if noselect and noinsert', function() - execute('set completeopt+=menuone,noselect,noinsert') + feed_command('set completeopt+=menuone,noselect,noinsert') feed('ifooo') screen:expect([[ foo | @@ -305,14 +305,14 @@ describe('completion', function() eq('', eval('getline(3)')) end) it('does not change modified state if noinsert', function() - execute('set completeopt+=menuone,noinsert') - execute('setlocal nomodified') + feed_command('set completeopt+=menuone,noinsert') + feed_command('setlocal nomodified') feed('i=TestComplete()') eq(0, eval('&l:modified')) end) it('does not change modified state if noselect', function() - execute('set completeopt+=menuone,noselect') - execute('setlocal nomodified') + feed_command('set completeopt+=menuone,noselect') + feed_command('setlocal nomodified') feed('i=TestComplete()') eq(0, eval('&l:modified')) end) @@ -326,8 +326,8 @@ describe('completion', function() return '' endfunction ]]) - execute('set completeopt+=noselect,noinsert') - execute('inoremap =TestComplete()') + feed_command('set completeopt+=noselect,noinsert') + feed_command('inoremap =TestComplete()') end) local tests = { @@ -541,7 +541,7 @@ describe('completion', function() return '' endfunction ]]) - execute("set completeopt=menuone,noselect") + feed_command("set completeopt=menuone,noselect") end) it("works", function() @@ -707,7 +707,7 @@ describe('completion', function() it('disables folding during completion', function () - execute("set foldmethod=indent") + feed_command("set foldmethod=indent") feed('ifoobargg') screen:expect([[ ^foo | @@ -734,7 +734,7 @@ describe('completion', function() end) it('popupmenu is not interrupted by events', function () - execute("set complete=.") + feed_command("set complete=.") feed('ifoobar fooeggf') screen:expect([[ @@ -852,8 +852,8 @@ describe('completion', function() end) it("'ignorecase' 'infercase' CTRL-X CTRL-N #6451", function() - execute('set ignorecase infercase') - execute('edit BACKERS.md') + feed_command('set ignorecase infercase') + feed_command('edit BACKERS.md') feed('oX') screen:expect([[ # Bountysource Backers | diff --git a/test/functional/viml/lang_spec.lua b/test/functional/viml/lang_spec.lua index a27e18f695..3ba9221aef 100644 --- a/test/functional/viml/lang_spec.lua +++ b/test/functional/viml/lang_spec.lua @@ -1,13 +1,12 @@ local helpers = require('test.functional.helpers')(after_each) local clear, eval, eq = helpers.clear, helpers.eval, helpers.eq -local execute, source = helpers.execute, helpers.source +local exc_exec, source = helpers.exc_exec, helpers.source describe('viml', function() before_each(clear) it('parses `` with turkish locale', function() - execute('lang ctype tr_TR.UTF-8') - if string.find(eval('v:errmsg'), '^E197: ') then + if exc_exec('lang ctype tr_TR.UTF-8') ~= 0 then pending("Locale tr_TR.UTF-8 not supported") return end -- cgit