From 743860de40502227b3f0ed64317eb937d24d4a36 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Tue, 4 Apr 2023 21:59:06 +0200 Subject: test: replace lfs with luv and vim.fs test: replace lfs with luv luv already pretty much does everything lfs does, so this duplication of dependencies isn't needed. --- test/functional/vimscript/buf_functions_spec.lua | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'test/functional/vimscript/buf_functions_spec.lua') diff --git a/test/functional/vimscript/buf_functions_spec.lua b/test/functional/vimscript/buf_functions_spec.lua index b521620320..7a54f479e0 100644 --- a/test/functional/vimscript/buf_functions_spec.lua +++ b/test/functional/vimscript/buf_functions_spec.lua @@ -1,6 +1,6 @@ local helpers = require('test.functional.helpers')(after_each) -local lfs = require('lfs') +local luv = require('luv') local eq = helpers.eq local clear = helpers.clear @@ -16,6 +16,7 @@ local curtabmeths = helpers.curtabmeths local get_pathsep = helpers.get_pathsep local rmdir = helpers.rmdir local pcall_err = helpers.pcall_err +local mkdir = helpers.mkdir local fname = 'Xtest-functional-eval-buf_functions' local fname2 = fname .. '.2' @@ -62,7 +63,7 @@ describe('bufname() function', function() eq('', funcs.bufname('X')) end) before_each(function() - lfs.mkdir(dirname) + mkdir(dirname) end) after_each(function() rmdir(dirname) @@ -70,7 +71,7 @@ describe('bufname() function', function() it('returns expected buffer name', function() eq('', funcs.bufname('%')) -- Buffer has no name yet command('file ' .. fname) - local wd = lfs.currentdir() + local wd = luv.cwd() local sep = get_pathsep() local curdirname = funcs.fnamemodify(wd, ':t') for _, arg in ipairs({'%', 1, 'X', wd}) do @@ -103,7 +104,7 @@ describe('bufnr() function', function() it('returns expected buffer number', function() eq(1, funcs.bufnr('%')) command('file ' .. fname) - local wd = lfs.currentdir() + local wd = luv.cwd() local curdirname = funcs.fnamemodify(wd, ':t') eq(1, funcs.bufnr(fname)) eq(1, funcs.bufnr(wd)) @@ -144,7 +145,7 @@ describe('bufwinnr() function', function() eq(-1, funcs.bufwinnr('X')) end) before_each(function() - lfs.mkdir(dirname) + mkdir(dirname) end) after_each(function() rmdir(dirname) -- cgit From 1fe1bb084d0099fc4f9bfdc11189485d0f74b75a Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Mon, 19 Dec 2022 16:37:45 +0000 Subject: refactor(options): deprecate nvim[_buf|_win]_[gs]et_option Co-authored-by: zeertzjq Co-authored-by: famiu --- test/functional/vimscript/buf_functions_spec.lua | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'test/functional/vimscript/buf_functions_spec.lua') diff --git a/test/functional/vimscript/buf_functions_spec.lua b/test/functional/vimscript/buf_functions_spec.lua index 7a54f479e0..2d6d4b8e04 100644 --- a/test/functional/vimscript/buf_functions_spec.lua +++ b/test/functional/vimscript/buf_functions_spec.lua @@ -9,7 +9,6 @@ local meths = helpers.meths local command = helpers.command local exc_exec = helpers.exc_exec local bufmeths = helpers.bufmeths -local winmeths = helpers.winmeths local curbufmeths = helpers.curbufmeths local curwinmeths = helpers.curwinmeths local curtabmeths = helpers.curtabmeths @@ -189,7 +188,7 @@ describe('getbufline() function', function() eq({}, funcs.getbufline(1, -1, 9999)) end) it('returns expected lines', function() - meths.set_option('hidden', true) + meths.set_option_value('hidden', true, {}) command('file ' .. fname) curbufmeths.set_lines(0, 1, false, {'foo\0', '\0bar', 'baz'}) command('edit ' .. fname2) @@ -269,24 +268,25 @@ describe('setbufvar() function', function() end) it('may set options, including window-local and global values', function() local buf1 = meths.get_current_buf() - eq(false, curwinmeths.get_option('number')) + eq(false, meths.get_option_value('number', {win=0})) command('split') command('new') eq(2, bufmeths.get_number(curwinmeths.get_buf())) funcs.setbufvar(1, '&number', true) local windows = curtabmeths.list_wins() - eq(false, winmeths.get_option(windows[1], 'number')) - eq(true, winmeths.get_option(windows[2], 'number')) - eq(false, winmeths.get_option(windows[3], 'number')) - eq(false, winmeths.get_option(meths.get_current_win(), 'number')) + eq(false, meths.get_option_value('number', {win=windows[1].id})) + eq(true, meths.get_option_value('number', {win=windows[2].id})) + eq(false, meths.get_option_value('number', {win=windows[3].id})) + eq(false, meths.get_option_value('number', {win=meths.get_current_win().id})) - eq(true, meths.get_option('hidden')) + + eq(true, meths.get_option_value('hidden', {})) funcs.setbufvar(1, '&hidden', 0) - eq(false, meths.get_option('hidden')) + eq(false, meths.get_option_value('hidden', {})) - eq(false, bufmeths.get_option(buf1, 'autoindent')) + eq(false, meths.get_option_value('autoindent', {buf=buf1.id})) funcs.setbufvar(1, '&autoindent', true) - eq(true, bufmeths.get_option(buf1, 'autoindent')) + eq(true, meths.get_option_value('autoindent', {buf=buf1.id})) eq('Vim(call):E355: Unknown option: xxx', exc_exec('call setbufvar(1, "&xxx", 0)')) end) -- cgit From 576dddb46168e81aa0f78c28816082c662dedea1 Mon Sep 17 00:00:00 2001 From: Famiu Haque Date: Mon, 22 May 2023 12:47:10 +0600 Subject: test: don't unnecessarily specify win/buf for `nvim_(get|set)_option_value` `nvim_(get|set)_option_value` pick the current buffer / window by default for buffer-local/window-local (but not global-local) options. So specifying `buf = 0` or `win = 0` in opts is unnecessary for those options. This PR removes those to reduce code clutter. --- test/functional/vimscript/buf_functions_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/functional/vimscript/buf_functions_spec.lua') diff --git a/test/functional/vimscript/buf_functions_spec.lua b/test/functional/vimscript/buf_functions_spec.lua index 2d6d4b8e04..2a5720fbd7 100644 --- a/test/functional/vimscript/buf_functions_spec.lua +++ b/test/functional/vimscript/buf_functions_spec.lua @@ -268,7 +268,7 @@ describe('setbufvar() function', function() end) it('may set options, including window-local and global values', function() local buf1 = meths.get_current_buf() - eq(false, meths.get_option_value('number', {win=0})) + eq(false, meths.get_option_value('number', {})) command('split') command('new') eq(2, bufmeths.get_number(curwinmeths.get_buf())) -- cgit