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/legacy/close_count_spec.lua | 206 +++++++++++++++------------- 1 file changed, 107 insertions(+), 99 deletions(-) (limited to 'test/functional/legacy/close_count_spec.lua') diff --git a/test/functional/legacy/close_count_spec.lua b/test/functional/legacy/close_count_spec.lua index ad1812f22e..762493151c 100644 --- a/test/functional/legacy/close_count_spec.lua +++ b/test/functional/legacy/close_count_spec.lua @@ -1,133 +1,141 @@ -- Tests for :[count]close! and :[count]hide local helpers = require('test.functional.helpers')(after_each) -local feed, eval, eq, clear, execute = - helpers.feed, helpers.eval, helpers.eq, helpers.clear, helpers.execute + +local eq = helpers.eq +local wait = helpers.wait +local feed = helpers.feed +local clear = helpers.clear +local command = helpers.command describe('close_count', function() setup(clear) it('is working', function() - execute('let tests = []') - execute('for i in range(5)') - execute('new') - execute('endfor') - execute('4wincmd w') - execute('close!') - execute('let buffers = []') - execute('windo call add(buffers, bufnr("%"))') + command('let tests = []') + command('for i in range(5)') + command('new') + command('endfor') + command('4wincmd w') + command('close!') + command('let buffers = []') + command('windo call add(buffers, bufnr("%"))') eq({6, 5, 4, 2, 1}, eval('buffers')) - execute('1close!') - execute('let buffers = []') - execute('windo call add(buffers, bufnr("%"))') + command('1close!') + command('let buffers = []') + command('windo call add(buffers, bufnr("%"))') eq({5, 4, 2, 1}, eval('buffers')) - execute('$close!') - execute('let buffers = []') - execute('windo call add(buffers, bufnr("%"))') + command('$close!') + command('let buffers = []') + command('windo call add(buffers, bufnr("%"))') eq({5, 4, 2}, eval('buffers')) - execute('1wincmd w') - execute('2close!') - execute('let buffers = []') - execute('windo call add(buffers, bufnr("%"))') + command('1wincmd w') + command('2close!') + command('let buffers = []') + command('windo call add(buffers, bufnr("%"))') eq({5, 2}, eval('buffers')) - execute('1wincmd w') - execute('new') - execute('new') - execute('2wincmd w') - execute('-1close!') - execute('let buffers = []') - execute('windo call add(buffers, bufnr("%"))') + command('1wincmd w') + command('new') + command('new') + command('2wincmd w') + command('-1close!') + command('let buffers = []') + command('windo call add(buffers, bufnr("%"))') eq({7, 5, 2}, eval('buffers')) - execute('2wincmd w') - execute('+1close!') - execute('let buffers = []') - execute('windo call add(buffers, bufnr("%"))') + command('2wincmd w') + command('+1close!') + command('let buffers = []') + command('windo call add(buffers, bufnr("%"))') eq({7, 5}, eval('buffers')) - execute('only!') - execute('b1') - execute('let tests = []') - execute('for i in range(5)') - execute('new') - execute('endfor') - execute('let buffers = []') - execute('windo call add(buffers, bufnr("%"))') + command('only!') + command('b1') + command('let tests = []') + command('for i in range(5)') + command('new') + command('endfor') + command('let buffers = []') + command('windo call add(buffers, bufnr("%"))') eq({13, 12, 11, 10, 9, 1}, eval('buffers')) - execute('4wincmd w') - execute('.hide') - execute('let buffers = []') - execute('windo call add(buffers, bufnr("%"))') + command('4wincmd w') + command('.hide') + command('let buffers = []') + command('windo call add(buffers, bufnr("%"))') eq({13, 12, 11, 9, 1}, eval('buffers')) - execute('1hide') - execute('let buffers = []') - execute('windo call add(buffers, bufnr("%"))') + command('1hide') + command('let buffers = []') + command('windo call add(buffers, bufnr("%"))') eq({12, 11, 9, 1}, eval('buffers')) - execute('$hide') - execute('let buffers = []') - execute('windo call add(buffers, bufnr("%"))') + command('$hide') + command('let buffers = []') + command('windo call add(buffers, bufnr("%"))') eq({12, 11, 9}, eval('buffers')) - execute('1wincmd w') - execute('2hide') - execute('let buffers = []') - execute('windo call add(buffers, bufnr("%"))') + command('1wincmd w') + command('2hide') + command('let buffers = []') + command('windo call add(buffers, bufnr("%"))') eq({12, 9}, eval('buffers')) - execute('1wincmd w') - execute('new') - execute('new') - execute('3wincmd w') - execute('-hide') - execute('let buffers = []') - execute('windo call add(buffers, bufnr("%"))') + command('1wincmd w') + command('new') + command('new') + command('3wincmd w') + command('-hide') + command('let buffers = []') + command('windo call add(buffers, bufnr("%"))') eq({15, 12, 9}, eval('buffers')) - execute('2wincmd w') - execute('+hide') - execute('let buffers = []') - execute('windo call add(buffers, bufnr("%"))') + command('2wincmd w') + command('+hide') + command('let buffers = []') + command('windo call add(buffers, bufnr("%"))') eq({15, 12}, eval('buffers')) - execute('only!') - execute('b1') - execute('let tests = []') - execute('set hidden') - execute('for i in range(5)') - execute('new') - execute('endfor') - execute('1wincmd w') - execute('$ hide') - execute('let buffers = []') - execute('windo call add(buffers, bufnr("%"))') + command('only!') + command('b1') + command('let tests = []') + command('set hidden') + command('for i in range(5)') + command('new') + command('endfor') + command('1wincmd w') + command('$ hide') + command('let buffers = []') + command('windo call add(buffers, bufnr("%"))') eq({20, 19, 18, 17, 16}, eval('buffers')) - execute('$-1 close!') - execute('let buffers = []') - execute('windo call add(buffers, bufnr("%"))') + command('$-1 close!') + command('let buffers = []') + command('windo call add(buffers, bufnr("%"))') eq({20, 19, 18, 16}, eval('buffers')) - execute('1wincmd w') - execute('.+close!') - execute('let buffers = []') - execute('windo call add(buffers, bufnr("%"))') + command('1wincmd w') + command('.+close!') + command('let buffers = []') + command('windo call add(buffers, bufnr("%"))') eq({20, 18, 16}, eval('buffers')) - execute('only!') - execute('b1') - execute('let tests = []') - execute('set hidden') - execute('for i in range(5)') - execute('new') - execute('endfor') - execute('4wincmd w') + command('only!') + command('b1') + command('let tests = []') + command('set hidden') + command('for i in range(5)') + command('new') + command('endfor') + command('4wincmd w') feed('c') - execute('let buffers = []') - execute('windo call add(buffers, bufnr("%"))') + wait() + command('let buffers = []') + command('windo call add(buffers, bufnr("%"))') eq({25, 24, 23, 21, 1}, eval('buffers')) feed('1c') - execute('let buffers = []') - execute('windo call add(buffers, bufnr("%"))') + wait() + command('let buffers = []') + command('windo call add(buffers, bufnr("%"))') eq({24, 23, 21, 1}, eval('buffers')) feed('9c') - execute('let buffers = []') - execute('windo call add(buffers, bufnr("%"))') + wait() + command('let buffers = []') + command('windo call add(buffers, bufnr("%"))') eq({24, 23, 21}, eval('buffers')) - execute('1wincmd w') + command('1wincmd w') feed('2c') - execute('let buffers = []') - execute('windo call add(buffers, bufnr("%"))') + wait() + command('let buffers = []') + command('windo call add(buffers, bufnr("%"))') eq({24, 21}, eval('buffers')) end) end) -- cgit From e170186a8df448cab30dba7af6a6b2d081bfd62e Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 9 Apr 2017 02:20:48 +0300 Subject: functests: Fix legacy/close_count_spec --- test/functional/legacy/close_count_spec.lua | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'test/functional/legacy/close_count_spec.lua') diff --git a/test/functional/legacy/close_count_spec.lua b/test/functional/legacy/close_count_spec.lua index 762493151c..9b932e2ef0 100644 --- a/test/functional/legacy/close_count_spec.lua +++ b/test/functional/legacy/close_count_spec.lua @@ -4,6 +4,7 @@ local helpers = require('test.functional.helpers')(after_each) local eq = helpers.eq local wait = helpers.wait +local eval = helpers.eval local feed = helpers.feed local clear = helpers.clear local command = helpers.command @@ -13,9 +14,7 @@ describe('close_count', function() it('is working', function() command('let tests = []') - command('for i in range(5)') - command('new') - command('endfor') + command('for i in range(5)|new|endfor') command('4wincmd w') command('close!') command('let buffers = []') @@ -50,9 +49,7 @@ describe('close_count', function() command('only!') command('b1') command('let tests = []') - command('for i in range(5)') - command('new') - command('endfor') + command('for i in range(5)|new|endfor') command('let buffers = []') command('windo call add(buffers, bufnr("%"))') eq({13, 12, 11, 10, 9, 1}, eval('buffers')) @@ -91,9 +88,7 @@ describe('close_count', function() command('b1') command('let tests = []') command('set hidden') - command('for i in range(5)') - command('new') - command('endfor') + command('for i in range(5)|new|endfor') command('1wincmd w') command('$ hide') command('let buffers = []') @@ -112,9 +107,7 @@ describe('close_count', function() command('b1') command('let tests = []') command('set hidden') - command('for i in range(5)') - command('new') - command('endfor') + command('for i in range(5)|new|endfor') command('4wincmd w') feed('c') wait() -- cgit