diff options
Diffstat (limited to 'test/functional/options')
-rw-r--r-- | test/functional/options/defaults_spec.lua | 6 | ||||
-rw-r--r-- | test/functional/options/num_options_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/options/winfixbuf_spec.lua | 54 |
3 files changed, 58 insertions, 4 deletions
diff --git a/test/functional/options/defaults_spec.lua b/test/functional/options/defaults_spec.lua index d27fa375ee..a7cdc5f9fa 100644 --- a/test/functional/options/defaults_spec.lua +++ b/test/functional/options/defaults_spec.lua @@ -1243,11 +1243,11 @@ describe('autocommands', function() command('au BufEnter * let g:n = g:n + 1') command('terminal') - eq(eval('get(g:, "n", 0)'), 1) + eq(1, eval('get(g:, "n", 0)')) helpers.retry(nil, 1000, function() - neq(api.nvim_get_option_value('buftype', { buf = 0 }), 'terminal') - eq(eval('get(g:, "n", 0)'), 2) + neq('terminal', api.nvim_get_option_value('buftype', { buf = 0 })) + eq(2, eval('get(g:, "n", 0)')) end) end) end) diff --git a/test/functional/options/num_options_spec.lua b/test/functional/options/num_options_spec.lua index 0614bcf814..3b411b109c 100644 --- a/test/functional/options/num_options_spec.lua +++ b/test/functional/options/num_options_spec.lua @@ -12,7 +12,7 @@ local function should_fail(opt, value, errmsg) eq(errmsg, eval('v:errmsg'):match('E%d*')) feed_command('let v:errmsg = ""') local status, err = pcall(api.nvim_set_option_value, opt, value, {}) - eq(status, false) + eq(false, status) eq(errmsg, err:match('E%d*')) eq('', eval('v:errmsg')) end diff --git a/test/functional/options/winfixbuf_spec.lua b/test/functional/options/winfixbuf_spec.lua new file mode 100644 index 0000000000..20407b9bb7 --- /dev/null +++ b/test/functional/options/winfixbuf_spec.lua @@ -0,0 +1,54 @@ +local helpers = require('test.functional.helpers')(after_each) +local clear = helpers.clear +local exec_lua = helpers.exec_lua + +describe("Nvim API calls with 'winfixbuf'", function() + before_each(function() + clear() + end) + + it("Calling vim.api.nvim_win_set_buf with 'winfixbuf'", function() + local results = exec_lua([[ + local function _setup_two_buffers() + local buffer = vim.api.nvim_create_buf(true, true) + + vim.api.nvim_create_buf(true, true) -- Make another buffer + + local current_window = 0 + vim.api.nvim_set_option_value("winfixbuf", true, {win=current_window}) + + return buffer + end + + local other_buffer = _setup_two_buffers() + local current_window = 0 + local results, _ = pcall(vim.api.nvim_win_set_buf, current_window, other_buffer) + + return results + ]]) + + assert(results == false) + end) + + it("Calling vim.api.nvim_set_current_buf with 'winfixbuf'", function() + local results = exec_lua([[ + local function _setup_two_buffers() + local buffer = vim.api.nvim_create_buf(true, true) + + vim.api.nvim_create_buf(true, true) -- Make another buffer + + local current_window = 0 + vim.api.nvim_set_option_value("winfixbuf", true, {win=current_window}) + + return buffer + end + + local other_buffer = _setup_two_buffers() + local results, _ = pcall(vim.api.nvim_set_current_buf, other_buffer) + + return results + ]]) + + assert(results == false) + end) +end) |