aboutsummaryrefslogtreecommitdiff
path: root/test/functional/vimscript
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2024-01-03 02:09:18 +0100
committerJustin M. Keyes <justinkz@gmail.com>2024-01-03 02:09:29 +0100
commit04f2f864e270e772c6326cefdf24947f0130e492 (patch)
tree46f83f909b888a66c741032ab955afc6eab84292 /test/functional/vimscript
parent59d117ec99b6037cb9fad5bbfb6d0b18f5012927 (diff)
downloadrneovim-04f2f864e270e772c6326cefdf24947f0130e492.tar.gz
rneovim-04f2f864e270e772c6326cefdf24947f0130e492.tar.bz2
rneovim-04f2f864e270e772c6326cefdf24947f0130e492.zip
refactor: format test/*
Diffstat (limited to 'test/functional/vimscript')
-rw-r--r--test/functional/vimscript/api_functions_spec.lua146
-rw-r--r--test/functional/vimscript/buf_functions_spec.lua127
-rw-r--r--test/functional/vimscript/changedtick_spec.lua122
-rw-r--r--test/functional/vimscript/container_functions_spec.lua18
-rw-r--r--test/functional/vimscript/ctx_functions_spec.lua200
-rw-r--r--test/functional/vimscript/environ_spec.lua25
-rw-r--r--test/functional/vimscript/errorlist_spec.lua17
-rw-r--r--test/functional/vimscript/eval_spec.lua103
-rw-r--r--test/functional/vimscript/executable_spec.lua134
-rw-r--r--test/functional/vimscript/execute_spec.lua46
-rw-r--r--test/functional/vimscript/exepath_spec.lua47
-rw-r--r--test/functional/vimscript/fnamemodify_spec.lua6
-rw-r--r--test/functional/vimscript/getline_spec.lua6
-rw-r--r--test/functional/vimscript/glob_spec.lua4
-rw-r--r--test/functional/vimscript/has_spec.lua97
-rw-r--r--test/functional/vimscript/hostname_spec.lua6
-rw-r--r--test/functional/vimscript/input_spec.lua172
-rw-r--r--test/functional/vimscript/json_functions_spec.lua785
-rw-r--r--test/functional/vimscript/lang_spec.lua6
-rw-r--r--test/functional/vimscript/let_spec.lua28
-rw-r--r--test/functional/vimscript/map_functions_spec.lua85
-rw-r--r--test/functional/vimscript/match_functions_spec.lua257
-rw-r--r--test/functional/vimscript/minmax_functions_spec.lua37
-rw-r--r--test/functional/vimscript/modeline_spec.lua2
-rw-r--r--test/functional/vimscript/null_spec.lua150
-rw-r--r--test/functional/vimscript/operators_spec.lua22
-rw-r--r--test/functional/vimscript/printf_spec.lua2
-rw-r--r--test/functional/vimscript/reltime_spec.lua8
-rw-r--r--test/functional/vimscript/screenpos_spec.lua70
-rw-r--r--test/functional/vimscript/server_spec.lua71
-rw-r--r--test/functional/vimscript/setpos_spec.lua39
-rw-r--r--test/functional/vimscript/sort_spec.lua48
-rw-r--r--test/functional/vimscript/special_vars_spec.lua10
-rw-r--r--test/functional/vimscript/state_spec.lua22
-rw-r--r--test/functional/vimscript/string_spec.lua181
-rw-r--r--test/functional/vimscript/system_spec.lua194
-rw-r--r--test/functional/vimscript/timer_spec.lua85
-rw-r--r--test/functional/vimscript/uniq_spec.lua12
-rw-r--r--test/functional/vimscript/vvar_event_spec.lua1
-rw-r--r--test/functional/vimscript/wait_spec.lua9
-rw-r--r--test/functional/vimscript/writefile_spec.lua138
41 files changed, 2052 insertions, 1486 deletions
diff --git a/test/functional/vimscript/api_functions_spec.lua b/test/functional/vimscript/api_functions_spec.lua
index 9a866d0e2d..05876c43d1 100644
--- a/test/functional/vimscript/api_functions_spec.lua
+++ b/test/functional/vimscript/api_functions_spec.lua
@@ -11,24 +11,24 @@ local feed = helpers.feed
describe('eval-API', function()
before_each(clear)
- it("work", function()
+ it('work', function()
command("call nvim_command('let g:test = 1')")
eq(1, eval("nvim_get_var('test')"))
- local buf = eval("nvim_get_current_buf()")
- command("call nvim_buf_set_lines("..buf..", 0, -1, v:true, ['aa', 'bb'])")
+ local buf = eval('nvim_get_current_buf()')
+ command('call nvim_buf_set_lines(' .. buf .. ", 0, -1, v:true, ['aa', 'bb'])")
expect([[
aa
bb]])
- command("call nvim_win_set_cursor(0, [1, 1])")
+ command('call nvim_win_set_cursor(0, [1, 1])')
command("call nvim_input('ax<esc>')")
expect([[
aax
bb]])
end)
- it("throw errors for invalid arguments", function()
+ it('throw errors for invalid arguments', function()
local err = exc_exec('call nvim_get_current_buf("foo")')
eq('Vim(call):E118: Too many arguments for function: nvim_get_current_buf', err)
@@ -36,100 +36,121 @@ describe('eval-API', function()
eq('Vim(call):E119: Not enough arguments for function: nvim_set_option_value', err)
err = exc_exec('call nvim_buf_set_lines(1, 0, -1, [], ["list"])')
- eq('Vim(call):E5555: API call: Wrong type for argument 4 when calling nvim_buf_set_lines, expecting Boolean', err)
+ eq(
+ 'Vim(call):E5555: API call: Wrong type for argument 4 when calling nvim_buf_set_lines, expecting Boolean',
+ err
+ )
err = exc_exec('call nvim_buf_set_lines(0, 0, -1, v:true, "string")')
- eq('Vim(call):E5555: API call: Wrong type for argument 5 when calling nvim_buf_set_lines, expecting ArrayOf(String)', err)
+ eq(
+ 'Vim(call):E5555: API call: Wrong type for argument 5 when calling nvim_buf_set_lines, expecting ArrayOf(String)',
+ err
+ )
err = exc_exec('call nvim_buf_get_number("0")')
- eq('Vim(call):E5555: API call: Wrong type for argument 1 when calling nvim_buf_get_number, expecting Buffer', err)
+ eq(
+ 'Vim(call):E5555: API call: Wrong type for argument 1 when calling nvim_buf_get_number, expecting Buffer',
+ err
+ )
err = exc_exec('call nvim_buf_line_count(17)')
eq('Vim(call):E5555: API call: Invalid buffer id: 17', err)
end)
it('cannot change text or window if textlocked', function()
- command("autocmd TextYankPost <buffer> ++once call nvim_buf_set_lines(0, 0, -1, v:false, [])")
- matches('Vim%(call%):E5555: API call: E565: Not allowed to change text or change window$',
- pcall_err(command, "normal! yy"))
-
- command("autocmd TextYankPost <buffer> ++once call nvim_open_term(0, {})")
- matches('Vim%(call%):E5555: API call: E565: Not allowed to change text or change window$',
- pcall_err(command, "normal! yy"))
+ command('autocmd TextYankPost <buffer> ++once call nvim_buf_set_lines(0, 0, -1, v:false, [])')
+ matches(
+ 'Vim%(call%):E5555: API call: E565: Not allowed to change text or change window$',
+ pcall_err(command, 'normal! yy')
+ )
+
+ command('autocmd TextYankPost <buffer> ++once call nvim_open_term(0, {})')
+ matches(
+ 'Vim%(call%):E5555: API call: E565: Not allowed to change text or change window$',
+ pcall_err(command, 'normal! yy')
+ )
-- Functions checking textlock should also not be usable from <expr> mappings.
- command("inoremap <expr> <f2> nvim_win_close(0, 1)")
- eq('Vim(normal):E5555: API call: E565: Not allowed to change text or change window',
- pcall_err(command, [[execute "normal i\<f2>"]]))
+ command('inoremap <expr> <f2> nvim_win_close(0, 1)')
+ eq(
+ 'Vim(normal):E5555: API call: E565: Not allowed to change text or change window',
+ pcall_err(command, [[execute "normal i\<f2>"]])
+ )
-- Text-changing functions gave a "Failed to save undo information" error when called from an
-- <expr> mapping outside do_cmdline() (msg_list == NULL), so use feed() to test this.
command("inoremap <expr> <f2> nvim_buf_set_text(0, 0, 0, 0, 0, ['hi'])")
meths.set_vvar('errmsg', '')
- feed("i<f2><esc>")
- eq('E5555: API call: E565: Not allowed to change text or change window',
- meths.get_vvar('errmsg'))
+ feed('i<f2><esc>')
+ eq(
+ 'E5555: API call: E565: Not allowed to change text or change window',
+ meths.get_vvar('errmsg')
+ )
-- Some functions checking textlock (usually those that may change the current window or buffer)
-- also ought to not be usable in the cmdwin.
local old_win = meths.get_current_win()
- feed("q:")
- eq('E11: Invalid in command-line window; <CR> executes, CTRL-C quits',
- pcall_err(meths.set_current_win, old_win))
+ feed('q:')
+ eq(
+ 'E11: Invalid in command-line window; <CR> executes, CTRL-C quits',
+ pcall_err(meths.set_current_win, old_win)
+ )
-- But others, like nvim_buf_set_lines(), which just changes text, is OK.
- curbufmeths.set_lines(0, -1, 1, {"wow!"})
- eq({'wow!'}, curbufmeths.get_lines(0, -1, 1))
+ curbufmeths.set_lines(0, -1, 1, { 'wow!' })
+ eq({ 'wow!' }, curbufmeths.get_lines(0, -1, 1))
-- Turning the cmdwin buffer into a terminal buffer would be pretty weird.
- eq('E11: Invalid in command-line window; <CR> executes, CTRL-C quits',
- pcall_err(meths.open_term, 0, {}))
+ eq(
+ 'E11: Invalid in command-line window; <CR> executes, CTRL-C quits',
+ pcall_err(meths.open_term, 0, {})
+ )
-- But turning a different buffer into a terminal from the cmdwin is OK.
local term_buf = meths.create_buf(false, true)
meths.open_term(term_buf, {})
- eq('terminal', meths.get_option_value("buftype", {buf = term_buf}))
+ eq('terminal', meths.get_option_value('buftype', { buf = term_buf }))
end)
- it("use buffer numbers and windows ids as handles", function()
+ it('use buffer numbers and windows ids as handles', function()
local screen = Screen.new(40, 8)
screen:attach()
local bnr = eval("bufnr('')")
- local bhnd = eval("nvim_get_current_buf()")
- local wid = eval("win_getid()")
- local whnd = eval("nvim_get_current_win()")
+ local bhnd = eval('nvim_get_current_buf()')
+ local wid = eval('win_getid()')
+ local whnd = eval('nvim_get_current_win()')
eq(bnr, bhnd)
eq(wid, whnd)
- command("new") -- creates new buffer and new window
+ command('new') -- creates new buffer and new window
local bnr2 = eval("bufnr('')")
- local bhnd2 = eval("nvim_get_current_buf()")
- local wid2 = eval("win_getid()")
- local whnd2 = eval("nvim_get_current_win()")
+ local bhnd2 = eval('nvim_get_current_buf()')
+ local wid2 = eval('win_getid()')
+ local whnd2 = eval('nvim_get_current_win()')
eq(bnr2, bhnd2)
eq(wid2, whnd2)
neq(bnr, bnr2)
neq(wid, wid2)
-- 0 is synonymous to the current buffer
- eq(bnr2, eval("nvim_buf_get_number(0)"))
+ eq(bnr2, eval('nvim_buf_get_number(0)'))
- command("bn") -- show old buffer in new window
- eq(bnr, eval("nvim_get_current_buf()"))
+ command('bn') -- show old buffer in new window
+ eq(bnr, eval('nvim_get_current_buf()'))
eq(bnr, eval("bufnr('')"))
- eq(bnr, eval("nvim_buf_get_number(0)"))
- eq(wid2, eval("win_getid()"))
- eq(whnd2, eval("nvim_get_current_win()"))
+ eq(bnr, eval('nvim_buf_get_number(0)'))
+ eq(wid2, eval('win_getid()'))
+ eq(whnd2, eval('nvim_get_current_win()'))
end)
- it("get_lines and set_lines use NL to represent NUL", function()
- curbufmeths.set_lines(0, -1, true, {"aa\0", "b\0b"})
- eq({'aa\n', 'b\nb'}, eval("nvim_buf_get_lines(0, 0, -1, 1)"))
+ it('get_lines and set_lines use NL to represent NUL', function()
+ curbufmeths.set_lines(0, -1, true, { 'aa\0', 'b\0b' })
+ eq({ 'aa\n', 'b\nb' }, eval('nvim_buf_get_lines(0, 0, -1, 1)'))
command('call nvim_buf_set_lines(0, 1, 2, v:true, ["xx", "\\nyy"])')
- eq({'aa\0', 'xx', '\0yy'}, curbufmeths.get_lines(0, -1, 1))
+ eq({ 'aa\0', 'xx', '\0yy' }, curbufmeths.get_lines(0, -1, 1))
end)
- it("that are FUNC_ATTR_NOEVAL cannot be called", function()
+ it('that are FUNC_ATTR_NOEVAL cannot be called', function()
-- Deprecated vim_ prefix is not exported.
local err = exc_exec('call vim_get_current_buffer("foo")')
eq('Vim(call):E117: Unknown function: vim_get_current_buffer', err)
@@ -149,25 +170,24 @@ describe('eval-API', function()
end)
it('have metadata accessible with api_info()', function()
- local api_keys = eval("sort(keys(api_info()))")
- eq({'error_types', 'functions', 'types',
- 'ui_events', 'ui_options', 'version'}, api_keys)
+ local api_keys = eval('sort(keys(api_info()))')
+ eq({ 'error_types', 'functions', 'types', 'ui_events', 'ui_options', 'version' }, api_keys)
end)
it('are highlighted by vim.vim syntax file', function()
local screen = Screen.new(40, 8)
screen:attach()
screen:set_default_attr_ids({
- [1] = {bold = true, foreground = Screen.colors.Brown},
- [2] = {foreground = Screen.colors.DarkCyan},
- [3] = {foreground = Screen.colors.SlateBlue},
- [4] = {foreground = Screen.colors.Fuchsia},
- [5] = {bold = true, foreground = Screen.colors.Blue},
+ [1] = { bold = true, foreground = Screen.colors.Brown },
+ [2] = { foreground = Screen.colors.DarkCyan },
+ [3] = { foreground = Screen.colors.SlateBlue },
+ [4] = { foreground = Screen.colors.Fuchsia },
+ [5] = { bold = true, foreground = Screen.colors.Blue },
})
- command("set ft=vim")
- command("set rtp^=build/runtime/")
- command("syntax on")
+ command('set ft=vim')
+ command('set rtp^=build/runtime/')
+ command('syntax on')
insert([[
call bufnr('%')
call nvim_input('typing...')
@@ -183,9 +203,11 @@ describe('eval-API', function()
end)
it('cannot be called from sandbox', function()
- eq('Vim(call):E48: Not allowed in sandbox',
- pcall_err(command, "sandbox call nvim_input('ievil')"))
- eq({''}, meths.buf_get_lines(0, 0, -1, true))
+ eq(
+ 'Vim(call):E48: Not allowed in sandbox',
+ pcall_err(command, "sandbox call nvim_input('ievil')")
+ )
+ eq({ '' }, meths.buf_get_lines(0, 0, -1, true))
end)
it('converts blobs to API strings', function()
diff --git a/test/functional/vimscript/buf_functions_spec.lua b/test/functional/vimscript/buf_functions_spec.lua
index 2a5720fbd7..c17edfad62 100644
--- a/test/functional/vimscript/buf_functions_spec.lua
+++ b/test/functional/vimscript/buf_functions_spec.lua
@@ -23,30 +23,47 @@ local dirname = fname .. '.d'
before_each(clear)
-for _, func in ipairs({'bufname(%s)', 'bufnr(%s)', 'bufwinnr(%s)',
- 'getbufline(%s, 1)', 'getbufvar(%s, "changedtick")',
- 'setbufvar(%s, "f", 0)'}) do
+for _, func in ipairs({
+ 'bufname(%s)',
+ 'bufnr(%s)',
+ 'bufwinnr(%s)',
+ 'getbufline(%s, 1)',
+ 'getbufvar(%s, "changedtick")',
+ 'setbufvar(%s, "f", 0)',
+}) do
local funcname = func:match('%w+')
describe(funcname .. '() function', function()
it('errors out when receives v:true/v:false/v:null', function()
-- Not compatible with Vim: in Vim it always results in buffer not found
-- without any error messages.
- for _, var in ipairs({'v:true', 'v:false'}) do
- eq('Vim(call):E5299: Expected a Number or a String, Boolean found',
- exc_exec('call ' .. func:format(var)))
+ for _, var in ipairs({ 'v:true', 'v:false' }) do
+ eq(
+ 'Vim(call):E5299: Expected a Number or a String, Boolean found',
+ exc_exec('call ' .. func:format(var))
+ )
end
- eq('Vim(call):E5300: Expected a Number or a String',
- exc_exec('call ' .. func:format('v:null')))
+ eq(
+ 'Vim(call):E5300: Expected a Number or a String',
+ exc_exec('call ' .. func:format('v:null'))
+ )
end)
it('errors out when receives invalid argument', function()
- eq('Vim(call):E745: Expected a Number or a String, List found',
- exc_exec('call ' .. func:format('[]')))
- eq('Vim(call):E728: Expected a Number or a String, Dictionary found',
- exc_exec('call ' .. func:format('{}')))
- eq('Vim(call):E805: Expected a Number or a String, Float found',
- exc_exec('call ' .. func:format('0.0')))
- eq('Vim(call):E703: Expected a Number or a String, Funcref found',
- exc_exec('call ' .. func:format('function("tr")')))
+ eq(
+ 'Vim(call):E745: Expected a Number or a String, List found',
+ exc_exec('call ' .. func:format('[]'))
+ )
+ eq(
+ 'Vim(call):E728: Expected a Number or a String, Dictionary found',
+ exc_exec('call ' .. func:format('{}'))
+ )
+ eq(
+ 'Vim(call):E805: Expected a Number or a String, Float found',
+ exc_exec('call ' .. func:format('0.0'))
+ )
+ eq(
+ 'Vim(call):E703: Expected a Number or a String, Funcref found',
+ exc_exec('call ' .. func:format('function("tr")'))
+ )
end)
end)
end
@@ -68,12 +85,12 @@ describe('bufname() function', function()
rmdir(dirname)
end)
it('returns expected buffer name', function()
- eq('', funcs.bufname('%')) -- Buffer has no name yet
+ eq('', funcs.bufname('%')) -- Buffer has no name yet
command('file ' .. fname)
local wd = luv.cwd()
local sep = get_pathsep()
local curdirname = funcs.fnamemodify(wd, ':t')
- for _, arg in ipairs({'%', 1, 'X', wd}) do
+ for _, arg in ipairs({ '%', 1, 'X', wd }) do
eq(fname, funcs.bufname(arg))
meths.set_current_dir('..')
eq(curdirname .. sep .. fname, funcs.bufname(arg))
@@ -139,7 +156,7 @@ describe('bufwinnr() function', function()
eq(-1, funcs.bufwinnr(2))
eq(-1, funcs.bufwinnr('non-existent-buffer'))
eq(-1, funcs.bufwinnr('#'))
- command('split ' .. fname2) -- It would be OK if there was one window
+ command('split ' .. fname2) -- It would be OK if there was one window
eq(2, funcs.bufnr('%'))
eq(-1, funcs.bufwinnr('X'))
end)
@@ -181,7 +198,7 @@ describe('getbufline() function', function()
end)
it('returns empty list when range is invalid', function()
eq({}, funcs.getbufline(1, 0))
- curbufmeths.set_lines(0, 1, false, {'foo', 'bar', 'baz'})
+ curbufmeths.set_lines(0, 1, false, { 'foo', 'bar', 'baz' })
eq({}, funcs.getbufline(1, 2, 1))
eq({}, funcs.getbufline(1, -10, -20))
eq({}, funcs.getbufline(1, -2, -1))
@@ -190,14 +207,14 @@ describe('getbufline() function', function()
it('returns expected lines', function()
meths.set_option_value('hidden', true, {})
command('file ' .. fname)
- curbufmeths.set_lines(0, 1, false, {'foo\0', '\0bar', 'baz'})
+ curbufmeths.set_lines(0, 1, false, { 'foo\0', '\0bar', 'baz' })
command('edit ' .. fname2)
- curbufmeths.set_lines(0, 1, false, {'abc\0', '\0def', 'ghi'})
- eq({'foo\n', '\nbar', 'baz'}, funcs.getbufline(1, 1, 9999))
- eq({'abc\n', '\ndef', 'ghi'}, funcs.getbufline(2, 1, 9999))
- eq({'foo\n', '\nbar', 'baz'}, funcs.getbufline(1, 1, '$'))
- eq({'baz'}, funcs.getbufline(1, '$', '$'))
- eq({'baz'}, funcs.getbufline(1, '$', 9999))
+ curbufmeths.set_lines(0, 1, false, { 'abc\0', '\0def', 'ghi' })
+ eq({ 'foo\n', '\nbar', 'baz' }, funcs.getbufline(1, 1, 9999))
+ eq({ 'abc\n', '\ndef', 'ghi' }, funcs.getbufline(2, 1, 9999))
+ eq({ 'foo\n', '\nbar', 'baz' }, funcs.getbufline(1, 1, '$'))
+ eq({ 'baz' }, funcs.getbufline(1, '$', '$'))
+ eq({ 'baz' }, funcs.getbufline(1, '$', 9999))
end)
end)
@@ -230,9 +247,9 @@ describe('getbufvar() function', function()
eq(0, funcs.getbufvar(1, '&g:number'))
command('new')
-- But with window-local options it probably does not what you expect
- command("setl number")
+ command('setl number')
-- (note that current window’s buffer is 2, but getbufvar() receives 1)
- eq({id=2}, curwinmeths.get_buf())
+ eq({ id = 2 }, curwinmeths.get_buf())
eq(1, funcs.getbufvar(1, '&number'))
eq(1, funcs.getbufvar(1, '&l:number'))
-- You can get global value though, if you find this useful.
@@ -240,31 +257,33 @@ describe('getbufvar() function', function()
end)
it('returns expected variable value', function()
eq(2, funcs.getbufvar(1, 'changedtick'))
- curbufmeths.set_lines(0, 1, false, {'abc\0', '\0def', 'ghi'})
+ curbufmeths.set_lines(0, 1, false, { 'abc\0', '\0def', 'ghi' })
eq(3, funcs.getbufvar(1, 'changedtick'))
curbufmeths.set_var('test', true)
eq(true, funcs.getbufvar(1, 'test'))
- eq({test=true, changedtick=3}, funcs.getbufvar(1, ''))
+ eq({ test = true, changedtick = 3 }, funcs.getbufvar(1, ''))
command('new')
eq(3, funcs.getbufvar(1, 'changedtick'))
eq(true, funcs.getbufvar(1, 'test'))
- eq({test=true, changedtick=3}, funcs.getbufvar(1, ''))
+ eq({ test = true, changedtick = 3 }, funcs.getbufvar(1, ''))
end)
end)
describe('setbufvar() function', function()
it('throws the error or ignores the input when buffer was not found', function()
command('file ' .. fname)
- eq(0,
- exc_exec('call setbufvar(2, "&autoindent", 0)'))
- eq('Vim(call):E94: No matching buffer for non-existent-buffer',
- exc_exec('call setbufvar("non-existent-buffer", "&autoindent", 0)'))
- eq(0,
- exc_exec('call setbufvar("#", "&autoindent", 0)'))
+ eq(0, exc_exec('call setbufvar(2, "&autoindent", 0)'))
+ eq(
+ 'Vim(call):E94: No matching buffer for non-existent-buffer',
+ exc_exec('call setbufvar("non-existent-buffer", "&autoindent", 0)')
+ )
+ eq(0, exc_exec('call setbufvar("#", "&autoindent", 0)'))
command('edit ' .. fname2)
eq(2, funcs.bufnr('%'))
- eq('Vim(call):E93: More than one match for X',
- exc_exec('call setbufvar("X", "&autoindent", 0)'))
+ eq(
+ 'Vim(call):E93: More than one match for X',
+ exc_exec('call setbufvar("X", "&autoindent", 0)')
+ )
end)
it('may set options, including window-local and global values', function()
local buf1 = meths.get_current_buf()
@@ -274,21 +293,19 @@ describe('setbufvar() function', function()
eq(2, bufmeths.get_number(curwinmeths.get_buf()))
funcs.setbufvar(1, '&number', true)
local windows = curtabmeths.list_wins()
- 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(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_value('hidden', {}))
funcs.setbufvar(1, '&hidden', 0)
eq(false, meths.get_option_value('hidden', {}))
- eq(false, meths.get_option_value('autoindent', {buf=buf1.id}))
+ eq(false, meths.get_option_value('autoindent', { buf = buf1.id }))
funcs.setbufvar(1, '&autoindent', true)
- eq(true, meths.get_option_value('autoindent', {buf=buf1.id}))
- eq('Vim(call):E355: Unknown option: xxx',
- exc_exec('call setbufvar(1, "&xxx", 0)'))
+ 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)
it('may set variables', function()
local buf1 = meths.get_current_buf()
@@ -297,15 +314,15 @@ describe('setbufvar() function', function()
eq(2, curbufmeths.get_number())
funcs.setbufvar(1, 'number', true)
eq(true, bufmeths.get_var(buf1, 'number'))
- eq('Vim(call):E461: Illegal variable name: b:',
- exc_exec('call setbufvar(1, "", 0)'))
+ eq('Vim(call):E461: Illegal variable name: b:', exc_exec('call setbufvar(1, "", 0)'))
eq(true, bufmeths.get_var(buf1, 'number'))
- eq('Vim:E46: Cannot change read-only variable "b:changedtick"',
- pcall_err(funcs.setbufvar, 1, 'changedtick', true))
+ eq(
+ 'Vim:E46: Cannot change read-only variable "b:changedtick"',
+ pcall_err(funcs.setbufvar, 1, 'changedtick', true)
+ )
eq(2, funcs.getbufvar(1, 'changedtick'))
end)
it('throws error when setting a string option to a boolean value vim-patch:9.0.0090', function()
- eq('Vim:E928: String required',
- pcall_err(funcs.setbufvar, '', '&errorformat', true))
+ eq('Vim:E928: String required', pcall_err(funcs.setbufvar, '', '&errorformat', true))
end)
end)
diff --git a/test/functional/vimscript/changedtick_spec.lua b/test/functional/vimscript/changedtick_spec.lua
index 8533fac9ec..1ff580e570 100644
--- a/test/functional/vimscript/changedtick_spec.lua
+++ b/test/functional/vimscript/changedtick_spec.lua
@@ -29,7 +29,7 @@ end
describe('b:changedtick', function()
-- Ported tests from Vim-8.0.333
- it('increments', function() -- Test_changedtick_increments
+ it('increments', function() -- Test_changedtick_increments
-- New buffer has an empty line, tick starts at 2
eq(2, changedtick())
funcs.setline(1, 'hello')
@@ -56,35 +56,55 @@ describe('b:changedtick', function()
local ct = changedtick()
local ctn = ct + 100500
eq(0, exc_exec('let d = b:'))
- eq('Vim(let):E46: Cannot change read-only variable "b:changedtick"',
- pcall_err(command, 'let b:changedtick = ' .. ctn))
- eq('Vim(let):E46: Cannot change read-only variable "b:["changedtick"]"',
- pcall_err(command, 'let b:["changedtick"] = ' .. ctn))
- eq('Vim(let):E46: Cannot change read-only variable "b:.changedtick"',
- pcall_err(command, 'let b:.changedtick = ' .. ctn))
- eq('Vim(let):E46: Cannot change read-only variable "d.changedtick"',
- pcall_err(command, 'let d.changedtick = ' .. ctn))
- eq('Key is read-only: changedtick',
- pcall_err(curbufmeths.set_var, 'changedtick', ctn))
+ eq(
+ 'Vim(let):E46: Cannot change read-only variable "b:changedtick"',
+ pcall_err(command, 'let b:changedtick = ' .. ctn)
+ )
+ eq(
+ 'Vim(let):E46: Cannot change read-only variable "b:["changedtick"]"',
+ pcall_err(command, 'let b:["changedtick"] = ' .. ctn)
+ )
+ eq(
+ 'Vim(let):E46: Cannot change read-only variable "b:.changedtick"',
+ pcall_err(command, 'let b:.changedtick = ' .. ctn)
+ )
+ eq(
+ 'Vim(let):E46: Cannot change read-only variable "d.changedtick"',
+ pcall_err(command, 'let d.changedtick = ' .. ctn)
+ )
+ eq('Key is read-only: changedtick', pcall_err(curbufmeths.set_var, 'changedtick', ctn))
- eq('Vim(unlet):E795: Cannot delete variable b:changedtick',
- pcall_err(command, 'unlet b:changedtick'))
- eq('Vim(unlet):E46: Cannot change read-only variable "b:.changedtick"',
- pcall_err(command, 'unlet b:.changedtick'))
- eq('Vim(unlet):E46: Cannot change read-only variable "b:["changedtick"]"',
- pcall_err(command, 'unlet b:["changedtick"]'))
- eq('Vim(unlet):E46: Cannot change read-only variable "d.changedtick"',
- pcall_err(command, 'unlet d.changedtick'))
- eq('Key is read-only: changedtick',
- pcall_err(curbufmeths.del_var, 'changedtick'))
+ eq(
+ 'Vim(unlet):E795: Cannot delete variable b:changedtick',
+ pcall_err(command, 'unlet b:changedtick')
+ )
+ eq(
+ 'Vim(unlet):E46: Cannot change read-only variable "b:.changedtick"',
+ pcall_err(command, 'unlet b:.changedtick')
+ )
+ eq(
+ 'Vim(unlet):E46: Cannot change read-only variable "b:["changedtick"]"',
+ pcall_err(command, 'unlet b:["changedtick"]')
+ )
+ eq(
+ 'Vim(unlet):E46: Cannot change read-only variable "d.changedtick"',
+ pcall_err(command, 'unlet d.changedtick')
+ )
+ eq('Key is read-only: changedtick', pcall_err(curbufmeths.del_var, 'changedtick'))
eq(ct, changedtick())
- eq('Vim(let):E46: Cannot change read-only variable "b:["changedtick"]"',
- pcall_err(command, 'let b:["changedtick"] += ' .. ctn))
- eq('Vim(let):E46: Cannot change read-only variable "b:["changedtick"]"',
- pcall_err(command, 'let b:["changedtick"] -= ' .. ctn))
- eq('Vim(let):E46: Cannot change read-only variable "b:["changedtick"]"',
- pcall_err(command, 'let b:["changedtick"] .= ' .. ctn))
+ eq(
+ 'Vim(let):E46: Cannot change read-only variable "b:["changedtick"]"',
+ pcall_err(command, 'let b:["changedtick"] += ' .. ctn)
+ )
+ eq(
+ 'Vim(let):E46: Cannot change read-only variable "b:["changedtick"]"',
+ pcall_err(command, 'let b:["changedtick"] -= ' .. ctn)
+ )
+ eq(
+ 'Vim(let):E46: Cannot change read-only variable "b:["changedtick"]"',
+ pcall_err(command, 'let b:["changedtick"] .= ' .. ctn)
+ )
eq(ct, changedtick())
@@ -99,16 +119,24 @@ describe('b:changedtick', function()
eq(0, exc_exec('let d = b:'))
eq(0, funcs.islocked('b:changedtick'))
eq(0, funcs.islocked('d.changedtick'))
- eq('Vim(unlockvar):E940: Cannot lock or unlock variable b:changedtick',
- pcall_err(command, 'unlockvar b:changedtick'))
- eq('Vim(unlockvar):E46: Cannot change read-only variable "d.changedtick"',
- pcall_err(c