aboutsummaryrefslogtreecommitdiff
path: root/test/functional/legacy/autocmd_option_spec.lua
diff options
context:
space:
mode:
authorwatiko <service@mail.watiko.net>2016-02-12 14:01:35 +0900
committerJurica Bradaric <jbradaric@gmail.com>2016-02-15 11:05:17 +0100
commit9bd8fcde1e82cb535abe46ff508de7029d8f686e (patch)
treee197c325010d7633413779e47169aa08bc78ab82 /test/functional/legacy/autocmd_option_spec.lua
parentb535df15540e2f9b2d209f9f51cd74f53770bc45 (diff)
downloadrneovim-9bd8fcde1e82cb535abe46ff508de7029d8f686e.tar.gz
rneovim-9bd8fcde1e82cb535abe46ff508de7029d8f686e.tar.bz2
rneovim-9bd8fcde1e82cb535abe46ff508de7029d8f686e.zip
test: Add test cases to legacy test autocmd_option
Diffstat (limited to 'test/functional/legacy/autocmd_option_spec.lua')
-rw-r--r--test/functional/legacy/autocmd_option_spec.lua43
1 files changed, 42 insertions, 1 deletions
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')