From 9bd8fcde1e82cb535abe46ff508de7029d8f686e Mon Sep 17 00:00:00 2001 From: watiko Date: Fri, 12 Feb 2016 14:01:35 +0900 Subject: test: Add test cases to legacy test autocmd_option --- test/functional/legacy/autocmd_option_spec.lua | 43 +++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) (limited to 'test/functional') diff --git a/test/functional/legacy/autocmd_option_spec.lua b/test/functional/legacy/autocmd_option_spec.lua index 855e9c6271..48b5109aa2 100644 --- a/test/functional/legacy/autocmd_option_spec.lua +++ b/test/functional/legacy/autocmd_option_spec.lua @@ -2,6 +2,8 @@ local helpers = require('test.functional.helpers') local nvim = helpers.meths local clear, eq, neq = helpers.clear, helpers.eq, helpers.neq local curbuf, buf = helpers.curbuf, helpers.bufmeths +local curwin, win = helpers.curwin, helpers.winmeths +local redir_exec = helpers.redir_exec local source, execute = helpers.source, helpers.execute local function declare_hook_function() @@ -86,7 +88,7 @@ end local function make_buffer() local old_buf = curbuf() - execute('new') + execute('botright new') local new_buf = curbuf() execute('wincmd p') -- move previous window @@ -96,6 +98,19 @@ local function make_buffer() return new_buf end +local function make_window_with_winnr() + local old_win = curwin() + execute('botright new') + local new_win = curwin() + local new_winnr = redir_exec('echo winnr()') + execute('wincmd p') -- move previous window + + neq(old_win, new_win) + eq(old_win, curwin()) + + return new_win, new_winnr:gsub('\n', '') +end + describe('au OptionSet', function() describe('with any opton (*)', function() @@ -248,6 +263,32 @@ describe('au OptionSet', function() end) end) + describe('being set by setwinvar()', function() + it('should not trigger because option name does not match with backup', function() + set_hook('backup') + + execute('call setwinvar(1, "&l:bk", 1)') + expected_empty() + end) + + it('should trigger, use correct option name backup', function() + set_hook('backup') + + execute('call setwinvar(1, "&backup", 1)') + expected_combination({'backup', 0, 1, 'local'}) + end) + + it('should not trigger if the current window is different from the targetted window', function() + set_hook('cursorcolumn') + + local new_window, new_winnr = make_window_with_winnr() + + execute('call setwinvar(' .. new_winnr .. ', "&cursorcolumn", 1)') + -- expected_combination({'cursorcolumn', 0, 1, 'local', {winnr = new_winnr}}) + expected_empty() + end) + end) + describe('being set by neovim api', function() it('should trigger if a boolean option be set globally', function() set_hook('autochdir') -- cgit From 1eeadd709862d8f90d43e08964200465af5c8323 Mon Sep 17 00:00:00 2001 From: watiko Date: Fri, 12 Feb 2016 20:38:20 +0900 Subject: test: Fix lint error --- test/functional/legacy/autocmd_option_spec.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'test/functional') diff --git a/test/functional/legacy/autocmd_option_spec.lua b/test/functional/legacy/autocmd_option_spec.lua index 48b5109aa2..6349371808 100644 --- a/test/functional/legacy/autocmd_option_spec.lua +++ b/test/functional/legacy/autocmd_option_spec.lua @@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers') local nvim = helpers.meths local clear, eq, neq = helpers.clear, helpers.eq, helpers.neq local curbuf, buf = helpers.curbuf, helpers.bufmeths -local curwin, win = helpers.curwin, helpers.winmeths +local curwin = helpers.curwin local redir_exec = helpers.redir_exec local source, execute = helpers.source, helpers.execute @@ -98,7 +98,7 @@ local function make_buffer() return new_buf end -local function make_window_with_winnr() +local function get_new_window_number() local old_win = curwin() execute('botright new') local new_win = curwin() @@ -108,7 +108,7 @@ local function make_window_with_winnr() neq(old_win, new_win) eq(old_win, curwin()) - return new_win, new_winnr:gsub('\n', '') + return new_winnr:gsub('\n', '') end describe('au OptionSet', function() @@ -281,7 +281,7 @@ describe('au OptionSet', function() it('should not trigger if the current window is different from the targetted window', function() set_hook('cursorcolumn') - local new_window, new_winnr = make_window_with_winnr() + local new_winnr = get_new_window_number() execute('call setwinvar(' .. new_winnr .. ', "&cursorcolumn", 1)') -- expected_combination({'cursorcolumn', 0, 1, 'local', {winnr = new_winnr}}) -- cgit