aboutsummaryrefslogtreecommitdiff
path: root/test/functional/vimscript
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2024-01-12 17:59:57 +0000
committerLewis Russell <lewis6991@gmail.com>2024-01-12 18:59:14 +0000
commit795f896a5772d5e0795f86642bdf90c82efac45c (patch)
tree308f04fbee18d2ec3f00c12a8bec96b84d8907f0 /test/functional/vimscript
parent4f81f506f96f8b5bfcf00e952ceb492d3ce9dc6e (diff)
downloadrneovim-795f896a5772d5e0795f86642bdf90c82efac45c.tar.gz
rneovim-795f896a5772d5e0795f86642bdf90c82efac45c.tar.bz2
rneovim-795f896a5772d5e0795f86642bdf90c82efac45c.zip
test: rename (meths, funcs) -> (api, fn)
Diffstat (limited to 'test/functional/vimscript')
-rw-r--r--test/functional/vimscript/api_functions_spec.lua28
-rw-r--r--test/functional/vimscript/buf_functions_spec.lua266
-rw-r--r--test/functional/vimscript/changedtick_spec.lua44
-rw-r--r--test/functional/vimscript/container_functions_spec.lua14
-rw-r--r--test/functional/vimscript/ctx_functions_spec.lua40
-rw-r--r--test/functional/vimscript/environ_spec.lua8
-rw-r--r--test/functional/vimscript/errorlist_spec.lua6
-rw-r--r--test/functional/vimscript/eval_spec.lua16
-rw-r--r--test/functional/vimscript/execute_spec.lua24
-rw-r--r--test/functional/vimscript/fnamemodify_spec.lua4
-rw-r--r--test/functional/vimscript/has_spec.lua108
-rw-r--r--test/functional/vimscript/input_spec.lua56
-rw-r--r--test/functional/vimscript/json_functions_spec.lua184
-rw-r--r--test/functional/vimscript/let_spec.lua18
-rw-r--r--test/functional/vimscript/map_functions_spec.lua76
-rw-r--r--test/functional/vimscript/match_functions_spec.lua70
-rw-r--r--test/functional/vimscript/minmax_functions_spec.lua8
-rw-r--r--test/functional/vimscript/msgpack_functions_spec.lua8
-rw-r--r--test/functional/vimscript/null_spec.lua22
-rw-r--r--test/functional/vimscript/printf_spec.lua48
-rw-r--r--test/functional/vimscript/reltime_spec.lua4
-rw-r--r--test/functional/vimscript/screenchar_spec.lua48
-rw-r--r--test/functional/vimscript/screenpos_spec.lua56
-rw-r--r--test/functional/vimscript/server_spec.lua65
-rw-r--r--test/functional/vimscript/setpos_spec.lua4
-rw-r--r--test/functional/vimscript/sort_spec.lua8
-rw-r--r--test/functional/vimscript/special_vars_spec.lua52
-rw-r--r--test/functional/vimscript/state_spec.lua8
-rw-r--r--test/functional/vimscript/string_spec.lua80
-rw-r--r--test/functional/vimscript/system_spec.lua16
-rw-r--r--test/functional/vimscript/timer_spec.lua8
-rw-r--r--test/functional/vimscript/wait_spec.lua12
-rw-r--r--test/functional/vimscript/writefile_spec.lua38
33 files changed, 722 insertions, 725 deletions
diff --git a/test/functional/vimscript/api_functions_spec.lua b/test/functional/vimscript/api_functions_spec.lua
index 29841d052a..200ad40c3a 100644
--- a/test/functional/vimscript/api_functions_spec.lua
+++ b/test/functional/vimscript/api_functions_spec.lua
@@ -5,7 +5,7 @@ local clear = helpers.clear
local exc_exec, expect, eval = helpers.exc_exec, helpers.expect, helpers.eval
local insert, pcall_err = helpers.insert, helpers.pcall_err
local matches = helpers.matches
-local meths = helpers.meths
+local api = helpers.api
local feed = helpers.feed
describe('eval-API', function()
@@ -80,36 +80,36 @@ describe('eval-API', function()
-- 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.nvim_set_vvar('errmsg', '')
+ api.nvim_set_vvar('errmsg', '')
feed('i<f2><esc>')
eq(
'E5555: API call: E565: Not allowed to change text or change window',
- meths.nvim_get_vvar('errmsg')
+ api.nvim_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.nvim_get_current_win()
+ local old_win = api.nvim_get_current_win()
feed('q:')
eq(
'E11: Invalid in command-line window; <CR> executes, CTRL-C quits',
- pcall_err(meths.nvim_set_current_win, old_win)
+ pcall_err(api.nvim_set_current_win, old_win)
)
-- But others, like nvim_buf_set_lines(), which just changes text, is OK.
- meths.nvim_buf_set_lines(0, 0, -1, 1, { 'wow!' })
- eq({ 'wow!' }, meths.nvim_buf_get_lines(0, 0, -1, 1))
+ api.nvim_buf_set_lines(0, 0, -1, 1, { 'wow!' })
+ eq({ 'wow!' }, api.nvim_buf_get_lines(0, 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.nvim_open_term, 0, {})
+ pcall_err(api.nvim_open_term, 0, {})
)
-- But turning a different buffer into a terminal from the cmdwin is OK.
- local term_buf = meths.nvim_create_buf(false, true)
- meths.nvim_open_term(term_buf, {})
- eq('terminal', meths.nvim_get_option_value('buftype', { buf = term_buf }))
+ local term_buf = api.nvim_create_buf(false, true)
+ api.nvim_open_term(term_buf, {})
+ eq('terminal', api.nvim_get_option_value('buftype', { buf = term_buf }))
end)
it('use buffer numbers and windows ids as handles', function()
@@ -143,11 +143,11 @@ describe('eval-API', function()
end)
it('get_lines and set_lines use NL to represent NUL', function()
- meths.nvim_buf_set_lines(0, 0, -1, true, { 'aa\0', 'b\0b' })
+ api.nvim_buf_set_lines(0, 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' }, meths.nvim_buf_get_lines(0, 0, -1, 1))
+ eq({ 'aa\0', 'xx', '\0yy' }, api.nvim_buf_get_lines(0, 0, -1, 1))
end)
it('that are FUNC_ATTR_NOEVAL cannot be called', function()
@@ -207,7 +207,7 @@ describe('eval-API', function()
'Vim(call):E48: Not allowed in sandbox',
pcall_err(command, "sandbox call nvim_input('ievil')")
)
- eq({ '' }, meths.nvim_buf_get_lines(0, 0, -1, true))
+ eq({ '' }, api.nvim_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 34206b15ae..5557ce6788 100644
--- a/test/functional/vimscript/buf_functions_spec.lua
+++ b/test/functional/vimscript/buf_functions_spec.lua
@@ -2,8 +2,8 @@ local helpers = require('test.functional.helpers')(after_each)
local eq = helpers.eq
local clear = helpers.clear
-local funcs = helpers.funcs
-local meths = helpers.meths
+local fn = helpers.fn
+local api = helpers.api
local command = helpers.command
local exc_exec = helpers.exc_exec
local get_pathsep = helpers.get_pathsep
@@ -65,12 +65,12 @@ end
describe('bufname() function', function()
it('returns empty string when buffer was not found', function()
command('file ' .. fname)
- eq('', funcs.bufname(2))
- eq('', funcs.bufname('non-existent-buffer'))
- eq('', funcs.bufname('#'))
+ eq('', fn.bufname(2))
+ eq('', fn.bufname('non-existent-buffer'))
+ eq('', fn.bufname('#'))
command('edit ' .. fname2)
- eq(2, funcs.bufnr('%'))
- eq('', funcs.bufname('X'))
+ eq(2, fn.bufnr('%'))
+ eq('', fn.bufname('X'))
end)
before_each(function()
mkdir(dirname)
@@ -79,80 +79,80 @@ describe('bufname() function', function()
rmdir(dirname)
end)
it('returns expected buffer name', function()
- eq('', funcs.bufname('%')) -- Buffer has no name yet
+ eq('', fn.bufname('%')) -- Buffer has no name yet
command('file ' .. fname)
local wd = vim.uv.cwd()
local sep = get_pathsep()
- local curdirname = funcs.fnamemodify(wd, ':t')
+ local curdirname = fn.fnamemodify(wd, ':t')
for _, arg in ipairs({ '%', 1, 'X', wd }) do
- eq(fname, funcs.bufname(arg))
- meths.nvim_set_current_dir('..')
- eq(curdirname .. sep .. fname, funcs.bufname(arg))
- meths.nvim_set_current_dir(curdirname)
- meths.nvim_set_current_dir(dirname)
- eq(wd .. sep .. fname, funcs.bufname(arg))
- meths.nvim_set_current_dir('..')
- eq(fname, funcs.bufname(arg))
+ eq(fname, fn.bufname(arg))
+ api.nvim_set_current_dir('..')
+ eq(curdirname .. sep .. fname, fn.bufname(arg))
+ api.nvim_set_current_dir(curdirname)
+ api.nvim_set_current_dir(dirname)
+ eq(wd .. sep .. fname, fn.bufname(arg))
+ api.nvim_set_current_dir('..')
+ eq(fname, fn.bufname(arg))
command('enew')
end
- eq('', funcs.bufname('%'))
- eq('', funcs.bufname('$'))
- eq(2, funcs.bufnr('%'))
+ eq('', fn.bufname('%'))
+ eq('', fn.bufname('$'))
+ eq(2, fn.bufnr('%'))
end)
end)
describe('bufnr() function', function()
it('returns -1 when buffer was not found', function()
command('file ' .. fname)
- eq(-1, funcs.bufnr(2))
- eq(-1, funcs.bufnr('non-existent-buffer'))
- eq(-1, funcs.bufnr('#'))
+ eq(-1, fn.bufnr(2))
+ eq(-1, fn.bufnr('non-existent-buffer'))
+ eq(-1, fn.bufnr('#'))
command('edit ' .. fname2)
- eq(2, funcs.bufnr('%'))
- eq(-1, funcs.bufnr('X'))
+ eq(2, fn.bufnr('%'))
+ eq(-1, fn.bufnr('X'))
end)
it('returns expected buffer number', function()
- eq(1, funcs.bufnr('%'))
+ eq(1, fn.bufnr('%'))
command('file ' .. fname)
local wd = vim.uv.cwd()
- local curdirname = funcs.fnamemodify(wd, ':t')
- eq(1, funcs.bufnr(fname))
- eq(1, funcs.bufnr(wd))
- eq(1, funcs.bufnr(curdirname))
- eq(1, funcs.bufnr('X'))
+ local curdirname = fn.fnamemodify(wd, ':t')
+ eq(1, fn.bufnr(fname))
+ eq(1, fn.bufnr(wd))
+ eq(1, fn.bufnr(curdirname))
+ eq(1, fn.bufnr('X'))
end)
it('returns number of last buffer with "$"', function()
- eq(1, funcs.bufnr('$'))
+ eq(1, fn.bufnr('$'))
command('new')
- eq(2, funcs.bufnr('$'))
+ eq(2, fn.bufnr('$'))
command('new')
- eq(3, funcs.bufnr('$'))
+ eq(3, fn.bufnr('$'))
command('only')
- eq(3, funcs.bufnr('$'))
- eq(3, funcs.bufnr('%'))
+ eq(3, fn.bufnr('$'))
+ eq(3, fn.bufnr('%'))
command('buffer 1')
- eq(3, funcs.bufnr('$'))
- eq(1, funcs.bufnr('%'))
+ eq(3, fn.bufnr('$'))
+ eq(1, fn.bufnr('%'))
command('bwipeout 2')
- eq(3, funcs.bufnr('$'))
- eq(1, funcs.bufnr('%'))
+ eq(3, fn.bufnr('$'))
+ eq(1, fn.bufnr('%'))
command('bwipeout 3')
- eq(1, funcs.bufnr('$'))
- eq(1, funcs.bufnr('%'))
+ eq(1, fn.bufnr('$'))
+ eq(1, fn.bufnr('%'))
command('new')
- eq(4, funcs.bufnr('$'))
+ eq(4, fn.bufnr('$'))
end)
end)
describe('bufwinnr() function', function()
it('returns -1 when buffer was not found', function()
command('file ' .. fname)
- eq(-1, funcs.bufwinnr(2))
- eq(-1, funcs.bufwinnr('non-existent-buffer'))
- eq(-1, funcs.bufwinnr('#'))
+ eq(-1, fn.bufwinnr(2))
+ eq(-1, fn.bufwinnr('non-existent-buffer'))
+ eq(-1, fn.bufwinnr('#'))
command('split ' .. fname2) -- It would be OK if there was one window
- eq(2, funcs.bufnr('%'))
- eq(-1, funcs.bufwinnr('X'))
+ eq(2, fn.bufnr('%'))
+ eq(-1, fn.bufwinnr('X'))
end)
before_each(function()
mkdir(dirname)
@@ -161,105 +161,105 @@ describe('bufwinnr() function', function()
rmdir(dirname)
end)
it('returns expected window number', function()
- eq(1, funcs.bufwinnr('%'))
+ eq(1, fn.bufwinnr('%'))
command('file ' .. fname)
command('vsplit')
command('split ' .. fname2)
- eq(2, funcs.bufwinnr(fname))
- eq(1, funcs.bufwinnr(fname2))
- eq(-1, funcs.bufwinnr(fname:sub(1, #fname - 1)))
- meths.nvim_set_current_dir(dirname)
- eq(2, funcs.bufwinnr(fname))
- eq(1, funcs.bufwinnr(fname2))
- eq(-1, funcs.bufwinnr(fname:sub(1, #fname - 1)))
- eq(1, funcs.bufwinnr('%'))
- eq(2, funcs.bufwinnr(1))
- eq(1, funcs.bufwinnr(2))
- eq(-1, funcs.bufwinnr(3))
- eq(1, funcs.bufwinnr('$'))
+ eq(2, fn.bufwinnr(fname))
+ eq(1, fn.bufwinnr(fname2))
+ eq(-1, fn.bufwinnr(fname:sub(1, #fname - 1)))
+ api.nvim_set_current_dir(dirname)
+ eq(2, fn.bufwinnr(fname))
+ eq(1, fn.bufwinnr(fname2))
+ eq(-1, fn.bufwinnr(fname:sub(1, #fname - 1)))
+ eq(1, fn.bufwinnr('%'))
+ eq(2, fn.bufwinnr(1))
+ eq(1, fn.bufwinnr(2))
+ eq(-1, fn.bufwinnr(3))
+ eq(1, fn.bufwinnr('$'))
end)
end)
describe('getbufline() function', function()
it('returns empty list when buffer was not found', function()
command('file ' .. fname)
- eq({}, funcs.getbufline(2, 1))
- eq({}, funcs.getbufline('non-existent-buffer', 1))
- eq({}, funcs.getbufline('#', 1))
+ eq({}, fn.getbufline(2, 1))
+ eq({}, fn.getbufline('non-existent-buffer', 1))
+ eq({}, fn.getbufline('#', 1))
command('edit ' .. fname2)
- eq(2, funcs.bufnr('%'))
- eq({}, funcs.getbufline('X', 1))
+ eq(2, fn.bufnr('%'))
+ eq({}, fn.getbufline('X', 1))
end)
it('returns empty list when range is invalid', function()
- eq({}, funcs.getbufline(1, 0))
- meths.nvim_buf_set_lines(0, 0, 1, false, { 'foo', 'bar', 'baz' })
- eq({}, funcs.getbufline(1, 2, 1))
- eq({}, funcs.getbufline(1, -10, -20))
- eq({}, funcs.getbufline(1, -2, -1))
- eq({}, funcs.getbufline(1, -1, 9999))
+ eq({}, fn.getbufline(1, 0))
+ api.nvim_buf_set_lines(0, 0, 1, false, { 'foo', 'bar', 'baz' })
+ eq({}, fn.getbufline(1, 2, 1))
+ eq({}, fn.getbufline(1, -10, -20))
+ eq({}, fn.getbufline(1, -2, -1))
+ eq({}, fn.getbufline(1, -1, 9999))
end)
it('returns expected lines', function()
- meths.nvim_set_option_value('hidden', true, {})
+ api.nvim_set_option_value('hidden', true, {})
command('file ' .. fname)
- meths.nvim_buf_set_lines(0, 0, 1, false, { 'foo\0', '\0bar', 'baz' })
+ api.nvim_buf_set_lines(0, 0, 1, false, { 'foo\0', '\0bar', 'baz' })
command('edit ' .. fname2)
- meths.nvim_buf_set_lines(0, 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))
+ api.nvim_buf_set_lines(0, 0, 1, false, { 'abc\0', '\0def', 'ghi' })
+ eq({ 'foo\n', '\nbar', 'baz' }, fn.getbufline(1, 1, 9999))
+ eq({ 'abc\n', '\ndef', 'ghi' }, fn.getbufline(2, 1, 9999))
+ eq({ 'foo\n', '\nbar', 'baz' }, fn.getbufline(1, 1, '$'))
+ eq({ 'baz' }, fn.getbufline(1, '$', '$'))
+ eq({ 'baz' }, fn.getbufline(1, '$', 9999))
end)
end)
describe('getbufvar() function', function()
it('returns empty list when buffer was not found', function()
command('file ' .. fname)
- eq('', funcs.getbufvar(2, '&autoindent'))
- eq('', funcs.getbufvar('non-existent-buffer', '&autoindent'))
- eq('', funcs.getbufvar('#', '&autoindent'))
+ eq('', fn.getbufvar(2, '&autoindent'))
+ eq('', fn.getbufvar('non-existent-buffer', '&autoindent'))
+ eq('', fn.getbufvar('#', '&autoindent'))
command('edit ' .. fname2)
- eq(2, funcs.bufnr('%'))
- eq('', funcs.getbufvar('X', '&autoindent'))
+ eq(2, fn.bufnr('%'))
+ eq('', fn.getbufvar('X', '&autoindent'))
end)
it('returns empty list when variable/option/etc was not found', function()
command('file ' .. fname)
- eq('', funcs.getbufvar(1, '&autondent'))
- eq('', funcs.getbufvar(1, 'changedtic'))
+ eq('', fn.getbufvar(1, '&autondent'))
+ eq('', fn.getbufvar(1, 'changedtic'))
end)
it('returns expected option value', function()
- eq(0, funcs.getbufvar(1, '&autoindent'))
- eq(0, funcs.getbufvar(1, '&l:autoindent'))
- eq(0, funcs.getbufvar(1, '&g:autoindent'))
+ eq(0, fn.getbufvar(1, '&autoindent'))
+ eq(0, fn.getbufvar(1, '&l:autoindent'))
+ eq(0, fn.getbufvar(1, '&g:autoindent'))
-- Also works with global-only options
- eq(1, funcs.getbufvar(1, '&hidden'))
- eq(1, funcs.getbufvar(1, '&l:hidden'))
- eq(1, funcs.getbufvar(1, '&g:hidden'))
+ eq(1, fn.getbufvar(1, '&hidden'))
+ eq(1, fn.getbufvar(1, '&l:hidden'))
+ eq(1, fn.getbufvar(1, '&g:hidden'))
-- Also works with window-local options
- eq(0, funcs.getbufvar(1, '&number'))
- eq(0, funcs.getbufvar(1, '&l:number'))
- eq(0, funcs.getbufvar(1, '&g:number'))
+ eq(0, fn.getbufvar(1, '&number'))
+ eq(0, fn.getbufvar(1, '&l:number'))
+ eq(0, fn.getbufvar(1, '&g:number'))
command('new')
-- But with window-local options it probably does not what you expect
command('setl number')
-- (note that current window’s buffer is 2, but getbufvar() receives 1)
- eq({ id = 2 }, meths.nvim_win_get_buf(0))
- eq(1, funcs.getbufvar(1, '&number'))
- eq(1, funcs.getbufvar(1, '&l:number'))
+ eq({ id = 2 }, api.nvim_win_get_buf(0))
+ eq(1, fn.getbufvar(1, '&number'))
+ eq(1, fn.getbufvar(1, '&l:number'))
-- You can get global value though, if you find this useful.
- eq(0, funcs.getbufvar(1, '&g:number'))
+ eq(0, fn.getbufvar(1, '&g:number'))
end)
it('returns expected variable value', function()
- eq(2, funcs.getbufvar(1, 'changedtick'))
- meths.nvim_buf_set_lines(0, 0, 1, false, { 'abc\0', '\0def', 'ghi' })
- eq(3, funcs.getbufvar(1, 'changedtick'))
- meths.nvim_buf_set_var(0, 'test', true)
- eq(true, funcs.getbufvar(1, 'test'))
- eq({ test = true, changedtick = 3 }, funcs.getbufvar(1, ''))
+ eq(2, fn.getbufvar(1, 'changedtick'))
+ api.nvim_buf_set_lines(0, 0, 1, false, { 'abc\0', '\0def', 'ghi' })
+ eq(3, fn.getbufvar(1, 'changedtick'))
+ api.nvim_buf_set_var(0, 'test', true)
+ eq(true, fn.getbufvar(1, 'test'))
+ eq({ test = true, changedtick = 3 }, fn.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(3, fn.getbufvar(1, 'changedtick'))
+ eq(true, fn.getbufvar(1, 'test'))
+ eq({ test = true, changedtick = 3 }, fn.getbufvar(1, ''))
end)
end)
@@ -273,50 +273,50 @@ describe('setbufvar() function', function()
)
eq(0, exc_exec('call setbufvar("#", "&autoindent", 0)'))
command('edit ' .. fname2)
- eq(2, funcs.bufnr('%'))
+ eq(2, fn.bufnr('%'))
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.nvim_get_current_buf()
- eq(false, meths.nvim_get_option_value('number', {}))
+ local buf1 = api.nvim_get_current_buf()
+ eq(false, api.nvim_get_option_value('number', {}))
command('split')
command('new')
- eq(2, meths.nvim_buf_get_number(meths.nvim_win_get_buf(0)))
- funcs.setbufvar(1, '&number', true)
- local windows = meths.nvim_tabpage_list_wins(0)
- eq(false, meths.nvim_get_option_value('number', { win = windows[1].id }))
- eq(true, meths.nvim_get_option_value('number', { win = windows[2].id }))
- eq(false, meths.nvim_get_option_value('number', { win = windows[3].id }))
- eq(false, meths.nvim_get_option_value('number', { win = meths.nvim_get_current_win().id }))
+ eq(2, api.nvim_buf_get_number(api.nvim_win_get_buf(0)))
+ fn.setbufvar(1, '&number', true)
+ local windows = api.nvim_tabpage_list_wins(0)
+ eq(false, api.nvim_get_option_value('number', { win = windows[1].id }))
+ eq(true, api.nvim_get_option_value('number', { win = windows[2].id }))
+ eq(false, api.nvim_get_option_value('number', { win = windows[3].id }))
+ eq(false, api.nvim_get_option_value('number', { win = api.nvim_get_current_win().id }))
- eq(true, meths.nvim_get_option_value('hidden', {}))
- funcs.setbufvar(1, '&hidden', 0)
- eq(false, meths.nvim_get_option_value('hidden', {}))
+ eq(true, api.nvim_get_option_value('hidden', {}))
+ fn.setbufvar(1, '&hidden', 0)
+ eq(false, api.nvim_get_option_value('hidden', {}))
- eq(false, meths.nvim_get_option_value('autoindent', { buf = buf1.id }))
- funcs.setbufvar(1, '&autoindent', true)
- eq(true, meths.nvim_get_option_value('autoindent', { buf = buf1.id }))
+ eq(false, api.nvim_get_option_value('autoindent', { buf = buf1.id }))
+ fn.setbufvar(1, '&autoindent', true)
+ eq(true, api.nvim_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.nvim_get_current_buf()
+ local buf1 = api.nvim_get_current_buf()
command('split')
command('new')
- eq(2, meths.nvim_buf_get_number(0))
- funcs.setbufvar(1, 'number', true)
- eq(true, meths.nvim_buf_get_var(buf1, 'number'))
+ eq(2, api.nvim_buf_get_number(0))
+ fn.setbufvar(1, 'number', true)
+ eq(true, api.nvim_buf_get_var(buf1, 'number'))
eq('Vim(call):E461: Illegal variable name: b:', exc_exec('call setbufvar(1, "", 0)'))
- eq(true, meths.nvim_buf_get_var(buf1, 'number'))
+ eq(true, api.nvim_buf_get_var(buf1, 'number'))
eq(
'Vim:E46: Cannot change read-only variable "b:changedtick"',
- pcall_err(funcs.setbufvar, 1, 'changedtick', true)
+ pcall_err(fn.setbufvar, 1, 'changedtick', true)
)
- eq(2, funcs.getbufvar(1, 'changedtick'))
+ eq(2, fn.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(fn.setbufvar, '', '&errorformat', true))
end)
end)
diff --git a/test/functional/vimscript/changedtick_spec.lua b/test/functional/vimscript/changedtick_spec.lua
index 203c9a22e5..85928921c5 100644
--- a/test/functional/vimscript/changedtick_spec.lua
+++ b/test/functional/vimscript/changedtick_spec.lua
@@ -4,8 +4,8 @@ local eq = helpers.eq
local eval = helpers.eval
local feed = helpers.feed
local clear = helpers.clear
-local funcs = helpers.funcs
-local meths = helpers.meths
+local fn = helpers.fn
+local api = helpers.api
local command = helpers.command
local exc_exec = helpers.exc_exec
local pcall_err = helpers.pcall_err
@@ -14,14 +14,14 @@ local exec_capture = helpers.exec_capture
before_each(clear)
local function changedtick()
- local ct = meths.nvim_buf_get_changedtick(0)
- eq(ct, meths.nvim_buf_get_var(0, 'changedtick'))
- eq(ct, meths.nvim_buf_get_var(0, 'changedtick'))
+ local ct = api.nvim_buf_get_changedtick(0)
+ eq(ct, api.nvim_buf_get_var(0, 'changedtick'))
+ eq(ct, api.nvim_buf_get_var(0, 'changedtick'))
eq(ct, eval('b:changedtick'))
eq(ct, eval('b:["changedtick"]'))
eq(ct, eval('b:.changedtick'))
- eq(ct, funcs.getbufvar('%', 'changedtick'))
- eq(ct, funcs.getbufvar('%', '').changedtick)
+ eq(ct, fn.getbufvar('%', 'changedtick'))
+ eq(ct, fn.getbufvar('%', '').changedtick)
eq(ct, eval('b:').changedtick)
return ct
end
@@ -31,7 +31,7 @@ describe('b:changedtick', function()
it('increments', function() -- Test_changedtick_increments
-- New buffer has an empty line, tick starts at 2
eq(2, changedtick())
- funcs.setline(1, 'hello')
+ fn.setline(1, 'hello')
eq(3, changedtick())
eq(0, exc_exec('undo'))
-- Somehow undo counts as two changes
@@ -40,16 +40,16 @@ describe('b:changedtick', function()
it('is present in b: dictionary', function()
eq(2, changedtick())
command('let d = b:')
- eq(2, meths.nvim_get_var('d').changedtick)
+ eq(2, api.nvim_get_var('d').changedtick)
end)
it('increments at bdel', function()
command('new')
eq(2, changedtick())
- local bnr = meths.nvim_buf_get_number(0)
+ local bnr = api.nvim_buf_get_number(0)
eq(2, bnr)
command('bdel')
- eq(3, funcs.getbufvar(bnr, 'changedtick'))
- eq(1, meths.nvim_buf_get_number(0))
+ eq(3, fn.getbufvar(bnr, 'changedtick'))
+ eq(1, api.nvim_buf_get_number(0))
end)
it('fails to be changed by user', function()
local ct = changedtick()
@@ -71,7 +71,7 @@ describe('b:changedtick', function()
'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(meths.nvim_buf_set_var, 0, 'changedtick', ctn))
+ eq('Key is read-only: changedtick', pcall_err(api.nvim_buf_set_var, 0, 'changedtick', ctn))
eq(
'Vim(unlet):E795: Cannot delete variable b:changedtick',
@@ -89,7 +89,7 @@ describe('b:changedtick', function()
'Vim(unlet):E46: Cannot change read-only variable "d.changedtick"',
pcall_err(command, 'unlet d.changedtick')
)
- eq('Key is read-only: changedtick', pcall_err(meths.nvim_buf_del_var, 0, 'changedtick'))
+ eq('Key is read-only: changedtick', pcall_err(api.nvim_buf_del_var, 0, 'changedtick'))
eq(ct, changedtick())
eq(
@@ -107,7 +107,7 @@ describe('b:changedtick', function()
eq(ct, changedtick())
- funcs.setline(1, 'hello')
+ fn.setline(1, 'hello')
eq(ct + 1, changedtick())
end)
@@ -116,8 +116,8 @@ describe('b:changedtick', function()
end)
it('fails to unlock b:changedtick', function()
eq(0, exc_exec('let d = b:'))
- eq(0, funcs.islocked('b:changedtick'))
- eq(0, funcs.islocked('d.changedtick'))
+ eq(0, fn.islocked('b:changedtick'))
+ eq(0, fn.islocked('d.changedtick'))
eq(
'Vim(unlockvar):E940: Cannot lock or unlock variable b:changedtick',
pcall_err(command, 'unlockvar b:changedtick')
@@ -126,8 +126,8 @@ describe('b:changedtick', function()
'Vim(unlockvar):E46: Cannot change read-only variable "d.changedtick"',
pcall_err(command, 'unlockvar d.changedtick')
)
- eq(0, funcs.islocked('b:changedtick'))
- eq(0, funcs.islocked('d.changedtick'))
+ eq(0, fn.islocked('b:changedtick'))
+ eq(0, fn.islocked('d.changedtick'))
eq(
'Vim(lockvar):E940: Cannot lock or unlock variable b:changedtick',
pcall_err(command, 'lockvar b:changedtick')
@@ -136,12 +136,12 @@ describe('b:changedtick', function()
'Vim(lockvar):E46: Cannot change read-only variable "d.changedtick"',
pcall_err(command, 'lockvar d.changedtick')
)
- eq(0, funcs.islocked('b:changedtick'))
- eq(0, funcs.islocked('d.changedtick'))
+ eq(0, fn.islocked('b:changedtick'))
+ eq(0, fn.islocked('d.changedtick'))
end)
it('is being completed', function()
feed(':echo b:<Tab><Home>let cmdline="<End>"<CR>')
- eq('echo b:changedtick', meths.nvim_get_var('cmdline'))
+ eq('echo b:changedtick', api.nvim_get_var('cmdline'))
end)
it('cannot be changed by filter() or map()', function()
eq(2, changedtick())
diff --git a/test/functional/vimscript/container_functions_spec.lua b/test/functional/vimscript/container_functions_spec.lua
index 62e6efd7c2..1b34ea0165 100644
--- a/test/functional/vimscript/container_functions_spec.lua
+++ b/test/functional/vimscript/container_functions_spec.lua
@@ -2,23 +2,23 @@ local helpers = require('test.functional.helpers')(after_each)
local eq = helpers.eq
local eval = helpers.eval
-local meths = helpers.meths
+local api = helpers.api
local clear = helpers.clear
before_each(clear)
describe('extend()', function()
it('succeeds to extend list with itself', function()
- meths.nvim_set_var('l', { 1, {} })
+ api.nvim_set_var('l', { 1, {} })
eq({ 1, {}, 1, {} }, eval('extend(l, l)'))
- eq({ 1, {}, 1, {} }, meths.nvim_get_var('l'))
+ eq({ 1, {}, 1, {} }, api.nvim_get_var('l'))
- meths.nvim_set_var('l', { 1, {} })
+ api.nvim_set_var('l', { 1, {} })
eq({ 1, {}, 1, {} }, eval('extend(l, l, 0)'))
- eq({ 1, {}, 1, {} }, meths.nvim_get_var('l'))
+ eq({ 1, {}, 1, {} }, api.nvim_get_var('l'))
- meths.nvim_set_var('l', { 1, {} })
+ api.nvim_set_var('l', { 1, {} })
eq({ 1, 1, {}, {} }, eval('extend(l, l, 1)'))
- eq({ 1, 1, {}, {} }, meths.nvim_get_var('l'))
+ eq({ 1, 1, {}, {} }, api.nvim_get_var('l'))
end)
end)
diff --git a/test/functional/vimscript/ctx_functions_spec.lua b/test/functional/vimscript/ctx_functions_spec.lua
index ced29a6b76..b8f9bbc92d 100644
--- a/test/functional/vimscript/ctx_functions_spec.lua
+++ b/test/functional/vimscript/ctx_functions_spec.lua
@@ -7,7 +7,7 @@ local eq = helpers.eq
local eval = helpers.eval
local feed = helpers.feed
local map = vim.tbl_map
-local meths = helpers.meths
+local api = helpers.api
local parse_context = helpers.parse_context
local exec_capture = helpers.exec_capture
local source = helpers.source
@@ -126,16 +126,16 @@ describe('context functions', function()
end)
it('saves and restores global variables properly', function()
- meths.nvim_set_var('one', 1)
- meths.nvim_set_var('Two', 2)
- meths.nvim_set_var('THREE', 3)
+ api.nvim_set_var('one', 1)
+ api.nvim_set_var('Two', 2)
+ api.nvim_set_var('THREE', 3)
eq({ 1, 2, 3 }, eval('[g:one, g:Two, g:THREE]'))
call('ctxpush')
call('ctxpush', { 'gvars' })
- meths.nvim_del_var('one')
- meths.nvim_del_var('Two')
- meths.nvim_del_var('THREE')
+ api.nvim_del_var('one')
+ api.nvim_del_var('Two')
+ api.nvim_del_var('THREE')
eq('Vim:E121: Undefined variable: g:one', pcall_err(eval, 'g:one'))
eq('Vim:E121: Undefined variable: g:Two', pcall_err(eval, 'g:Two'))
eq('Vim:E121: Undefined variable: g:THREE', pcall_err(eval, 'g:THREE'))
@@ -143,9 +143,9 @@ describe('context functions', function()
call('ctxpop')
eq({ 1, 2, 3 }, eval('[g:one, g:Two, g:THREE]'))
- meths.nvim_del_var('one')
- meths.nvim_del_var('Two')
- meths.nvim_del_var('THREE')
+ api.nvim_del_var('one')
+ api.nvim_del_var('Two')
+ api.nvim_del_var('THREE')
eq('Vim:E121: Undefined variable: g:one', pcall_err(eval, 'g:one'))
eq('Vim:E121: Undefined variable: g:Two', pcall_err(eval, 'g:Two'))
eq('Vim:E121: Undefined variable: g:THREE', pcall_err(eval, 'g:THREE'))
@@ -300,9 +300,9 @@ describe('context functions', function()
feed('G')
feed('gg')
command('edit ' .. fname2)
- meths.nvim_set_var('one', 1)
- meths.nvim_set_var('Two', 2)
- meths.nvim_set_var('THREE', 3)
+ api.nvim_set_var('one', 1)
+ api.nvim_set_var('Two', 2)
+ api.nvim_set_var('THREE', 3)
local with_regs = {
['regs'] = {
@@ -412,14 +412,14 @@ describe('context functions', function()
end)
it('sets context dictionary at index in context stack', function()
- meths.nvim_set_var('one', 1)
- meths.nvim_set_var('Two', 2)
- meths.nvim_set_var('THREE', 3)
+ api.nvim_set_var('one', 1)
+ api.nvim_set_var('Two', 2)
+ api.nvim_set_var('THREE', 3)
call('ctxpush')
local ctx1 = call('ctxget')
- meths.nvim_set_var('one', 'a')
- meths.nvim_set_var('Two', 'b')
- meths.nvim_set_var('THREE', 'c')
+ api.nvim_set_var('one', 'a')
+ api.nvim_set_var('Two', 'b')
+ api.nvim_set_var('THREE', 'c')
call('ctxpush')
call('ctxpush')
local ctx2 = call('ctxget')
@@ -431,7 +431,7 @@ describe('context functions', function()
eq({ 1, 2, 3 }, eval('[g:one, g:Two, g:THREE]'))
call('ctxpop')
eq({ 'a', 'b', 'c' }, eval('[g:one, g:Two, g:THREE]'))
- meths.nvim_set_var('one', 1.5)
+ api.nvim_set_var('one', 1.5)
eq({ 1.5, 'b', 'c' }, eval('[g:one, g:Two, g:THREE]'))
call('ctxpop')
eq({ 'a', 'b', 'c' }, eval('[g:one, g:Two, g:THREE]'))
diff --git a/test/functional/vimscript/environ_spec.lua b/test/functional/vimscript/environ_spec.lua
index c5821567ff..0763def84e 100644
--- a/test/functional/vimscript/environ_spec.lua
+++ b/test/functional/vimscript/environ_spec.lua
@@ -1,13 +1,13 @@
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local eq = helpers.eq
-local environ = helpers.funcs.environ
-local exists = helpers.funcs.exists
-local system = helpers.funcs.system
+local environ = helpers.fn.environ
+local exists = helpers.fn.exists
+local system = helpers.fn.system
local nvim_prog = helpers.nvim_prog
local command = helpers.command
local eval = helpers.eval
-local setenv = helpers.funcs.setenv
+local setenv = helpers.fn.setenv
describe('environment variables', function()
it('environ() handles empty env variable', function()
diff --git a/test/functional/vimscript/errorlist_spec.lua b/test/functional/vimscript/errorlist_spec.lua
index 2977612247..1e405e7e64 100644
--- a/test/functional/vimscript/errorlist_spec.lua
+++ b/test/functional/vimscript/errorlist_spec.lua
@@ -4,10 +4,10 @@ local clear = helpers.clear
local command = helpers.command
local eq = helpers.eq
local exc_exec = helpers.exc_exec
-local get_win_var = helpers.meths.nvim_win_get_var
+local get_win_var = helpers.api.nvim_win_get_var
describe('setqflist()', function()
- local setqflist = helpers.funcs.setqflist
+ local setqflist = helpers.fn.setqflist
before_each(clear)
@@ -46,7 +46,7 @@ describe('setqflist()', function()
end)
describe('setloclist()', function()
- local setloclist = helpers.funcs.setloclist
+ local setloclist = helpers.fn.setloclist
before_each(clear)
diff --git a/test/functional/vimscript/eval_spec.lua b/test/functional/vimscript/eval_spec.lua
index 180e6118fd..e337959810 100644
--- a/test/functional/vimscript/eval_spec.lua
+++ b/test/functional/vimscript/eval_spec.lua
@@ -22,7 +22,7 @@ local exec_capture = helpers.exec_capture
local eval = helpers.eval
local command = helpers.command
local write_file = helpers.write_file
-local meths = helpers.meths
+local api = helpers.api
local sleep = vim.uv.sleep
local matches = helpers.matches
local pcall_err = helpers.pcall_err
@@ -33,13 +33,13 @@ local expect_exit = helpers.expect_exit
describe('Up to MAX_FUNC_ARGS arguments are handled by', function()
local max_func_args = 20 -- from eval.h
- local range = helpers.funcs.range
+ local range = helpers.fn.range
before_each(clear)
it('printf()', function()
- local printf = helpers.funcs.printf
- local rep = helpers.funcs['repeat']
+ local printf = helpers.fn.printf
+ local rep = helpers.fn['repeat']
local expected = '2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,'
eq(expected, printf(rep('%d,', max_func_args - 1), unpack(range(2, max_func_args))))
local ret = exc_exec('call printf("", 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21)')
@@ -47,7 +47,7 @@ describe('Up to MAX_FUNC_ARGS arguments are handled by', function()
end)
it('rpcnotify()', function()
- local rpcnotify = helpers.funcs.rpcnotify
+ local rpcnotify = helpers.fn.rpcnotify
local ret = rpcnotify(0, 'foo', unpack(range(3, max_func_args)))
eq(1, ret)
ret = exc_exec('call rpcnotify(0, "foo", 3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21)')
@@ -121,7 +121,7 @@ describe('List support code', function()
let bl = range(%u)
let dur = reltimestr(reltime(rt))
]]):format(len))
- dur = tonumber(meths.nvim_get_var('dur'))
+ dur = tonumber(api.nvim_get_var('dur'))
if dur >= min_dur then
-- print(('Using len %u, dur %g'):format(len, dur))
break
@@ -136,7 +136,7 @@ describe('List support code', function()
feed('<C-c>')
poke_eventloop()
command('let t_dur = reltimestr(reltime(t_rt))')
- local t_dur = tonumber(meths.nvim_get_var('t_dur'))
+ local t_dur = tonumber(api.nvim_get_var('t_dur'))
if t_dur >= dur / 8 then
eq(nil, ('Took too long to cancel: %g >= %g'):format(t_dur, dur / 8))
end
@@ -147,7 +147,7 @@ describe('List support code', function()
feed('<C-c>')
poke_eventloop()
command('let t_dur = reltimestr(reltime(t_rt))')
- local t_dur = tonumber(meths.nvim_get_var('t_dur'))
+ local t_dur = tonumber(api.nvim_get_var('t_dur'))
print(('t_dur: %g'):format(t_dur))
if t_dur >= dur / 8 then
eq(nil, ('Took too long to cancel: %g >= %g'):format(t_dur, dur / 8))
diff --git a/test/functional/vimscript/execute_spec.lua b/test/functional/vimscript/execute_spec.lua
index 3124c02c2f..29488ed31c 100644
--- a/test/functional/vimscript/execute_spec.lua
+++ b/test/functional/vimscript/execute_spec.lua
@@ -5,7 +5,7 @@ local clear = helpers.clear
local source = helpers.source
local exc_exec = helpers.exc_exec
local pcall_err = helpers.pcall_err
-local funcs = helpers.funcs
+local fn = helpers.fn
local Screen = require('test.functional.ui.screen')
local command = helpers.command
local feed = helpers.feed
@@ -22,16 +22,16 @@ describe('execute()', function()
silent! messages
redir END
]])
- eq(eval('g:__redir_output'), funcs.execute('messages'))
+ eq(eval('g:__redir_output'), fn.execute('messages'))
end)
it('captures the concatenated outputs of a List of commands', function()
- eq('foobar', funcs.execute({ 'echon "foo"', 'echon "bar"' }))
- eq('\nfoo\nbar', funcs.execute({ 'echo "foo"', 'echo "bar"' }))
+ eq('foobar', fn.execute({ 'echon "foo"', 'echon "bar"' }))
+ eq('\nfoo\nbar', fn.execute({ 'echo "foo"', 'echo "bar"' }))
end)
it('supports nested execute("execute(...)")', function()
- eq('42', funcs.execute([[echon execute("echon execute('echon 42')")]]))
+ eq('42', fn.execute([[echon execute("echon execute('echon 42')")]]))
end)
it('supports nested :redir to a variable', function()
@@ -54,7 +54,7 @@ describe('execute()', function()
return a
endfunction
]])
- eq('top1bar1foobar2bar3', funcs.execute('echon "top1"|call g:Bar()'))
+ eq('top1bar1foobar2bar3', fn.execute('echon "top1"|call g:Bar()'))
end)
it('supports nested :redir to a register', function()
@@ -76,17 +76,17 @@ describe('execute()', function()
return @a
endfunction
]])
- eq('top1bar1foobar2bar3', funcs.execute('echon "top1"|call g:Bar()'))
+ eq('top1bar1foobar2bar3', fn.execute('echon "top1"|call g:Bar()'))
-- :redir itself doesn't nest, so the redirection ends in g:Foo
eq('bar1foo', eval('@a'))
end)
it('captures a transformed string', function()
- eq('^A', funcs.execute('echon "\\<C-a>"'))
+ eq('^A', fn.execute('echon "\\<C-a>"'))
end)
it('returns empty string if the argument list is empty', function()
- eq('', funcs.execute({}))
+ eq('', fn.execute({}))
eq(0, exc_exec('let g:ret = execute(v:_null_list)'))
eq('', eval('g:ret'))
end)
@@ -255,7 +255,7 @@ describe('execute()', function()
-- with how nvim currently displays the output.
it('captures shell-command output', function()
local win_lf = is_os('win') and '\13' or ''
- eq('\n:!echo foo\r\n\nfoo' .. win_lf .. '\n', funcs.execute('!echo foo'))
+ eq('\n:!echo foo\r\n\nfoo' .. win_lf .. '\n', fn.execute('!echo foo'))
end)
describe('{silent} argument', function()
@@ -275,11 +275,11 @@ describe('execute()', function()
command('split')
eq(
'Vim(windo):E493: Backwards range given: 2,1windo echo',
- pcall_err(funcs.execute, '2,1windo echo', '')
+ pcall_err(fn.execute, '2,1windo echo', '')
)
eq(
'Vim(windo):E493: Backwards range given: 2,1windo echo',
- pcall_err(funcs.execute, { '2,1windo echo' }, '')
+ pcall_err(fn.execute, { '2,1windo echo' }, '')
)
end)
diff --git a/test/functional/vimscript/fnamemodify_spec.lua b/test/functional/vimscript/fnamemodify_spec.lua
index 6e49bcb0c5..4a134fe23c 100644
--- a/test/functional/vimscript/fnamemodify_spec.lua
+++ b/test/functional/vimscript/fnamemodify_spec.lua
@@ -1,8 +1,8 @@
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local eq = helpers.eq
-local fnamemodify = helpers.funcs.fnamemodify
-local getcwd = helpers.funcs.getcwd
+local fnamemodify = helpers.fn.fnamemodify
+local getcwd = helpers.fn.getcwd
local command = helpers.command
local write_file = helpers.write_file
local alter_slashes = helpers.alter_slashes
diff --git a/test/functional/vimscript/has_spec.lua b/test/functional/vimscript/has_spec.lua
index c797a3bbf9..82b3db5b67 100644
--- a/test/functional/vimscript/has_spec.lua
+++ b/test/functional/vimscript/has_spec.lua
@@ -3,7 +3,7 @@ local Screen = require('test.functional.ui.screen')
local clear = helpers.clear
local connect = helpers.connect
local eq = helpers.eq
-local funcs = helpers.funcs
+local fn = helpers.fn
local is_os = helpers.is_os
local nvim_prog = helpers.nvim_prog
@@ -11,83 +11,83 @@ describe('has()', function()
before_each(clear)
it('"nvim-x.y.z"', function()
- eq(0, funcs.has('nvim-'))
- eq(0, funcs.has('nvim- '))
- eq(0, funcs.has('nvim- \t '))
- eq(0, funcs.has('nvim-0. 1. 1'))
- eq(0, funcs.has('nvim-0. 1.1'))
- eq(0, funcs.has('nvim-0.1. 1'))
- eq(0, funcs.has('nvim-a'))
- eq(0, funcs.has('nvim-a.b.c'))
- eq(0, funcs.has('nvim-0.b.c'))
- eq(0, funcs.has('nvim-0.0.c'))
- eq(0, funcs.has('nvim-0.b.0'))
- eq(0, funcs.has('nvim-a.b.0'))
- eq(0, funcs.has('nvim-.0.0.0'))
- eq(0, funcs.has('nvim-.0'))
- eq(0, funcs.has('nvim-0.'))
- eq(0, funcs.has('nvim-0..'))
- eq(0, funcs.has('nvim-.'))
- eq(0, funcs.has('nvim-..'))
- eq(0, funcs.has('nvim-...'))
- eq(0, funcs.has('nvim-42'))
- eq(0, funcs.has('nvim-9999'))
- eq(0, funcs.has('nvim-99.001.05'))
+ eq(0, fn.has('nvim-'))
+ eq(0, fn.has('nvim- '))
+ eq(0, fn.has('nvim- \t '))
+ eq(0, fn.has('nvim-0. 1. 1'))
+ eq(0, fn.has('nvim-0. 1.1'))
+ eq(0, fn.has('nvim-0.1. 1'))
+ eq(0, fn.has('nvim-a'))
+ eq(0, fn.has('nvim-a.b.c'))
+ eq(0, fn.has('nvim-0.b.c'))
+ eq(0, fn.has('nvim-0.0.c'))
+ eq(0, fn.has('nvim-0.b.0'))
+ eq(0, fn.has('nvim-a.b.0'))
+ eq(0, fn.has('nvim-.0.0.0'))
+ eq(0, fn.has('nvim-.0'))
+ eq(0, fn.has('nvim-0.'))
+ eq(0, fn.has('nvim-0..'))
+ eq(0, fn.has('nvim-.'))
+ eq(0, fn.has('nvim-..'))
+ eq(0, fn.has('nvim-...'))
+ eq(0, fn.has('nvim-42'))
+ eq(0, fn.has('nvim-9999'))
+ eq(0, fn.has('nvim-99.001.05'))
- eq(1, funcs.has('nvim'))
- eq(1, funcs.has('nvim-0'))
- eq(1, funcs.has('nvim-0.1'))
- eq(1, funcs.has('nvim-0.0.0'))
- eq(1, funcs.has('nvim-0.1.1.'))
- eq(1, funcs.has('nvim-0.1.1.abc'))
- eq(1, funcs.has('nvim-0.1.1..'))
- eq(1, funcs.has('nvim-0.1.1.. ..'))
- eq(1, funcs.has('nvim-0.1.1.... '))
- eq(1, funcs.has('nvim-0.0.0'))
- eq(1, funcs.has('nvim-0.0.1'))
- eq(1, funcs.has('nvim-0.1.0'))
- eq(1, funcs.has('nvim-0.1.1'))
- eq(1, funcs.has('nvim-0.1.5'))
- eq(1, funcs.has('nvim-0000.001.05'))
- eq(1, funcs.has('nvim-0.01.005'))
- eq(1, funcs.has('nvim-00.001.05'))
+ eq(1, fn.has('nvim'))
+ eq(1, fn.has('nvim-0'))
+ eq(1, fn.has('nvim-0.1'))
+ eq(1, fn.has('nvim-0.0.0'))
+ eq(1, fn.has('nvim-0.1.1.'))
+ eq(1, fn.has('nvim-0.1.1.abc'))
+ eq(1, fn.has('nvim-0.1.1..'))
+ eq(1, fn.has('nvim-0.1.1.. ..'))
+ eq(1, fn.has('nvim-0.1.1.... '))
+ eq(1, fn.has('nvim-0.0.0'))
+ eq(1, fn.has('nvim-0.0.1'))
+ eq(1, fn.has('nvim-0.1.0'))
+ eq(1, fn.has('nvim-0.1.1'))
+ eq(1, fn.has('nvim-0.1.5'))
+ eq(1, fn.has('nvim-0000.001.05'))
+ eq(1, fn.has('nvim-0.01.005'))
+ eq(1, fn.has('nvim-00.001.05'))
end)
it('"unnamedplus"', function()
- if (not is_os('win')) and funcs.has('clipboard') == 1 then
- eq(1, funcs.has('unnamedplus'))
+ if (not is_os('win')) and fn.has('clipboard') == 1 then
+ eq(1, fn.has('unnamedplus'))
else
- eq(0, funcs.has('unnamedplus'))
+ eq(0, fn.has('unnamedplus'))
end
end)
it('"wsl"', function()
local is_wsl = vim.uv.os_uname()['release']:lower():match('microsoft') and true or false
if is_wsl then
- eq(1, funcs.has('wsl'))
+ eq(1, fn.has('wsl'))
else
- eq(0, funcs.has('wsl'))
+ eq(0, fn.has('wsl'))
end
end)
it('"gui_running"', function()
- eq(0, funcs.has('gui_running'))
+ eq(0, fn.has('gui_running'))
local tui = Screen.new(50, 15)
- local gui_session = connect(funcs.serverstart())
+ local gui_session = connect(fn.serverstart())
local gui = Screen.new(50, 15)
- eq(0, funcs.has('gui_running'))
+ eq(0, fn.has('gui_running'))
tui:attach({ ext_linegrid = true, rgb = true, stdin_tty = true, stdout_tty = true })
gui:attach({ ext_multigrid = true, rgb = true }, gui_session)
- eq(1, funcs.has('gui_running'))
+ eq(1, fn.has('gui_running'))
tui:detach()
- eq(1, funcs.has('gui_running'))
+ eq(1, fn.has('gui_running'))
gui:detach()
- eq(0, funcs.has('gui_running'))
+ eq(0, fn.has('gui_running'))
end)
it('does not change v:shell_error', function()
- funcs.system({ nvim_prog, '-es', '+73cquit' })
- funcs.has('python3') -- use a call whose implementation shells out
- eq(73, funcs.eval('v:shell_error'))
+ fn.system({ nvim_prog, '-es', '+73cquit' })
+ fn.has('python3') -- use a call whose implementation shells out
+ eq(73, fn.eval('v:shell_error'))
end)
end)
diff --git a/test/functional/vimscript/input_spec.lua b/test/functional/vimscript/input_spec.lua
index 2e1d0501cf..6dd22078d6 100644
--- a/test/functional/vimscript/input_spec.lua
+++ b/test/functional/vimscript/input_spec.lua
@@ -3,7 +3,7 @@ local Screen = require('test.functional.ui.screen')
local eq = helpers.eq
local feed = helpers.feed
-local meths = helpers.meths
+local api = helpers.api
local clear = helpers.clear
local source = helpers.source
local command = helpers.command
@@ -110,7 +110,7 @@ describe('input()', function()
end)
it('allows unequal numeric values when using {opts} dictionary', function()
command('echohl Test')
- meths.nvim_set_var('opts', { prompt = 1, default = 2, cancelreturn = 3 })
+ api.nvim_set_var('opts', { prompt = 1, default = 2, cancelreturn = 3 })
feed([[:echo input(opts)<CR>]])
screen:expect([[
|
@@ -132,7 +132,7 @@ describe('input()', function()
end)
it('works with redraw', function()
command('echohl Test')
- meths.nvim_set_var('opts', { prompt = 'Foo>', default = 'Bar' })
+ api.nvim_set_var('opts', { prompt = 'Foo>', default = 'Bar' })
feed([[:echo inputdialog(opts)<CR>]])
screen:expect([[
|
@@ -176,34 +176,34 @@ describe('input()', function()
it('supports completion', function()
feed(':let var = input("", "", "custom,CustomCompl")<CR>')
feed('<Tab><CR>')
- eq('TEST', meths.nvim_get_var('var'))
+ eq('TEST', api.nvim_get_var('var'))
feed(':let var = input({"completion": "customlist,CustomListCompl"})<CR>')
feed('<Tab><CR>')
- eq('FOO', meths.nvim_get_var('var'))
+ eq('FOO', api.nvim_get_var('var'))
end)
it('supports cancelreturn', function()
feed(':let var = input({"cancelreturn": "BAR"})<CR>')
feed('<Esc>')
- eq('BAR', meths.nvim_get_var('var'))
+ eq('BAR', api.nvim_get_var('var'))
feed(':let var = input({"cancelreturn": []})<CR>')
feed('<Esc>')
- eq({}, meths.nvim_get_var('var'))
+ eq({}, api.nvim_get_var('var'))
feed(':let var = input({"cancelreturn": v:false})<CR>')
feed('<Esc>')
- eq(false, meths.nvim_get_var('var'))
+ eq(false, api.nvim_get_var('var'))
feed(':let var = input({"cancelreturn": v:null})<CR>')
feed('<Esc>')
- eq(NIL, meths.nvim_get_var('var'))
+ eq(NIL, api.nvim_get_var('var'))
end)
it('supports default string', function()
feed(':let var = input("", "DEF1")<CR>')
feed('<CR>')
- eq('DEF1', meths.nvim_get_var('var'))
+ eq('DEF1', api.nvim_get_var('var'))
feed(':let var = input({"default": "DEF2"})<CR>')
feed('<CR>')
- eq('DEF2', meths.nvim_get_var('var'))
+ eq('DEF2', api.nvim_get_var('var'))
end)
it('errors out on invalid inputs', function()
eq('Vim(call):E730: Using a List as a String', exc_exec('call input([])'))
@@ -292,7 +292,7 @@ describe('inputdialog()', function()
end)
it('allows unequal numeric values when using {opts} dictionary', function()
command('echohl Test')
- meths.nvim_set_var('opts', { prompt = 1, default = 2, cancelreturn = 3 })
+ api.nvim_set_var('opts', { prompt = 1, default = 2, cancelreturn = 3 })
feed([[:echo input(opts)<CR>]])
screen:expect([[
|
@@ -314,7 +314,7 @@ describe('inputdialog()', function()
end)
it('works with redraw', function()
command('echohl Test')
- meths.nvim_set_var('opts', { prompt = 'Foo>', default = 'Bar' })
+ api.nvim_set_var('opts', { prompt = 'Foo>', default = 'Bar' })
feed([[:echo input(opts)<CR>]])
screen:expect([[
|
@@ -358,25 +358,25 @@ describe('inputdialog()', function()
it('supports completion', function()
feed(':let var = inputdialog({"completion": "customlist,CustomListCompl"})<CR>')
feed('<Tab><CR>')
- eq('FOO', meths.nvim_get_var('var'))
+ eq('FOO', api.nvim_get_var('var'))
end)
it('supports cancelreturn', function()
feed(':let var = inputdialog("", "", "CR1")<CR>')
feed('<Esc>')
- eq('CR1', meths.nvim_get_var('var'))
+ eq('CR1', api.nvim_get_var('var'))
feed(':let var = inputdialog({"cancelreturn": "BAR"})<CR>')
feed('<Esc>')
- eq('BAR', meths.nvim_get_var('var'))
+ eq('BAR', api.nvim_get_var('var'))
end)
it('supports default string', function()
feed(':let var = inputdialog("", "DEF1")<CR>')
feed('<CR>')
- eq('DEF1', meths.nvim_get_var('var'))
+ eq('DEF1', api.nvim_get_var('var'))
feed(':let var = inputdialog({"default": "DEF2"})<CR>')
feed('<CR>')
- eq('DEF2', meths.nvim_get_var('var'))
+ eq('DEF2', api.nvim_get_var('var'))
end)
it('errors out on invalid inputs', function()
eq('Vim(call):E730: Using a List as a String', exc_exec('call inputdialog([])'))
@@ -409,8 +409,8 @@ end)
describe('confirm()', function()
-- oldtest: Test_confirm()
it('works', function()
- meths.nvim_set_option_value('more', false, {}) -- Avoid hit-enter prompt
- meths.nvim_set_option_value('laststatus', 2, {})
+ api.nvim_set_option_value('more', false, {}) -- Avoid hit-enter prompt
+ api.nvim_set_option_value('laststatus', 2, {})
-- screen:expect() calls are needed to avoid feeding input too early
screen:expect({ any = '%[No Name%]' })
@@ -418,19 +418,19 @@ describe('confirm()', function()
screen:expect({ any = '{CONFIRM:.+: }' })
feed('o')
screen:expect({ any = '%[No Name%]' })
- eq(1, meths.nvim_get_var('a'))
+ eq(1, api.nvim_get_var('a'))
async_meths.command([[let a = 'Are you sure?'->confirm("&Yes\n&No")]])
screen:expect({ any = '{CONFIRM:.+: }' })
feed('y')
screen:expect({ any = '%[No Name%]' })
- eq(1, meths.nvim_get_var('a'))
+ eq(1, api.nvim_get_var('a'))
async_meths.command([[let a = confirm('Are you sure?', "&Yes\n&No")]])
screen:expect({ any = '{CONFIRM:.+: }' })
feed('n')
screen:expect({ any = '%[No Name%]' })
- eq(2, meths.nvim_get_var('a'))
+ eq(2, api.nvim_get_var('a'))
-- Not possible to match Vim's CTRL-C test here as CTRL-C always sets got_int in Nvim.
@@ -439,26 +439,26 @@ describe('confirm()', function()
screen:expect({ any = '{CONFIRM:.+: }' })
feed('<Esc>')
screen:expect({ any = '%[No Name%]' })
- eq(0, meths.nvim_get_var('a'))
+ eq(0, api.nvim_get_var('a'))
-- Default choice is returned when pressing <CR>.
async_meths.command([[let a = confirm('Are you sure?', "&Yes\n&No")]])
screen:expect({ any = '{CONFIRM:.+: }' })
feed('<CR>')
screen:expect({ any = '%[No Name%]' })
- eq(1, meths.nvim_get_var('a'))
+ eq(1, api.nvim_get_var('a'))
async_meths.command([[let a = confirm('Are you sure?', "&Yes\n&No", 2)]])
screen:expect({ any = '{CONFIRM:.+: }' })
feed('<CR>')
screen:expect({ any = '%[No Name%]' })
- eq(2, meths.nvim_get_var('a'))
+ eq(2, api.nvim_get_var('a'))
async_meths.command([[let a = confirm('Are you sure?', "&Yes\n&No", 0)]])
screen:expect({ any = '{CONFIRM:.+: }' })
feed('<CR>')
screen:expect({ any = '%[No Name%]' })
- eq(0, meths.nvim_get_var('a'))
+ eq(0, api.nvim_get_var('a'))
-- Test with the {type} 4th argument
for _, type in ipairs({ 'Error', 'Question', 'Info', 'Warning', 'Generic' }) do
@@ -466,7 +466,7 @@ describe('confirm()', function()
screen:expect({ any = '{CONFIRM:.+: }' })
feed('y')
screen:expect({ any = '%[No Name%]' })
- eq(1, meths.nvim_get_var('a'))
+ eq(1, api.nvim_get_var('a'))
end
eq('Vim(call):E730: Using a List as a String', pcall_err(command, 'call confirm([])'))
diff --git a/test/functional/vimscript/json_functions_spec.lua b/test/functional/vimscript/json_functions_spec.lua
index 8f54cce444..ef0359263e 100644
--- a/test/functional/vimscript/json_functions_spec.lua
+++ b/test/functional/vimscript/json_functions_spec.lua
@@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
-local funcs = helpers.funcs
-local meths = helpers.meths
+local fn = helpers.fn
+local api = helpers.api
local eq = helpers.eq
local eval = helpers.eval
local command = helpers.command
@@ -59,13 +59,13 @@ describe('json_decode() function', function()
before_each(restart)
local speq = function(expected, actual_expr)
- eq(1, funcs.EvalEq(expected, actual_expr))
+ eq(1, fn.EvalEq(expected, actual_expr))
end
it('accepts readfile()-style list', function()
eq(
{ Test = 1 },
- funcs.json_decode({
+ fn.json_decode({
'{',
'\t"Test": 1',
'}',
@@ -76,7 +76,7 @@ describe('json_decode() function', function()
it('accepts strings with newlines', function()
eq(
{ Test = 1 },
- funcs.json_decode([[
+ fn.json_decode([[
{
"Test": 1
}
@@ -85,9 +85,9 @@ describe('json_decode() function', function()
end)
it('parses null, true, false', function()
- eq(NIL, funcs.json_decode('null'))
- eq(true, funcs.json_decode('true'))
- eq(false, funcs.json_decode('false'))
+ eq(NIL, fn.json_decode('null'))
+ eq(true, fn.json_decode('true'))
+ eq(false, fn.json_decode('false'))
end)
it('fails to parse incomplete null, true, false', function()
@@ -109,12 +109,12 @@ describe('json_decode() function', function()
end)
it('parses integer numbers', function()
- eq(100000, funcs.json_decode('100000'))
- eq(-100000, funcs.json_decode('-100000'))
- eq(100000, funcs.json_decode(' 100000 '))
- eq(-100000, funcs.json_decode(' -100000 '))
- eq(0, funcs.json_decode('0'))
- eq(0, funcs.json_decode('-0'))
+ eq(100000, fn.json_decode('100000'))
+ eq(-100000, fn.json_decode('-100000'))
+ eq(100000, fn.json_decode(' 100000 '))
+ eq(-100000, fn.json_decode(' -100000 '))
+ eq(0, fn.json_decode('0'))
+ eq(0, fn.json_decode('-0'))
end)
it('fails to parse +numbers and .number', function()
@@ -158,35 +158,35 @@ describe('json_decode() function', function()
it('parses floating-point numbers', function()
-- Also test method call (->) syntax
eq('100000.0', eval('"100000.0"->json_decode()->string()'))
- eq(100000.5, funcs.json_decode('100000.5'))
- eq(-100000.5, funcs.json_decode('-100000.5'))
- eq(-100000.5e50, funcs.json_decode('-100000.5e50'))
- eq(100000.5e50, funcs.json_decode('100000.5e50'))
- eq(100000.5e50, funcs.json_decode('100000.5e+50'))
- eq(-100000.5e-50, funcs.json_decode('-100000.5e-50'))
- eq(100000.5e-50, funcs.json_decode('100000.5e-50'))
- eq(100000e-50, funcs.json_decode('100000e-50'))
- eq(0.5, funcs.json_decode('0.5'))
- eq(0.005, funcs.json_decode('0.005'))
- eq(0.005, funcs.json_decode('0.00500'))
- eq(0.5, funcs.json_decode('0.00500e+002'))
- eq(0.00005, funcs.json_decode('0.00500e-002'))
-
- eq(-0.0, funcs.json_decode('-0.0'))
- eq(-0.0, funcs.json_decode('-0.0e0'))
- eq(-0.0, funcs.json_decode('-0.0e+0'))
- eq(-0.0, funcs.json_decode('-0.0e-0'))
- eq(-0.0, funcs.json_decode('-0e-0'))
- eq(-0.0, funcs.json_decode('-0e-2'))
- eq(-0.0, funcs.json_decode('-0e+2'))
-
- eq(0.0, funcs.json_decode('0.0'))
- eq(0.0, funcs.json_decode('0.0e0'))
- eq(0.0, funcs.json_decode('0.0e+0'))
- eq(0.0, funcs.json_decode('0.0e-0'))
- eq(0.0, funcs.json_decode('0e-0'))
- eq(0.0, funcs.json_decode('0e-2'))
- eq(0.0, funcs.json_decode('0e+2'))
+ eq(100000.5, fn.json_decode('100000.5'))
+ eq(-100000.5, fn.json_decode('-100000.5'))
+ eq(-100000.5e50, fn.json_decode('-100000.5e50'))
+ eq(100000.5e50, fn.json_decode('100000.5e50'))
+ eq(100000.5e50, fn.json_decode('100000.5e+50'))
+ eq(-100000.5e-50, fn.json_decode('-100000.5e-50'))
+ eq(100000.5e-50, fn.json_decode('100000.5e-50'))
+ eq(100000e-50, fn.json_decode('100000e-50'))
+ eq(0.5, fn.json_decode('0.5'))
+ eq(0.005, fn.json_decode('0.005'))
+ eq(0.005, fn.json_decode('0.00500'))
+ eq(0.5, fn.json_decode('0.00500e+002'))
+ eq(0.00005, fn.json_decode('0.00500e-002'))
+
+ eq(-0.0, fn.json_decode('-0.0'))
+ eq(-0.0, fn.json_decode('-0.0e0'))
+ eq(-0.0, fn.json_decode('-0.0e+0'))
+ eq(-0.0, fn.json_decode('-0.0e-0'))
+ eq(-0.0, fn.json_decode('-0e-0'))
+ eq(-0.0, fn.json_decode('-0e-2'))
+ eq(-0.0, fn.json_decode('-0e+2'))
+
+ eq(0.0, fn.json_decode('0.0'))
+ eq(0.0, fn.json_decode('0.0e0'))
+ eq(0.0, fn.json_decode('0.0e+0'))
+ eq(0.0, fn.json_decode('0.0e-0'))
+ eq(0.0, fn.json_decode('0e-0'))
+ eq(0.0, fn.json_decode('0e-2'))
+ eq(0.0, fn.json_decode('0e+2'))
end)
it('fails to parse numbers with spaces inside', function()
@@ -210,7 +210,7 @@ describe('json_decode() function', function()
end)
it('parses empty containers', function()
- eq({}, funcs.json_decode('[]'))
+ eq({}, fn.json_decode('[]'))
eq('[]', eval('string(json_decode("[]"))'))
end)
@@ -301,12 +301,12 @@ describe('json_decode() function', function()
end)
it('parses containers', function()
- eq({ 1 }, funcs.json_decode('[1]'))
- eq({ NIL, 1 }, funcs.json_decode('[null, 1]'))
- eq({ ['1'] = 2 }, funcs.json_decode('{"1": 2}'))
+ eq({ 1 }, fn.json_decode('[1]'))
+ eq({ NIL, 1 }, fn.json_decode('[null, 1]'))
+ eq({ ['1'] = 2 }, fn.json_decode('{"1": 2}'))
eq(
{ ['1'] = 2, ['3'] = { { ['4'] = { ['5'] = { {}, 1 } } } } },
- funcs.json_decode('{"1": 2, "3": [{"4": {"5": [[], 1]}}]}')
+ fn.json_decode('{"1": 2, "3": [{"4": {"5": [[], 1]}}]}')
)
end)
@@ -363,10 +363,10 @@ describe('json_decode() function', function()
end)
it('parses strings properly', function()
- eq('\n', funcs.json_decode('"\\n"'))
- eq('', funcs.json_decode('""'))
- eq('\\/"\t\b\n\r\f', funcs.json_decode([["\\\/\"\t\b\n\r\f"]]))
- eq('/a', funcs.json_decode([["\/a"]]))
+ eq('\n', fn.json_decode('"\\n"'))
+ eq('', fn.json_decode('""'))
+ eq('\\/"\t\b\n\r\f', fn.json_decode([["\\\/\"\t\b\n\r\f"]]))
+ eq('/a', fn.json_decode([["\/a"]]))
-- Unicode characters: 2-byte, 3-byte, 4-byte
eq(
{
@@ -374,7 +374,7 @@ describe('json_decode() function', function()
'ફ',
'\240\144\128\128',
},
- funcs.json_decode({
+ fn.json_decode({
'[',
'"«",',
'"ફ",',
@@ -472,29 +472,29 @@ describe('json_decode() function', function()
end)
it('parses surrogate pairs properly', function()
- eq('\240\144\128\128', funcs.json_decode('"\\uD800\\uDC00"'))
- eq('\237\160\128a\237\176\128', funcs.json_decode('"\\uD800a\\uDC00"'))
- eq('\237\160\128\t\237\176\128', funcs.json_decode('"\\uD800\\t\\uDC00"'))
+ eq('\240\144\128\128', fn.json_decode('"\\uD800\\uDC00"'))
+ eq('\237\160\128a\237\176\128', fn.json_decode('"\\uD800a\\uDC00"'))
+ eq('\237\160\128\t\237\176\128', fn.json_decode('"\\uD800\\t\\uDC00"'))
- eq('\237\160\128', funcs.json_decode('"\\uD800"'))
- eq('\237\160\128a', funcs.json_decode('"\\uD800a"'))
- eq('\237\160\128\t', funcs.json_decode('"\\uD800\\t"'))
+ eq('\237\160\128', fn.json_decode('"\\uD800"'))
+ eq('\237\160\128a', fn.json_decode('"\\uD800a"'))
+ eq('\237\160\128\t', fn.json_decode('"\\uD800\\t"'))
- eq('\237\176\128', funcs.json_decode('"\\uDC00"'))
- eq('\237\176\128a', funcs.json_decode('"\\uDC00a"'))
- eq('\237\176\128\t', funcs.json_decode('"\\uDC00\\t"'))
+ eq('\237\176\128', fn.json_decode('"\\uDC00"'))
+ eq('\237\176\128a', fn.json_decode('"\\uDC00a"'))
+ eq('\237\176\128\t', fn.json_decode('"\\uDC00\\t"'))
- eq('\237\176\128', funcs.json_decode('"\\uDC00"'))
- eq('a\237\176\128', funcs.json_decode('"a\\uDC00"'))
- eq('\t\237\176\128', funcs.json_decode('"\\t\\uDC00"'))
+ eq('\237\176\128', fn.json_decode('"\\uDC00"'))
+ eq('a\237\176\128', fn.json_decode('"a\\uDC00"'))
+ eq('\t\237\176\128', fn.json_decode('"\\t\\uDC00"'))
- eq('\237\160\128¬', funcs.json_decode('"\\uD800\\u00AC"'))
+ eq('\237\160\128¬', fn.json_decode('"\\uD800\\u00AC"'))
- eq('\237\160\128\237\160\128', funcs.json_decode('"\\uD800\\uD800"'))
+ eq('\237\160\128\237\160\128', fn.json_decode('"\\uD800\\uD800"'))
end)
local sp_decode_eq = function(expected, json)
- meths.nvim_set_var('__json', json)
+ api.nvim_set_var('__json', json)
speq(expected, 'json_decode(g:__json)')
command('unlet! g:__json')
end
@@ -570,10 +570,10 @@ describe('json_decode() function', function()
end)
it('parses dictionaries with empty keys', function()
- eq({ [''] = 4 }, funcs.json_decode('{"": 4}'))
+ eq({ [''] = 4 }, fn.json_decode('{"": 4}'))
eq(
{ b = 3, a = 1, c = 4, d = 2, [''] = 4 },
- funcs.json_decode('{"b": 3, "a": 1, "c": 4, "d": 2, "": 4}')
+ fn.json_decode('{"b": 3, "a": 1, "c": 4, "d": 2, "": 4}')
)
end)
@@ -602,7 +602,7 @@ describe('json_decode() function', function()
end)
it('parses U+00C3 correctly', function()
- eq('\195\131', funcs.json_decode('"\195\131"'))
+ eq('\195\131', fn.json_decode('"\195\131"'))
end)
it('fails to parse empty string', function()
@@ -622,7 +622,7 @@ describe('json_decode() function', function()
local s =
' \t\n\r \t\r\n \n\t\r \n\r\t \r\t\n \r\n\t\t \n\r\t \r\n\t\n \r\t\n\r \t\r \n\t\r\n \n \t\r\n \r\t\n\t \r\n\t\r \n\r \t\n\r\t \r \t\n\r \n\t\r\t \n\r\t\n \r\n \t\r\n\t'
local str = ('%s{%s"key"%s:%s[%s"val"%s,%s"val2"%s]%s,%s"key2"%s:%s1%s}%s'):gsub('%%s', s)
- eq({ key = { 'val', 'val2' }, key2 = 1 }, funcs.json_decode(str))
+ eq({ key = { 'val', 'val2' }, key2 = 1 }, fn.json_decode(str))
end)
it('does not overflow when writing error message about decoding ["", ""]', function()
@@ -640,12 +640,12 @@ describe('json_encode() function', function()
end)
it('dumps strings', function()
- eq('"Test"', funcs.json_encode('Test'))
- eq('""', funcs.json_encode(''))
- eq('"\\t"', funcs.json_encode('\t'))
- eq('"\\n"', funcs.json_encode('\n'))
- eq('"\\u001B"', funcs.json_encode('\27'))
- eq('"þÿþ"', funcs.json_encode('þÿþ'))
+ eq('"Test"', fn.json_encode('Test'))
+ eq('""', fn.json_encode(''))
+ eq('"\\t"', fn.json_encode('\t'))
+ eq('"\\n"', fn.json_encode('\n'))
+ eq('"\\u001B"', fn.json_encode('\27'))
+ eq('"þÿþ"', fn.json_encode('þÿþ'))
end)
it('dumps blobs', function()
@@ -654,17 +654,17 @@ describe('json_encode() function', function()
end)
it('dumps numbers', function()
- eq('0', funcs.json_encode(0))
- eq('10', funcs.json_encode(10))
- eq('-10', funcs.json_encode(-10))
+ eq('0', fn.json_encode(0))
+ eq('10', fn.json_encode(10))
+ eq('-10', fn.json_encode(-10))
end)
it('dumps floats', function()
-- Also test method call (->) syntax
eq('0.0', eval('0.0->json_encode()'))
- eq('10.5', funcs.json_encode(10.5))
- eq('-10.5', funcs.json_encode(-10.5))
- eq('-1.0e-5', funcs.json_encode(-1e-5))
+ eq('10.5', fn.json_encode(10.5))
+ eq('-10.5', fn.json_encode(-10.5))
+ eq('-1.0e-5', fn.json_encode(-1e-5))
eq('1.0e50', eval('1.0e50->json_encode()'))
end)
@@ -684,17 +684,17 @@ describe('json_encode() function', function()
end)
it('dumps lists', function()
- eq('[]', funcs.json_encode({}))
- eq('[[]]', funcs.json_encode({ {} }))
- eq('[[], []]', funcs.json_encode({ {}, {} }))
+ eq('[]', fn.json_encode({}))
+ eq('[[]]', fn.json_encode({ {} }))
+ eq('[[], []]', fn.json_encode({ {}, {} }))
end)
it('dumps dictionaries', function()
eq('{}', eval('json_encode({})'))
- eq('{"d": []}', funcs.json_encode({ d = {} }))
- eq('{"d": [], "e": []}', funcs.json_encode({ d = {}, e = {} }))
+ eq('{"d": []}', fn.json_encode({ d = {} }))
+ eq('{"d": [], "e": []}', fn.json_encode({ d = {}, e = {} }))
-- Empty keys are allowed per JSON spec (and Vim dicts, and msgpack).
- eq('{"": []}', funcs.json_encode({ [''] = {} }))
+ eq('{"": []}', fn.json_encode({ [''] = {} }))
end)
it('cannot dump generic mapping with generic mapping keys and values', function()
@@ -892,9 +892,9 @@ describe('json_encode() function', function()
end)
it('ignores improper values in &isprint', function()
- meths.nvim_set_option_value('isprint', '1', {})
+ api.nvim_set_option_value('isprint', '1', {})
eq(1, eval('"\1" =~# "\\\\p"'))
- eq('"\\u0001"', funcs.json_encode('\1'))
+ eq('"\\u0001"', fn.json_encode('\1'))
end)
it('fails when using surrogate character in a UTF-8 string', function()
diff --git a/test/functional/vimscript/let_spec.lua b/test/functional/vimscript/let_spec.lua
index 7c632fc67e..15d4b189b8 100644
--- a/test/functional/vimscript/let_spec.lua
+++ b/test/functional/vimscript/let_spec.lua
@@ -4,7 +4,7 @@ local eq = helpers.eq
local clear = helpers.clear
local command = helpers.command
local eval = helpers.eval
-local meths = helpers.meths
+local api = helpers.api
local exec = helpers.exec
local exec_capture = helpers.exec_capture
local expect_exit = helpers.expect_exit
@@ -15,12 +15,12 @@ before_each(clear)
describe(':let', function()
it('correctly lists variables with curly-braces', function()
- meths.nvim_set_var('v', { 0 })
+ api.nvim_set_var('v', { 0 })
eq('v [0]', exec_capture('let {"v"}'))
end)
it('correctly lists variables with subscript', function()
- meths.nvim_set_var('v', { 0 })
+ api.nvim_set_var('v', { 0 })
eq('v[0] #0', exec_capture('let v[0]'))
eq('g:["v"][0] #0', exec_capture('let g:["v"][0]'))
eq('{"g:"}["v"][0] #0', exec_capture('let {"g:"}["v"][0]'))
@@ -100,17 +100,17 @@ describe(':let', function()
end)
it('can apply operator to boolean option', function()
- eq(true, meths.nvim_get_option_value('equalalways', {}))
+ eq(true, api.nvim_get_option_value('equalalways', {}))
command('let &equalalways -= 1')
- eq(false, meths.nvim_get_option_value('equalalways', {}))
+ eq(false, api.nvim_get_option_value('equalalways', {}))
command('let &equalalways += 1')
- eq(true, meths.nvim_get_option_value('equalalways', {}))
+ eq(true, api.nvim_get_option_value('equalalways', {}))
command('let &equalalways *= 1')
- eq(true, meths.nvim_get_option_value('equalalways', {}))
+ eq(true, api.nvim_get_option_value('equalalways', {}))
command('let &equalalways /= 1')
- eq(true, meths.nvim_get_option_value('equalalways', {}))
+ eq(true, api.nvim_get_option_value('equalalways', {}))
command('let &equalalways %= 1')
- eq(false, meths.nvim_get_option_value('equalalways', {}))
+ eq(false, api.nvim_get_option_value('equalalways', {}))
end)
end)
diff --git a/test/functional/vimscript/map_functions_spec.lua b/test/functional/vimscript/map_functions_spec.lua
index 9edf54898b..59d427ca90 100644
--- a/test/functional/vimscript/map_functions_spec.lua
+++ b/test/functional/vimscript/map_functions_spec.lua
@@ -7,8 +7,8 @@ local exec = helpers.exec
local exec_lua = helpers.exec_lua
local expect = helpers.expect
local feed = helpers.feed
-local funcs = helpers.funcs
-local meths = helpers.meths
+local fn = helpers.fn
+local api = helpers.api
local source = helpers.source
local command = helpers.command
local exec_capture = helpers.exec_capture
@@ -37,32 +37,32 @@ describe('maparg()', function()
it('returns a dictionary', function()
command('nnoremap foo bar')
- eq('bar', funcs.maparg('foo'))
- eq(foo_bar_map_table, funcs.maparg('foo', 'n', false, true))
+ eq('bar', fn.maparg('foo'))
+ eq(foo_bar_map_table, fn.maparg('foo', 'n', false, true))
end)
it('returns 1 for silent when <silent> is used', function()
command('nnoremap <silent> foo bar')
- eq(1, funcs.maparg('foo', 'n', false, true)['silent'])
+ eq(1, fn.maparg('foo', 'n', false, true)['silent'])
command('nnoremap baz bat')
- eq(0, funcs.maparg('baz', 'n', false, true)['silent'])
+ eq(0, fn.maparg('baz', 'n', false, true)['silent'])
end)
it('returns an empty string when no map is present', function()
- eq('', funcs.maparg('not a mapping'))
+ eq('', fn.maparg('not a mapping'))
end)
it('returns an empty dictionary when no map is present and dict is requested', function()
- eq({}, funcs.maparg('not a mapping', 'n', false, true))
+ eq({}, fn.maparg('not a mapping', 'n', false, true))
end)
it('returns the same value for noremap and <script>', function()
command('inoremap <script> hello world')
command('inoremap this that')
eq(
- funcs.maparg('hello', 'i', false, true)['noremap'],
- funcs.maparg('this', 'i', false, true)['noremap']
+ fn.maparg('hello', 'i', false, true)['noremap'],
+ fn.maparg('this', 'i', false, true)['noremap']
)
end)
@@ -72,11 +72,11 @@ describe('maparg()', function()
command('new')
command('new')
command('cnoremap <buffer> this that')
- eq(1, funcs.maparg('this', 'c', false, true)['buffer'])
+ eq(1, fn.maparg('this', 'c', false, true)['buffer'])
-- Global will return 0 always
command('nnoremap other another')
- eq(0, funcs.maparg('other', 'n', false, true)['buffer'])
+ eq(0, fn.maparg('other', 'n', false, true)['buffer'])
end)
it('returns script numbers', function()
@@ -87,8 +87,8 @@ describe('maparg()', function()
nnoremap fizz :call <SID>maparg_test_function()<CR>
]])
- eq(1, funcs.maparg('fizz', 'n', false, true)['sid'])
- eq('testing', meths.nvim_call_function('<SNR>1_maparg_test_function', {}))
+ eq(1, fn.maparg('fizz', 'n', false, true)['sid'])
+ eq('testing', api.nvim_call_function('<SNR>1_maparg_test_function', {}))
end)
it('works with <F12> and others', function()
@@ -103,7 +103,7 @@ describe('maparg()', function()
]])
eq(1, eval('g:maparg_test_var'))
- eq(':let g:maparg_test_var = 1<CR>', funcs.maparg('<F12>', 'n', false, true)['rhs'])
+ eq(':let g:maparg_test_var = 1<CR>', fn.maparg('<F12>', 'n', false, true)['rhs'])
end)
it('works with <expr>', function()
@@ -126,7 +126,7 @@ describe('maparg()', function()
]])
eq(1, eval('g:counter'))
- local map_dict = funcs.maparg('<C-L>', 'i', false, true)
+ local map_dict = fn.maparg('<C-L>', 'i', false, true)
eq(1, map_dict['expr'])
eq('i', map_dict['mode'])
end)
@@ -143,10 +143,10 @@ describe('maparg()', function()
nnoremap c` d
nnoremap e` f`
]]))
- eq(ac('b`'), funcs.maparg(ac('a')))
- eq(ac(''), funcs.maparg(ac('c')))
- eq(ac('d'), funcs.maparg(ac('c`')))
- eq(ac('f`'), funcs.maparg(ac('e`')))
+ eq(ac('b`'), fn.maparg(ac('a')))
+ eq(ac(''), fn.maparg(ac('c')))
+ eq(ac('d'), fn.maparg(ac('c`')))
+ eq(ac('f`'), fn.maparg(ac('e`')))
local function acmap(lhs, rhs)
return {
@@ -169,10 +169,10 @@ describe('maparg()', function()
}
end
- eq({}, funcs.maparg(ac('c'), 'n', 0, 1))
- eq(acmap('a', 'b`'), funcs.maparg(ac('a'), 'n', 0, 1))
- eq(acmap('c`', 'd'), funcs.maparg(ac('c`'), 'n', 0, 1))
- eq(acmap('e`', 'f`'), funcs.maparg(ac('e`'), 'n', 0, 1))
+ eq({}, fn.maparg(ac('c'), 'n', 0, 1))
+ eq(acmap('a', 'b`'), fn.maparg(ac('a'), 'n', 0, 1))
+ eq(acmap('c`', 'd'), fn.maparg(ac('c`'), 'n', 0, 1))
+ eq(acmap('e`', 'f`'), fn.maparg(ac('e`'), 'n', 0, 1))
end)
end)
@@ -180,34 +180,34 @@ describe('mapset()', function()
before_each(clear)
it('can restore mapping with backslash in lhs', function()
- meths.nvim_set_keymap('n', '\\ab', 'a', {})
+ api.nvim_set_keymap('n', '\\ab', 'a', {})
eq('\nn \\ab a', exec_capture('nmap \\ab'))
- local mapargs = funcs.maparg('\\ab', 'n', false, true)
- meths.nvim_set_keymap('n', '\\ab', 'b', {})
+ local mapargs = fn.maparg('\\ab', 'n', false, true)
+ api.nvim_set_keymap('n', '\\ab', 'b', {})
eq('\nn \\ab b', exec_capture('nmap \\ab'))
- funcs.mapset('n', false, mapargs)
+ fn.mapset('n', false, mapargs)
eq('\nn \\ab a', exec_capture('nmap \\ab'))
end)
it('can restore mapping description from the dict returned by maparg()', function()
- meths.nvim_set_keymap('n', 'lhs', 'rhs', { desc = 'map description' })
+ api.nvim_set_keymap('n', 'lhs', 'rhs', { desc = 'map description' })
eq('\nn lhs rhs\n map description', exec_capture('nmap lhs'))
- local mapargs = funcs.maparg('lhs', 'n', false, true)
- meths.nvim_set_keymap('n', 'lhs', 'rhs', { desc = 'MAP DESCRIPTION' })
+ local mapargs = fn.maparg('lhs', 'n', false, true)
+ api.nvim_set_keymap('n', 'lhs', 'rhs', { desc = 'MAP DESCRIPTION' })
eq('\nn lhs rhs\n MAP DESCRIPTION', exec_capture('nmap lhs'))
- funcs.mapset('n', false, mapargs)
+ fn.mapset('n', false, mapargs)
eq('\nn lhs rhs\n map description', exec_capture('nmap lhs'))
end)
it('can restore "replace_keycodes" from the dict returned by maparg()', function()
- meths.nvim_set_keymap('i', 'foo', [['<l' .. 't>']], { expr = true, replace_keycodes = true })
+ api.nvim_set_keymap('i', 'foo', [['<l' .. 't>']], { expr = true, replace_keycodes = true })
feed('Afoo')
expect('<')
- local mapargs = funcs.maparg('foo', 'i', false, true)
- meths.nvim_set_keymap('i', 'foo', [['<l' .. 't>']], { expr = true })
+ local mapargs = fn.maparg('foo', 'i', false, true)
+ api.nvim_set_keymap('i', 'foo', [['<l' .. 't>']], { expr = true })
feed('foo')
expect('<<lt>')
- funcs.mapset('i', false, mapargs)
+ fn.mapset('i', false, mapargs)
feed('foo')
expect('<<lt><')
end)
@@ -217,12 +217,12 @@ describe('mapset()', function()
eq('\ni foo * bar', exec_capture('iabbr foo'))
feed('ifoo ')
expect('bar ')
- local mapargs = funcs.maparg('foo', 'i', true, true)
+ local mapargs = fn.maparg('foo', 'i', true, true)
command('inoreabbr foo BAR')
eq('\ni foo * BAR', exec_capture('iabbr foo'))
feed('foo ')
expect('bar BAR ')
- funcs.mapset('i', true, mapargs)
+ fn.mapset('i', true, mapargs)
eq('\ni foo * bar', exec_capture('iabbr foo'))
feed('foo<Esc>')
expect('bar BAR bar')
diff --git a/test/functional/vimscript/match_functions_spec.lua b/test/functional/vimscript/match_functions_spec.lua
index 8092d140c8..3db612e472 100644
--- a/test/functional/vimscript/match_functions_spec.lua
+++ b/test/functional/vimscript/match_functions_spec.lua
@@ -3,7 +3,7 @@ local Screen = require('test.functional.ui.screen')
local eq = helpers.eq
local clear = helpers.clear
-local funcs = helpers.funcs
+local fn = helpers.fn
local command = helpers.command
local exc_exec = helpers.exc_exec
@@ -12,7 +12,7 @@ before_each(clear)
describe('setmatches()', function()
it('correctly handles case when both group and pattern entries are numbers', function()
command('hi def link 1 PreProc')
- eq(0, funcs.setmatches({ { group = 1, pattern = 2, id = 3, priority = 4 } }))
+ eq(0, fn.setmatches({ { group = 1, pattern = 2, id = 3, priority = 4 } }))
eq({
{
group = '1',
@@ -20,8 +20,8 @@ describe('setmatches()', function()
id = 3,
priority = 4,
},
- }, funcs.getmatches())
- eq(0, funcs.setmatches({ { group = 1, pattern = 2, id = 3, priority = 4, conceal = 5 } }))
+ }, fn.getmatches())
+ eq(0, fn.setmatches({ { group = 1, pattern = 2, id = 3, priority = 4, conceal = 5 } }))
eq({
{
group = '1',
@@ -30,10 +30,10 @@ describe('setmatches()', function()
priority = 4,
conceal = '5',
},
- }, funcs.getmatches())
+ }, fn.getmatches())
eq(
0,
- funcs.setmatches({
+ fn.setmatches({
{ group = 1, pos1 = { 2 }, pos2 = { 6 }, id = 3, priority = 4, conceal = 5 },
})
)
@@ -46,21 +46,21 @@ describe('setmatches()', function()
priority = 4,
conceal = '5',
},
- }, funcs.getmatches())
+ }, fn.getmatches())
end)
it('does not fail if highlight group is not defined', function()
- eq(0, funcs.setmatches { { group = 1, pattern = 2, id = 3, priority = 4 } })
- eq({ { group = '1', pattern = '2', id = 3, priority = 4 } }, funcs.getmatches())
+ eq(0, fn.setmatches { { group = 1, pattern = 2, id = 3, priority = 4 } })
+ eq({ { group = '1', pattern = '2', id = 3, priority = 4 } }, fn.getmatches())
eq(
0,
- funcs.setmatches {
+ fn.setmatches {
{ group = 1, pos1 = { 2 }, pos2 = { 6 }, id = 3, priority = 4, conceal = 5 },
}
)
eq(
{ { group = '1', pos1 = { 2 }, pos2 = { 6 }, id = 3, priority = 4, conceal = '5' } },
- funcs.getmatches()
+ fn.getmatches()
)
end)
end)
@@ -68,7 +68,7 @@ end)
describe('matchadd()', function()
it('correctly works when first two arguments and conceal are numbers at once', function()
command('hi def link 1 PreProc')
- eq(4, funcs.matchadd(1, 2, 3, 4, { conceal = 5 }))
+ eq(4, fn.matchadd(1, 2, 3, 4, { conceal = 5 }))
eq({
{
group = '1',
@@ -77,7 +77,7 @@ describe('matchadd()', function()
id = 4,
conceal = '5',
},
- }, funcs.getmatches())
+ }, fn.getmatches())
end)
end)
@@ -99,7 +99,7 @@ describe('matchaddpos()', function()
end)
it('works with 0 lnum', function()
command('hi clear PreProc')
- eq(4, funcs.matchaddpos('PreProc', { 1 }, 3, 4))
+ eq(4, fn.matchaddpos('PreProc', { 1 }, 3, 4))
eq({
{
group = 'PreProc',
@@ -107,9 +107,9 @@ describe('matchaddpos()', function()
priority = 3,
id = 4,
},
- }, funcs.getmatches())
- funcs.matchdelete(4)
- eq(4, funcs.matchaddpos('PreProc', { { 0 }, 1 }, 3, 4))
+ }, fn.getmatches())
+ fn.matchdelete(4)
+ eq(4, fn.matchaddpos('PreProc', { { 0 }, 1 }, 3, 4))
eq({
{
group = 'PreProc',
@@ -117,9 +117,9 @@ describe('matchaddpos()', function()
priority = 3,
id = 4,
},
- }, funcs.getmatches())
- funcs.matchdelete(4)
- eq(4, funcs.matchaddpos('PreProc', { 0, 1 }, 3, 4))
+ }, fn.getmatches())
+ fn.matchdelete(4)
+ eq(4, fn.matchaddpos('PreProc', { 0, 1 }, 3, 4))
eq({
{
group = 'PreProc',
@@ -127,11 +127,11 @@ describe('matchaddpos()', function()
priority = 3,
id = 4,
},
- }, funcs.getmatches())
+ }, fn.getmatches())
end)
it('works with negative numbers', function()
command('hi clear PreProc')
- eq(4, funcs.matchaddpos('PreProc', { -10, 1 }, 3, 4))
+ eq(4, fn.matchaddpos('PreProc', { -10, 1 }, 3, 4))
eq({
{
group = 'PreProc',
@@ -139,9 +139,9 @@ describe('matchaddpos()', function()
priority = 3,
id = 4,
},
- }, funcs.getmatches())
- funcs.matchdelete(4)
- eq(4, funcs.matchaddpos('PreProc', { { -10 }, 1 }, 3, 4))
+ }, fn.getmatches())
+ fn.matchdelete(4)
+ eq(4, fn.matchaddpos('PreProc', { { -10 }, 1 }, 3, 4))
eq({
{
group = 'PreProc',
@@ -149,9 +149,9 @@ describe('matchaddpos()', function()
priority = 3,
id = 4,
},
- }, funcs.getmatches())
- funcs.matchdelete(4)
- eq(4, funcs.matchaddpos('PreProc', { { 2, -1 }, 1 }, 3, 4))
+ }, fn.getmatches())
+ fn.matchdelete(4)
+ eq(4, fn.matchaddpos('PreProc', { { 2, -1 }, 1 }, 3, 4))
eq({
{
group = 'PreProc',
@@ -159,9 +159,9 @@ describe('matchaddpos()', function()
priority = 3,
id = 4,
},
- }, funcs.getmatches())
- funcs.matchdelete(4)
- eq(4, funcs.matchaddpos('PreProc', { { 2, 0, -1 }, 1 }, 3, 4))
+ }, fn.getmatches())
+ fn.matchdelete(4)
+ eq(4, fn.matchaddpos('PreProc', { { 2, 0, -1 }, 1 }, 3, 4))
eq({
{
group = 'PreProc',
@@ -169,14 +169,14 @@ describe('matchaddpos()', function()
priority = 3,
id = 4,
},
- }, funcs.getmatches())
+ }, fn.getmatches())
end)
it('works with zero length', function()
local screen = Screen.new(40, 5)
screen:attach()
- funcs.setline(1, 'abcdef')
+ fn.setline(1, 'abcdef')
command('hi PreProc guifg=Red')
- eq(4, funcs.matchaddpos('PreProc', { { 1, 2, 0 } }, 3, 4))
+ eq(4, fn.matchaddpos('PreProc', { { 1, 2, 0 } }, 3, 4))
eq({
{
group = 'PreProc',
@@ -184,7 +184,7 @@ describe('matchaddpos()', function()
priority = 3,
id = 4,
},
- }, funcs.getmatches())
+ }, fn.getmatches())
screen:expect(
[[
^a{1:b}cdef |
diff --git a/test/functional/vimscript/minmax_functions_spec.lua b/test/functional/vimscript/minmax_functions_spec.lua
index a618782f88..c4a986bc8c 100644
--- a/test/functional/vimscript/minmax_functions_spec.lua
+++ b/test/functional/vimscript/minmax_functions_spec.lua
@@ -4,7 +4,7 @@ local eq = helpers.eq
local eval = helpers.eval
local command = helpers.command
local clear = helpers.clear
-local funcs = helpers.funcs
+local fn = helpers.fn
local pcall_err = helpers.pcall_err
before_each(clear)
@@ -30,12 +30,12 @@ for _, func in ipairs({ 'min', 'max' }) do
end
end)
it('works with arrays/dictionaries with zero items', function()
- eq(0, funcs[func]({}))
+ eq(0, fn[func]({}))
eq(0, eval(func .. '({})'))
end)
it('works with arrays/dictionaries with one item', function()
- eq(5, funcs[func]({ 5 }))
- eq(5, funcs[func]({ test = 5 }))
+ eq(5, fn[func]({ 5 }))
+ eq(5, fn[func]({ test = 5 }))
end)
it('works with NULL arrays/dictionaries', function()
eq(0, eval(func .. '(v:_null_list)'))
diff --git a/test/functional/vimscript/msgpack_functions_spec.lua b/test/functional/vimscript/msgpack_functions_spec.lua
index b6980befd9..609a706155 100644
--- a/test/functional/vimscript/msgpack_functions_spec.lua
+++ b/test/functional/vimscript/msgpack_functions_spec.lua
@@ -1,9 +1,9 @@
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
-local funcs = helpers.funcs
+local fn = helpers.fn
local eval, eq = helpers.eval, helpers.eq
local command = helpers.command
-local meths = helpers.meths
+local api = helpers.api
local exc_exec = helpers.exc_exec
local is_os = helpers.is_os
@@ -12,7 +12,7 @@ describe('msgpack*() functions', function()
local obj_test = function(msg, obj)
it(msg, function()
- meths.nvim_set_var('obj', obj)
+ api.nvim_set_var('obj', obj)
eq(obj, eval('msgpackparse(msgpackdump(g:obj))'))
eq(obj, eval('msgpackparse(msgpackdump(g:obj, "B"))'))
end)
@@ -406,7 +406,7 @@ local parse_eq = function(expect, list_arg)
.. blobstr(list_arg):gsub('(.)', function(c)
return ('%.2x'):format(c:byte())
end)
- eq(expect, funcs.msgpackparse(list_arg))
+ eq(expect, fn.msgpackparse(list_arg))
command('let g:parsed = msgpackparse(' .. blob_expr .. ')')
eq(expect, eval('g:parsed'))
end
diff --git a/test/functional/vimscript/null_spec.lua b/test/functional/vimscript/null_spec.lua
index 2e96ccfead..805cd13844 100644
--- a/test/functional/vimscript/null_spec.lua
+++ b/test/functional/vimscript/null_spec.lua
@@ -3,20 +3,20 @@ local helpers = require('test.functional.helpers')(after_each)
local exc_exec = helpers.exc_exec
local command = helpers.command
local clear = helpers.clear
-local meths = helpers.meths
-local funcs = helpers.funcs
+local api = helpers.api
+local fn = helpers.fn
local eq = helpers.eq
local function redir_exec(cmd)
- meths.nvim_set_var('__redir_exec_cmd', cmd)
+ api.nvim_set_var('__redir_exec_cmd', cmd)
command([[
redir => g:__redir_exec_output
silent! execute g:__redir_exec_cmd
redir END
]])
- local ret = meths.nvim_get_var('__redir_exec_output')
- meths.nvim_del_var('__redir_exec_output')
- meths.nvim_del_var('__redir_exec_cmd')
+ local ret = api.nvim_get_var('__redir_exec_output')
+ api.nvim_del_var('__redir_exec_output')
+ api.nvim_del_var('__redir_exec_cmd')
return ret
end
@@ -41,9 +41,9 @@ describe('NULL', function()
it(name, function()
eq((err == 0) and '' or ('\n' .. err), redir_exec('let g:_var = ' .. expr))
if val == nil then
- eq(0, funcs.exists('g:_var'))
+ eq(0, fn.exists('g:_var'))
else
- eq(val, meths.nvim_get_var('_var'))
+ eq(val, api.nvim_get_var('_var'))
end
if after ~= nil then
after()
@@ -71,10 +71,10 @@ describe('NULL', function()
null_expr_test('is not locked', 'islocked("v:_null_list")', 0, 0)
null_test('is accepted by :for', 'for x in L|throw x|endfor', 0)
null_expr_test('does not crash append()', 'append(0, L)', 0, 0, function()
- eq({ '' }, meths.nvim_buf_get_lines(0, 0, -1, false))
+ eq({ '' }, api.nvim_buf_get_lines(0, 0, -1, false))
end)
null_expr_test('does not crash setline()', 'setline(1, L)', 0, 0, function()
- eq({ '' }, meths.nvim_buf_get_lines(0, 0, -1, false))
+ eq({ '' }, api.nvim_buf_get_lines(0, 0, -1, false))
end)
null_expr_test('is identical to itself', 'L is L', 0, 1)
null_expr_test('can be sliced', 'L[:]', 0, {})
@@ -183,7 +183,7 @@ describe('NULL', function()
0,
'',
function()
- eq({ '' }, meths.nvim_buf_get_lines(0, 0, -1, false))
+ eq({ '' }, api.nvim_buf_get_lines(0, 0, -1, false))
end
)
null_expr_test('is accepted by setmatches()', 'setmatches(L)', 0, 0)
diff --git a/test/functional/vimscript/printf_spec.lua b/test/functional/vimscript/printf_spec.lua
index f9a7199f11..4fa4ea7f4c 100644
--- a/test/functional/vimscript/printf_spec.lua
+++ b/test/functional/vimscript/printf_spec.lua
@@ -3,56 +3,56 @@ local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local eq = helpers.eq
local eval = helpers.eval
-local funcs = helpers.funcs
-local meths = helpers.meths
+local fn = helpers.fn
+local api = helpers.api
local exc_exec = helpers.exc_exec
describe('printf()', function()
before_each(clear)
it('works with zero and %b', function()
- eq('0', funcs.printf('%lb', 0))
- eq('0', funcs.printf('%llb', 0))
- eq('0', funcs.printf('%zb', 0))
+ eq('0', fn.printf('%lb', 0))
+ eq('0', fn.printf('%llb', 0))
+ eq('0', fn.printf('%zb', 0))
end)
it('works with one and %b', function()
- eq('1', funcs.printf('%b', 1))
- eq('1', funcs.printf('%lb', 1))
- eq('1', funcs.printf('%llb', 1))
- eq('1', funcs.printf('%zb', 1))
+ eq('1', fn.printf('%b', 1))
+ eq('1', fn.printf('%lb', 1))
+ eq('1', fn.printf('%llb', 1))
+ eq('1', fn.printf('%zb', 1))
end)
it('works with 0xff and %b', function()
- eq('11111111', funcs.printf('%b', 0xff))
- eq('11111111', funcs.printf('%lb', 0xff))
- eq('11111111', funcs.printf('%llb', 0xff))
- eq('11111111', funcs.printf('%zb', 0xff))
+ eq('11111111', fn.printf('%b', 0xff))
+ eq('11111111', fn.printf('%lb', 0xff))
+ eq('11111111', fn.printf('%llb', 0xff))
+ eq('11111111', fn.printf('%zb', 0xff))
end)
it('accepts width modifier with %b', function()
- eq(' 1', funcs.printf('%3b', 1))
+ eq(' 1', fn.printf('%3b', 1))
end)
it('accepts prefix modifier with %b', function()
- eq('0b1', funcs.printf('%#b', 1))
+ eq('0b1', fn.printf('%#b', 1))
end)
it('writes capital B with %B', function()
- eq('0B1', funcs.printf('%#B', 1))
+ eq('0B1', fn.printf('%#B', 1))
end)
it('accepts prefix, zero-fill and width modifiers with %b', function()
- eq('0b001', funcs.printf('%#05b', 1))
+ eq('0b001', fn.printf('%#05b', 1))
end)
it('accepts prefix and width modifiers with %b', function()
- eq(' 0b1', funcs.printf('%#5b', 1))
+ eq(' 0b1', fn.printf('%#5b', 1))
end)
it('does not write prefix for zero with prefix and width modifier used with %b', function()
- eq(' 0', funcs.printf('%#5b', 0))
+ eq(' 0', fn.printf('%#5b', 0))
end)
it('accepts precision modifier with %b', function()
- eq('00000', funcs.printf('%.5b', 0))
+ eq('00000', fn.printf('%.5b', 0))
end)
it('accepts all modifiers with %b at once', function()
-- zero-fill modifier is ignored when used with left-align
-- force-sign and add-blank are ignored
-- use-grouping-characters modifier is ignored always
- eq('0b00011 ', funcs.printf("% '+#0-10.5b", 3))
+ eq('0b00011 ', fn.printf("% '+#0-10.5b", 3))
end)
it('errors out when %b modifier is used for a list', function()
eq('Vim(call):E745: Using a List as a Number', exc_exec('call printf("%b", [])'))
@@ -65,12 +65,12 @@ describe('printf()', function()
local seen_rets = {}
-- Collect all args in an array to avoid possible allocation of the same
-- address after freeing unreferenced values.
- meths.nvim_set_var('__args', {})
+ api.nvim_set_var('__args', {})
local function check_printf(expr, is_null)
eq(0, exc_exec('call add(__args, ' .. expr .. ')'))
eq(0, exc_exec('let __result = printf("%p", __args[-1])'))
local id_ret = eval('id(__args[-1])')
- eq(id_ret, meths.nvim_get_var('__result'))
+ eq(id_ret, api.nvim_get_var('__result'))
if is_null then
if null_ret then
eq(null_ret, id_ret)
@@ -81,7 +81,7 @@ describe('printf()', function()
eq(nil, seen_rets[id_ret])
seen_rets[id_ret] = expr
end
- meths.nvim_del_var('__result')
+ api.nvim_del_var('__result')
end
check_printf('v:_null_list', true)
check_printf('v:_null_dict', true)
diff --git a/test/functional/vimscript/reltime_spec.lua b/test/functional/vimscript/reltime_spec.lua
index 29a57ad8ff..7cdb78e4ce 100644
--- a/test/functional/vimscript/reltime_spec.lua
+++ b/test/functional/vimscript/reltime_spec.lua
@@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')(after_each)
local clear, eq, ok = helpers.clear, helpers.eq, helpers.ok
-local neq, command, funcs = helpers.neq, helpers.command, helpers.funcs
-local reltime, reltimestr, reltimefloat = funcs.reltime, funcs.reltimestr, funcs.reltimefloat
+local neq, command, fn = helpers.neq, helpers.command, helpers.fn
+local reltime, reltimestr, reltimefloat = fn.reltime, fn.reltimestr, fn.reltimefloat
describe('reltimestr(), reltimefloat()', function()
before_each(clear)
diff --git a/test/functional/vimscript/screenchar_spec.lua b/test/functional/vimscript/screenchar_spec.lua
index f24aa87ff4..48b6893865 100644
--- a/test/functional/vimscript/screenchar_spec.lua
+++ b/test/functional/vimscript/screenchar_spec.lua
@@ -1,6 +1,6 @@
local helpers = require('test.functional.helpers')(after_each)
local clear, eq, neq = helpers.clear, helpers.eq, helpers.neq
-local command, meths, funcs = helpers.command, helpers.meths, helpers.funcs
+local command, api, fn = helpers.command, helpers.api, helpers.fn
local tbl_deep_extend = vim.tbl_deep_extend
-- Set up two overlapping floating windows
@@ -14,15 +14,15 @@ local setup_floating_windows = function()
border = 'none',
}
- local bufnr_1 = meths.nvim_create_buf(false, true)
- meths.nvim_buf_set_lines(bufnr_1, 0, -1, true, { 'aa' })
+ local bufnr_1 = api.nvim_create_buf(false, true)
+ api.nvim_buf_set_lines(bufnr_1, 0, -1, true, { 'aa' })
local opts_1 = tbl_deep_extend('force', { row = 0, col = 0, zindex = 11 }, base_opts)
- meths.nvim_open_win(bufnr_1, false, opts_1)
+ api.nvim_open_win(bufnr_1, false, opts_1)
- local bufnr_2 = meths.nvim_create_buf(false, true)
- meths.nvim_buf_set_lines(bufnr_2, 0, -1, true, { 'bb' })
+ local bufnr_2 = api.nvim_create_buf(false, true)
+ api.nvim_buf_set_lines(bufnr_2, 0, -1, true, { 'bb' })
local opts_2 = tbl_deep_extend('force', { row = 0, col = 1, zindex = 10 }, base_opts)
- meths.nvim_open_win(bufnr_2, false, opts_2)
+ api.nvim_open_win(bufnr_2, false, opts_2)
command('redraw')
end
@@ -32,38 +32,38 @@ describe('screenchar() and family respect floating windows', function()
clear()
-- These commands result into visible text `aabc`.
-- `aab` - from floating windows, `c` - from text in regular window.
- meths.nvim_buf_set_lines(0, 0, -1, true, { 'cccc' })
+ api.nvim_buf_set_lines(0, 0, -1, true, { 'cccc' })
setup_floating_windows()
end)
it('screenattr()', function()
- local attr_1 = funcs.screenattr(1, 1)
- local attr_2 = funcs.screenattr(1, 2)
- local attr_3 = funcs.screenattr(1, 3)
- local attr_4 = funcs.screenattr(1, 4)
+ local attr_1 = fn.screenattr(1, 1)
+ local attr_2 = fn.screenattr(1, 2)
+ local attr_3 = fn.screenattr(1, 3)
+ local attr_4 = fn.screenattr(1, 4)
eq(attr_1, attr_2)
eq(attr_1, attr_3)
neq(attr_1, attr_4)
end)
it('screenchar()', function()
- eq(97, funcs.screenchar(1, 1))
- eq(97, funcs.screenchar(1, 2))
- eq(98, funcs.screenchar(1, 3))
- eq(99, funcs.screenchar(1, 4))
+ eq(97, fn.screenchar(1, 1))
+ eq(97, fn.screenchar(1, 2))
+ eq(98, fn.screenchar(1, 3))
+ eq(99, fn.screenchar(1, 4))
end)
it('screenchars()', function()
- eq({ 97 }, funcs.screenchars(1, 1))
- eq({ 97 }, funcs.screenchars(1, 2))
- eq({ 98 }, funcs.screenchars(1, 3))
- eq({ 99 }, funcs.screenchars(1, 4))
+ eq({ 97 }, fn.screenchars(1, 1))
+ eq({ 97 }, fn.screenchars(1, 2))
+ eq({ 98 }, fn.screenchars(1, 3))
+ eq({ 99 }, fn.screenchars(1, 4))
end)
it('screenstring()', function()
- eq('a', funcs.screenstring(1, 1))
- eq('a', funcs.screenstring(1, 2))
- eq('b', funcs.screenstring(1, 3))
- eq('c', funcs.screenstring(1, 4))
+ eq('a', fn.screenstring(1, 1))
+ eq('a', fn.screenstring(1, 2))
+ eq('b', fn.screenstring(1, 3))
+ eq('c', fn.screenstring(1, 4))
end)
end)
diff --git a/test/functional/vimscript/screenpos_spec.lua b/test/functional/vimscript/screenpos_spec.lua
index 7edfcac28b..b951d830a6 100644
--- a/test/functional/vimscript/screenpos_spec.lua
+++ b/test/functional/vimscript/screenpos_spec.lua
@@ -1,6 +1,6 @@
local helpers = require('test.functional.helpers')(after_each)
-local clear, eq, meths = helpers.clear, helpers.eq, helpers.meths
-local command, funcs = helpers.command, helpers.funcs
+local clear, eq, api = helpers.clear, helpers.eq, helpers.api
+local command, fn = helpers.command, helpers.fn
local feed = helpers.feed
before_each(clear)
@@ -18,33 +18,33 @@ describe('screenpos() function', function()
border = 'none',
focusable = 1,
}
- local float = meths.nvim_open_win(meths.nvim_create_buf(false, true), false, opts)
+ local float = api.nvim_open_win(api.nvim_create_buf(false, true), false, opts)
command('redraw')
- eq({ row = 7, col = 9, endcol = 9, curscol = 9 }, funcs.screenpos(float, 1, 1))
+ eq({ row = 7, col = 9, endcol = 9, curscol = 9 }, fn.screenpos(float, 1, 1))
-- only left border
opts.border = { '', '', '', '', '', '', '', '|' }
- meths.nvim_win_set_config(float, opts)
+ api.nvim_win_set_config(float, opts)
command('redraw')
- eq({ row = 7, col = 10, endcol = 10, curscol = 10 }, funcs.screenpos(float, 1, 1))
+ eq({ row = 7, col = 10, endcol = 10, curscol = 10 }, fn.screenpos(float, 1, 1))
-- only top border
opts.border = { '', '_', '', '', '', '', '', '' }
- meths.nvim_win_set_config(float, opts)
+ api.nvim_win_set_config(float, opts)
command('redraw')
- eq({ row = 8, col = 9, endcol = 9, curscol = 9 }, funcs.screenpos(float, 1, 1))
+ eq({ row = 8, col = 9, endcol = 9, curscol = 9 }, fn.screenpos(float, 1, 1))
-- both left and top border
opts.border = 'single'
- meths.nvim_win_set_config(float, opts)
+ api.nvim_win_set_config(float, opts)
command('redraw')
- eq({ row = 8, col = 10, endcol = 10, curscol = 10 }, funcs.screenpos(float, 1, 1))
+ eq({ row = 8, col = 10, endcol = 10, curscol = 10 }, fn.screenpos(float, 1, 1))
end)
it('works for folded line with virt_lines attached to line above', function()
- meths.nvim_buf_set_lines(0, 0, -1, true, { 'aaa', 'bbb', 'ccc', 'ddd' })
- local ns = meths.nvim_create_namespace('')
- meths.nvim_buf_set_extmark(
+ api.nvim_buf_set_lines(0, 0, -1, true, { 'aaa', 'bbb', 'ccc', 'ddd' })
+ local ns = api.nvim_create_namespace('')
+ api.nvim_buf_set_extmark(
0,
ns,
0,
@@ -52,28 +52,28 @@ describe('screenpos() function', function()
{ virt_lines = { { { 'abb' } }, { { 'acc' } }, { { 'add' } } } }
)
command('2,3fold')
- eq({ row = 5, col = 1, endcol = 1, curscol = 1 }, funcs.screenpos(0, 2, 1))
- eq({ row = 5, col = 1, endcol = 1, curscol = 1 }, funcs.screenpos(0, 3, 1))
- eq({ row = 6, col = 1, endcol = 1, curscol = 1 }, funcs.screenpos(0, 4, 1))
+ eq({ row = 5, col = 1, endcol = 1, curscol = 1 }, fn.screenpos(0, 2, 1))
+ eq({ row = 5, col = 1, endcol = 1, curscol = 1 }, fn.screenpos(0, 3, 1))
+ eq({ row = 6, col = 1, endcol = 1, curscol = 1 }, fn.screenpos(0, 4, 1))
feed('<C-E>')
- eq({ row = 4, col = 1, endcol = 1, curscol = 1 }, funcs.screenpos(0, 2, 1))
- eq({ row = 4, col = 1, endcol = 1, curscol = 1 }, funcs.screenpos(0, 3, 1))
- eq({ row = 5, col = 1, endcol = 1, curscol = 1 }, funcs.screenpos(0, 4, 1))
+ eq({ row = 4, col = 1, endcol = 1, curscol = 1 }, fn.screenpos(0, 2, 1))
+ eq({ row = 4, col = 1, endcol = 1, curscol = 1 }, fn.screenpos(0, 3, 1))
+ eq({ row = 5, col = 1, endcol = 1, curscol = 1 }, fn.screenpos(0, 4, 1))
feed('<C-E>')
- eq({ row = 3, col = 1, endcol = 1, curscol = 1 }, funcs.screenpos(0, 2, 1))
- eq({ row = 3, col = 1, endcol = 1, curscol = 1 }, funcs.screenpos(0, 3, 1))
- eq({ row = 4, col = 1, endcol = 1, curscol = 1 }, funcs.screenpos(0, 4, 1))
+ eq({ row = 3, col = 1, endcol = 1, curscol = 1 }, fn.screenpos(0, 2, 1))
+ eq({ row = 3, col = 1, endcol = 1, curscol = 1 }, fn.screenpos(0, 3, 1))
+ eq({ row = 4, col = 1, endcol = 1, curscol = 1 }, fn.screenpos(0, 4, 1))
feed('<C-E>')
- eq({ row = 2, col = 1, endcol = 1, curscol = 1 }, funcs.screenpos(0, 2, 1))
- eq({ row = 2, col = 1, endcol = 1, curscol = 1 }, funcs.screenpos(0, 3, 1))
- eq({ row = 3, col = 1, endcol = 1, curscol = 1 }, funcs.screenpos(0, 4, 1))
+ eq({ row = 2, col = 1, endcol = 1, curscol = 1 }, fn.screenpos(0, 2, 1))
+ eq({ row = 2, col = 1, endcol = 1, curscol = 1 }, fn.screenpos(0, 3, 1))
+ eq({ row = 3, col = 1, endcol = 1, curscol = 1 }, fn.screenpos(0, 4, 1))
feed('<C-E>')
- eq({ row = 1, col = 1, endcol = 1, curscol = 1 }, funcs.screenpos(0, 2, 1))
- eq({ row = 1, col = 1, endcol = 1, curscol = 1 }, funcs.screenpos(0, 3, 1))
- eq({ row = 2, col = 1, endcol = 1, curscol = 1 }, funcs.screenpos(0, 4, 1))
+ eq({ row = 1, col = 1, endcol = 1, curscol = 1 }, fn.screenpos(0, 2, 1))
+ eq({ row = 1, col = 1, endcol = 1, curscol = 1 }, fn.screenpos(0, 3, 1))
+ eq({ row = 2, col = 1, endcol = 1, curscol = 1 }, fn.screenpos(0, 4, 1))
end)
end)
diff --git a/test/functional/vimscript/server_spec.lua b/test/functional/vimscript/server_spec.lua
index 9d2bfbafc8..360fcf0dfe 100644
--- a/test/functional/vimscript/server_spec.lua
+++ b/test/functional/vimscript/server_spec.lua
@@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')(after_each)
local assert_log = helpers.assert_log
local eq, neq, eval = helpers.eq, helpers.neq, helpers.eval
-local clear, funcs, meths = helpers.clear, helpers.funcs, helpers.meths
+local clear, fn, api = helpers.clear, helpers.fn, helpers.api
local ok = helpers.ok
local matches = helpers.matches
local pcall_err = helpers.pcall_err
@@ -11,8 +11,8 @@ local is_os = helpers.is_os
local testlog = 'Xtest-server-log'
local function clear_serverlist()
- for _, server in pairs(funcs.serverlist()) do
- funcs.serverstop(server)
+ for _, server in pairs(fn.serverlist()) do
+ fn.serverstop(server)
end
end
@@ -25,9 +25,9 @@ describe('server', function()
local dir = 'Xtest_xdg_run'
mkdir(dir)
clear({ env = { XDG_RUNTIME_DIR = dir } })
- matches(dir, funcs.stdpath('run'))
+ matches(dir, fn.stdpath('run'))
if not is_os('win') then
- matches(dir, funcs.serverstart())
+ matches(dir, fn.serverstart())
end
end)
@@ -45,37 +45,37 @@ describe('server', function()
clear({ env = { NVIM_LISTEN_ADDRESS = '.' } })
-- Cleared on startup.
eq('', eval('$NVIM_LISTEN_ADDRESS'))
- local servers = funcs.serverlist()
+ local servers = fn.serverlist()
eq(1, #servers)
ok(string.len(servers[1]) > 4) -- "~/.local/state/nvim…/…" or "\\.\pipe\…"
end)
it('sets v:servername at startup or if all servers were stopped', function()
clear()
- local initial_server = meths.nvim_get_vvar('servername')
+ local initial_server = api.nvim_get_vvar('servername')
assert(initial_server ~= nil and initial_server:len() > 0, 'v:servername was not initialized')
-- v:servername is readonly so we cannot unset it--but we can test that it
-- does not get set again thereafter.
- local s = funcs.serverstart()
+ local s = fn.serverstart()
assert(s ~= nil and s:len() > 0, 'serverstart() returned empty')
neq(initial_server, s)
-- serverstop() does _not_ modify v:servername...
- eq(1, funcs.serverstop(s))
- eq(initial_server, meths.nvim_get_vvar('servername'))
+ eq(1, fn.serverstop(s))
+ eq(initial_server, api.nvim_get_vvar('servername'))
-- ...unless we stop _all_ servers.
- eq(1, funcs.serverstop(funcs.serverlist()[1]))
- eq('', meths.nvim_get_vvar('servername'))
+ eq(1, fn.serverstop(fn.serverlist()[1]))
+ eq('', api.nvim_get_vvar('servername'))
-- v:servername and $NVIM take the next available server.
local servername = (
is_os('win') and [[\\.\pipe\Xtest-functional-server-pipe]]
or './Xtest-functional-server-socket'
)
- funcs.serverstart(servername)
- eq(servername, meths.nvim_get_vvar('servername'))
+ fn.serverstart(servername)
+ eq(servername, api.nvim_get_vvar('servername'))
-- Not set in the current process, only in children.
eq('', eval('$NVIM'))
end)
@@ -96,50 +96,47 @@ describe('server', function()
NVIM_LISTEN_ADDRESS = '.',
} }
clear_serverlist()
- eq({}, funcs.serverlist())
+ eq({}, fn.serverlist())
- local s = funcs.serverstart('127.0.0.1:0') -- assign random port
+ local s = fn.serverstart('127.0.0.1:0') -- assign random port
if #s > 0 then
assert(string.match(s, '127.0.0.1:%d+'))
- eq(s, funcs.serverlist()[1])
+ eq(s, fn.serverlist()[1])
clear_serverlist()
end
- s = funcs.serverstart('127.0.0.1:') -- assign random port
+ s = fn.serverstart('127.0.0.1:') -- assign random port
if #s > 0 then
assert(string.match(s, '127.0.0.1:%d+'))
- eq(s, funcs.serverlist()[1])
+ eq(s, fn.serverlist()[1])
clear_serverlist()
end
local expected = {}
local v4 = '127.0.0.1:12345'
- local status, _ = pcall(funcs.serverstart, v4)
+ local status, _ = pcall(fn.serverstart, v4)
if status then
table.insert(expected, v4)
- pcall(funcs.serverstart, v4) -- exists already; ignore
+ pcall(fn.serverstart, v4) -- exists already; ignore
assert_log('Failed to start server: address already in use: 127%.0%.0%.1', testlog, 10)
end
local v6 = '::1:12345'
- status, _ = pcall(funcs.serverstart, v6)
+ status, _ = pcall(fn.serverstart, v6)
if status then
table.insert(expected, v6)
- pcall(funcs.serverstart, v6) -- exists already; ignore
+ pcall(fn.serverstart, v6) -- exists already; ignore
assert_log('Failed to start server: address already in use: ::1', testlog, 10)
end
- eq(expected, funcs.serverlist())
+ eq(expected, fn.serverlist())
clear_serverlist()
-- Address without slashes is a "name" which is appended to a generated path. #8519
- matches([[.*[/\\]xtest1%.2%.3%.4[^/\\]*]], funcs.serverstart('xtest1.2.3.4'))
+ matches([[.*[/\\]xtest1%.2%.3%.4[^/\\]*]], fn.serverstart('xtest1.2.3.4'))
clear_serverlist()
- eq(
- 'Vim:Failed to start server: invalid argument',
- pcall_err(funcs.serverstart, '127.0.0.1:65536')
- ) -- invalid port
- eq({}, funcs.serverlist())
+ eq('Vim:Failed to start server: invalid argument', pcall_err(fn.serverstart, '127.0.0.1:65536')) -- invalid port
+ eq({}, fn.serverlist())
end)
it('serverlist() returns the list of servers', function()
@@ -175,20 +172,20 @@ describe('startup --listen', function()
clear()
local cmd = { unpack(helpers.nvim_argv) }
table.insert(cmd, '--listen')
- matches('nvim.*: Argument missing after: "%-%-listen"', funcs.system(cmd))
+ matches('nvim.*: Argument missing after: "%-%-listen"', fn.system(cmd))
cmd = { unpack(helpers.nvim_argv) }
table.insert(cmd, '--listen2')
- matches('nvim.*: Garbage after option argument: "%-%-listen2"', funcs.system(cmd))
+ matches('nvim.*: Garbage after option argument: "%-%-listen2"', fn.system(cmd))
end)
it('sets v:servername, overrides $NVIM_LISTEN_ADDRESS', function()
local addr = (is_os('win') and [[\\.\pipe\Xtest-listen-pipe]] or './Xtest-listen-pipe')
clear({ env = { NVIM_LISTEN_ADDRESS = './Xtest-env-pipe' }, args = { '--listen', addr } })
- eq(addr, meths.nvim_get_vvar('servername'))
+ eq(addr, api.nvim_get_vvar('servername'))
-- Address without slashes is a "name" which is appended to a generated path. #8519
clear({ args = { '--listen', 'test-name' } })
- matches([[.*[/\\]test%-name[^/\\]*]], meths.nvim_get_vvar('servername'))
+ matches([[.*[/\\]test%-name[^/\\]*]], api.nvim_get_vvar('servername'))
end)
end)
diff --git a/test/functional/vimscript/setpos_spec.lua b/test/functional/vimscript/setpos_spec.lua
index 15ab76e78e..a26e48f469 100644
--- a/test/functional/vimscript/setpos_spec.lua
+++ b/test/functional/vimscript/setpos_spec.lua
@@ -1,6 +1,6 @@
local helpers = require('test.functional.helpers')(after_each)
-local setpos = helpers.funcs.setpos
-local getpos = helpers.funcs.getpos
+local setpos = helpers.fn.setpos
+local getpos = helpers.fn.getpos
local insert = helpers.insert
local clear = helpers.clear
local command = helpers.command
diff --git a/test/functional/vimscript/sort_spec.lua b/test/functional/vimscript/sort_spec.lua
index 25242791c2..bd3d0da146 100644
--- a/test/functional/vimscript/sort_spec.lua
+++ b/test/functional/vimscript/sort_spec.lua
@@ -4,8 +4,8 @@ local eq = helpers.eq
local NIL = vim.NIL
local eval = helpers.eval
local clear = helpers.clear
-local meths = helpers.meths
-local funcs = helpers.funcs
+local api = helpers.api
+local fn = helpers.fn
local command = helpers.command
local exc_exec = helpers.exc_exec
local pcall_err = helpers.pcall_err
@@ -21,7 +21,7 @@ describe('sort()', function()
end)
it('sorts “wrong” values between -0.0001 and 0.0001, preserving order', function()
- meths.nvim_set_var('list', {
+ api.nvim_set_var('list', {
true,
false,
NIL,
@@ -32,7 +32,7 @@ describe('sort()', function()
-0.0001,
})
command('call insert(g:list, function("tr"))')
- local error_lines = funcs.split(funcs.execute('silent! call sort(g:list, "f")'), '\n')
+ local error_lines = fn.split(fn.execute('silent! call sort(g:list, "f")'), '\n')
local errors = {}
for _, err in ipairs(error_lines) do
errors[err] = true
diff --git a/test/functional/vimscript/special_vars_spec.lua b/test/functional/vimscript/special_vars_spec.lua
index a76bb78b6f..590d409141 100644
--- a/test/functional/vimscript/special_vars_spec.lua
+++ b/test/functional/vimscript/special_vars_spec.lua
@@ -1,11 +1,11 @@
local helpers = require('test.functional.helpers')(after_each)
local exc_exec = helpers.exc_exec
local command = helpers.command
-local funcs = helpers.funcs
+local fn = helpers.fn
local clear = helpers.clear
local eval = helpers.eval
local eq = helpers.eq
-local meths = helpers.meths
+local api = helpers.api
local NIL = vim.NIL
describe('Special values', function()
@@ -25,15 +25,15 @@ describe('Special values', function()
end)
it('work with empty()', function()
- eq(0, funcs.empty(true))
- eq(1, funcs.empty(false))
- eq(1, funcs.empty(NIL))
+ eq(0, fn.empty(true))
+ eq(1, fn.empty(false))
+ eq(1, fn.empty(NIL))
end)
it('can be stringified and eval’ed back', function()
- eq(true, funcs.eval(funcs.string(true)))
- eq(false, funcs.eval(funcs.string(false)))
- eq(NIL, funcs.eval(funcs.string(NIL)))
+ eq(true, fn.eval(fn.string(true)))
+ eq(false, fn.eval(fn.string(false)))
+ eq(NIL, fn.eval(fn.string(NIL)))
end)
it('work with is/isnot properly', function()
@@ -107,8 +107,8 @@ describe('Special values', function()
end)
it('does not work with +=/-=/.=', function()
- meths.nvim_set_var('true', true)
- meths.nvim_set_var('false', false)
+ api.nvim_set_var('true', true)
+ api.nvim_set_var('false', false)
command('let null = v:null')
eq('Vim(let):E734: Wrong variable type for +=', exc_exec('let true += 1'))
@@ -137,19 +137,19 @@ describe('Special values', function()
end)
it('work with type()', function()
- eq(6, funcs.type(true))
- eq(6, funcs.type(false))
- eq(7, funcs.type(NIL))
+ eq(6, fn.type(true))
+ eq(6, fn.type(false))
+ eq(7, fn.type(NIL))
end)
it('work with copy() and deepcopy()', function()
- eq(true, funcs.deepcopy(true))
- eq(false, funcs.deepcopy(false))
- eq(NIL, funcs.deepcopy(NIL))
+ eq(true, fn.deepcopy(true))
+ eq(false, fn.deepcopy(false))
+ eq(NIL, fn.deepcopy(NIL))
- eq(true, funcs.copy(true))
- eq(false, funcs.copy(false))
- eq(NIL, funcs.copy(NIL))
+ eq(true, fn.copy(true))
+ eq(false, fn.copy(false))
+ eq(NIL, fn.copy(NIL))
end)
it('fails in index', function()
@@ -159,20 +159,20 @@ describe('Special values', function()
end)
it('is accepted by assert_true and assert_false', function()
- funcs.assert_false(false)
- funcs.assert_false(true)
- funcs.assert_false(NIL)
+ fn.assert_false(false)
+ fn.assert_false(true)
+ fn.assert_false(NIL)
- funcs.assert_true(false)
- funcs.assert_true(true)
- funcs.assert_true(NIL)
+ fn.assert_true(false)
+ fn.assert_true(true)
+ fn.assert_true(NIL)
eq({
'Expected False but got v:true',
'Expected False but got v:null',
'Expected True but got v:false',
'Expected True but got v:null',
- }, meths.nvim_get_vvar('errors'))
+ }, api.nvim_get_vvar('errors'))
end)
describe('compat', function()
diff --git a/test/functional/vimscript/state_spec.lua b/test/functional/vimscript/state_spec.lua
index f9a21c5881..7179806e36 100644
--- a/test/functional/vimscript/state_spec.lua
+++ b/test/functional/vimscript/state_spec.lua
@@ -4,7 +4,7 @@ local eq = helpers.eq
local exec = helpers.exec
local exec_lua = helpers.exec_lua
local feed = helpers.feed
-local meths = helpers.meths
+local api = helpers.api
local poke_eventloop = helpers.poke_eventloop
before_each(clear)
@@ -12,7 +12,7 @@ before_each(clear)
describe('state() function', function()
-- oldtest: Test_state()
it('works', function()
- meths.nvim_ui_attach(80, 24, {}) -- Allow hit-enter-prompt
+ api.nvim_ui_attach(80, 24, {}) -- Allow hit-enter-prompt
exec_lua([[
function _G.Get_state_mode()
@@ -48,7 +48,7 @@ describe('state() function', function()
-- Halfway a mapping
feed([[:call v:lua.Run_timer()<CR>;]])
- meths.nvim_get_mode() -- Process pending input and luv timer callback
+ api.nvim_get_mode() -- Process pending input and luv timer callback
feed(';')
eq({ 'mS', 'n' }, exec_lua('return _G.res'))
@@ -79,7 +79,7 @@ describe('state() function', function()
-- messages scrolled
feed([[:call v:lua.Run_timer() | echo "one\ntwo\nthree"<CR>]])
- meths.nvim_get_mode() -- Process pending input and luv timer callback
+ api.nvim_get_mode() -- Process pending input and luv timer callback
feed('<CR>')
eq({ 'Ss', 'r' }, exec_lua('return _G.res'))
end)
diff --git a/test/functional/vimscript/string_spec.lua b/test/functional/vimscript/string_spec.lua
index cb63404c00..6a7fe1bad9 100644
--- a/test/functional/vimscript/string_spec.lua
+++ b/test/functional/vimscript/string_spec.lua
@@ -2,11 +2,11 @@ local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
local eq = helpers.eq
local command = helpers.command
-local meths = helpers.meths
+local api = helpers.api
local eval = helpers.eval
local exc_exec = helpers.exc_exec
local pcall_err = helpers.pcall_err
-local funcs = helpers.funcs
+local fn = helpers.fn
local NIL = vim.NIL
local source = helpers.source
@@ -24,8 +24,8 @@ describe('string() function', function()
end)
it('dumps regular values', function()
- eq('1.5', funcs.string(1.5))
- eq('1.56e-20', funcs.string(1.56000e-020))
+ eq('1.5', fn.string(1.5))
+ eq('1.56e-20', fn.string(1.56000e-020))
eq('0.0', eval('string(0.0)'))
end)
@@ -33,58 +33,58 @@ describe('string() function', function()
eq('v:true', eval('string(v:true)'))
eq('v:false', eval('string(v:false)'))
eq('v:null', eval('string(v:null)'))
- eq('v:true', funcs.string(true))
- eq('v:false', funcs.string(false))
- eq('v:null', funcs.string(NIL))
+ eq('v:true', fn.string(true))
+ eq('v:false', fn.string(false))
+ eq('v:null', fn.string(NIL))
end)
it('dumps values with at most six digits after the decimal point', function()
- eq('1.234568e-20', funcs.string(1.23456789123456789123456789e-020))
- eq('1.234568', funcs.string(1.23456789123456789123456789))
+ eq('1.234568e-20', fn.string(1.23456789123456789123456789e-020))
+ eq('1.234568', fn.string(1.23456789123456789123456789))
end)
it('dumps values with at most seven digits before the decimal point', function()
- eq('1234567.891235', funcs.string(1234567.89123456789123456789))
- eq('1.234568e7', funcs.string(12345678.9123456789123456789))
+ eq('1234567.891235', fn.string(1234567.89123456789123456789))
+ eq('1.234568e7', fn.string(12345678.9123456789123456789))
end)
it('dumps negative values', function()
- eq('-1.5', funcs.string(-1.5))
- eq('-1.56e-20', funcs.string(-1.56000e-020))
- eq('-1.234568e-20', funcs.string(-1.23456789123456789123456789e-020))
- eq('-1.234568', funcs.string(-1.23456789123456789123456789))
- eq('-1234567.891235', funcs.string(-1234567.89123456789123456789))
- eq('-1.234568e7', funcs.string(-12345678.9123456789123456789))
+ eq('-1.5', fn.string(-1.5))
+ eq('-1.56e-20', fn.string(-1.56000e-020))
+ eq('-1.234568e-20', fn.string(-1.23456789123456789123456789e-020))
+ eq('-1.234568', fn.string(-1.23456789123456789123456789))
+ eq('-1234567.891235', fn.string(-1234567.89123456789123456789))
+ eq('-1.234568e7', fn.string(-12345678.9123456789123456789))
end)
end)
describe('used to represent numbers', function()
it('dumps regular values', function()
- eq('0', funcs.string(0))
- eq('-1', funcs.string(-1))
- eq('1', funcs.string(1))
+ eq('0', fn.string(0))
+ eq('-1', fn.string(-1))
+ eq('1', fn.string(1))
end)
it('dumps large values', function()
- eq('2147483647', funcs.string(2 ^ 31 - 1))
- eq('-2147483648', funcs.string(-2 ^ 31))
+ eq('2147483647', fn.string(2 ^ 31 - 1))
+ eq('-2147483648', fn.string(-2 ^ 31))
end)
end)
describe('used to represent strings', function()
it('dumps regular strings', function()
- eq("'test'", funcs.string('test'))
+ eq("'test'", fn.string('test'))
end)
it('dumps empty strings', function()
- eq("''", funcs.string(''))
+ eq("''", fn.string(''))
end)
it("dumps strings with ' inside", function()
- eq("''''''''", funcs.string("'''"))
- eq("'a''b'''''", funcs.string("a'b''"))
- eq("'''b''''d'", funcs.string("'b''d"))
- eq("'a''b''c''d'", funcs.string("a'b'c'd"))
+ eq("''''''''", fn.string("'''"))
+ eq("'a''b'''''", fn.string("a'b''"))
+ eq("'''b''''d'", fn.string("'b''d"))
+ eq("'a''b''c''d'", fn.string("a'b'c'd"))
end)
it('dumps NULL strings', function()
@@ -161,7 +161,7 @@ describe('string() function', function()
end)
it('does not crash or halt when dumping partials with reference cycles in self', function()
- meths.nvim_set_var('d', { v = true })
+ api.nvim_set_var('d', { v = true })
eq(
[[Vim(echo):E724: unable to correctly dump variable with self-referencing container]],
pcall_err(command, 'echo string(extend(extend(g:d, {"f": g:Test2_f}), {"p": g:d.f}))')
@@ -186,7 +186,7 @@ describe('string() function', function()
end)
it('does not crash or halt when dumping partials with reference cycles in arguments', function()
- meths.nvim_set_var('l', {})
+ api.nvim_set_var('l', {})
eval('add(l, l)')
-- Regression: the below line used to crash (add returns original list and
-- there was error in dumping partials). Tested explicitly in
@@ -201,8 +201,8 @@ describe('string() function', function()
it(
'does not crash or halt when dumping partials with reference cycles in self and arguments',
function()
- meths.nvim_set_var('d', { v = true })
- meths.nvim_set_var('l', {})
+ api.nvim_set_var('d', { v = true })
+ api.nvim_set_var('l', {})
eval('add(l, l)')
eval('add(l, function("Test1", l))')
eval('add(l, function("Test1", d))')
@@ -219,19 +219,19 @@ describe('string() function', function()
describe('used to represent lists', function()
it('dumps empty list', function()
- eq('[]', funcs.string({}))
+ eq('[]', fn.string({}))
end)
it('dumps nested lists', function()
- eq('[[[[[]]]]]', funcs.string({ { { { {} } } } }))
+ eq('[[[[[]]]]]', fn.string({ { { { {} } } } }))
end)
it('dumps nested non-empty lists', function()
- eq('[1, [[3, [[5], 4]], 2]]', funcs.string({ 1, { { 3, { { 5 }, 4 } }, 2 } }))
+ eq('[1, [[3, [[5], 4]], 2]]', fn.string({ 1, { { 3, { { 5 }, 4 } }, 2 } }))
end)
it('errors when dumping recursive lists', function()
- meths.nvim_set_var('l', {})
+ api.nvim_set_var('l', {})
eval('add(l, l)')
eq(
'Vim(echo):E724: unable to correctly dump variable with self-referencing container',
@@ -240,7 +240,7 @@ describe('string() function', function()
end)
it('dumps recursive lists despite the error', function()
- meths.nvim_set_var('l', {})
+ api.nvim_set_var('l', {})
eval('add(l, l)')
eq(
'Vim(echo):E724: unable to correctly dump variable with self-referencing container',
@@ -266,11 +266,11 @@ describe('string() function', function()
end)
it('dumps non-empty dictionary', function()
- eq("{'t''est': 1}", funcs.string({ ["t'est"] = 1 }))
+ eq("{'t''est': 1}", fn.string({ ["t'est"] = 1 }))
end)
it('errors when dumping recursive dictionaries', function()
- meths.nvim_set_var('d', { d = 1 })
+ api.nvim_set_var('d', { d = 1 })
eval('extend(d, {"d": d})')
eq(
'Vim(echo):E724: unable to correctly dump variable with self-referencing container',
@@ -279,7 +279,7 @@ describe('string() function', function()
end)
it('dumps recursive dictionaries despite the error', function()
- meths.nvim_set_var('d', { d = 1 })
+ api.nvim_set_var('d', { d = 1 })
eval('extend(d, {"d": d})')
eq(
'Vim(echo):E724: unable to correctly dump variable with self-referencing container',
diff --git a/test/functional/vimscript/system_spec.lua b/test/functional/vimscript/system_spec.lua
index 19a5d4c806..d44f68e152 100644
--- a/test/functional/vimscript/system_spec.lua
+++ b/test/functional/vimscript/system_spec.lua
@@ -4,14 +4,14 @@ local helpers = require('test.functional.helpers')(after_each)
local assert_alive = helpers.assert_alive
local testprg = helpers.testprg
-local eq, call, clear, eval, feed_command, feed, meths =
+local eq, call, clear, eval, feed_command, feed, api =
helpers.eq,
helpers.call,
helpers.clear,
helpers.eval,
helpers.feed_command,
helpers.feed,
- helpers.meths
+ helpers.api
local command = helpers.command
local insert = helpers.insert
local expect = helpers.expect
@@ -220,8 +220,8 @@ describe('system()', function()
end)
it('prints verbose information', function()
- meths.nvim_set_option_value('shell', 'fake_shell', {})
- meths.nvim_set_option_value('shellcmdflag', 'cmdflag', {})
+ api.nvim_set_option_value('shell', 'fake_shell', {})
+ api.nvim_set_option_value('shellcmdflag', 'cmdflag', {})
screen:try_resize(72, 14)
feed(':4verbose echo system("echo hi")<cr>')
@@ -247,8 +247,8 @@ describe('system()', function()
feed(':edit ' .. tempfile .. '<cr>')
- local command_total_time = tonumber(helpers.funcs.split(helpers.funcs.getline(7))[2])
- local command_self_time = tonumber(helpers.funcs.split(helpers.funcs.getline(7))[3])
+ local command_total_time = tonumber(helpers.fn.split(helpers.fn.getline(7))[2])
+ local command_self_time = tonumber(helpers.fn.split(helpers.fn.getline(7))[3])
helpers.neq(nil, command_total_time)
helpers.neq(nil, command_self_time)
@@ -346,7 +346,7 @@ describe('system()', function()
input[#input + 1] = '01234567890ABCDEFabcdef'
end
input = table.concat(input, '\n')
- meths.nvim_set_var('input', input)
+ api.nvim_set_var('input', input)
eq(input, eval('system("cat -", g:input)'))
end)
end)
@@ -480,7 +480,7 @@ describe('systemlist()', function()
for _ = 1, 0xffff do
input[#input + 1] = '01234567890ABCDEFabcdef'
end
- meths.nvim_set_var('input', input)
+ api.nvim_set_var('input', input)
eq(input, eval('systemlist("cat -", g:input)'))
end)
end)
diff --git a/test/functional/vimscript/timer_spec.lua b/test/functional/vimscript/timer_spec.lua
index 02a5880949..3f53c21e7a 100644
--- a/test/functional/vimscript/timer_spec.lua
+++ b/test/functional/vimscript/timer_spec.lua
@@ -2,9 +2,9 @@ local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local feed, eq, eval, ok = helpers.feed, helpers.eq, helpers.eval, helpers.ok
local source, nvim_async, run = helpers.source, helpers.nvim_async, helpers.run
-local clear, command, funcs = helpers.clear, helpers.command, helpers.funcs
+local clear, command, fn = helpers.clear, helpers.command, helpers.fn
local exc_exec = helpers.exc_exec
-local meths = helpers.meths
+local api = helpers.api
local load_adjust = helpers.load_adjust
local retry = helpers.retry
@@ -111,7 +111,7 @@ describe('timers', function()
[1] = { bold = true, foreground = Screen.colors.Blue },
})
- meths.nvim_buf_set_lines(0, 0, -1, true, { 'ITEM 1', 'ITEM 2' })
+ api.nvim_buf_set_lines(0, 0, -1, true, { 'ITEM 1', 'ITEM 2' })
source([[
let g:cont = 0
func! AddItem(timer)
@@ -165,7 +165,7 @@ describe('timers', function()
local t_init_val = eval("[timer_start(5, 'MyHandler', {'repeat': -1}), g:val]")
eq(0, t_init_val[2])
run(nil, nil, nil, load_adjust(30))
- funcs.timer_stop(t_init_val[1])
+ fn.timer_stop(t_init_val[1])
local count = eval('g:val')
run(nil, load_adjust(300), nil, load_adjust(30))
local count2 = eval('g:val')
diff --git a/test/functional/vimscript/wait_spec.lua b/test/functional/vimscript/wait_spec.lua
index e6b244538d..4ee3b183b3 100644
--- a/test/functional/vimscript/wait_spec.lua
+++ b/test/functional/vimscript/wait_spec.lua
@@ -7,14 +7,14 @@ local eq = helpers.eq
local feed = helpers.feed
local feed_command = helpers.feed_command
local next_msg = helpers.next_msg
-local meths = helpers.meths
+local api = helpers.api
local source = helpers.source
local pcall_err = helpers.pcall_err
before_each(function()
clear()
- local channel = meths.nvim_get_api_info()[1]
- meths.nvim_set_var('channel', channel)
+ local channel = api.nvim_get_api_info()[1]
+ api.nvim_set_var('channel', channel)
end)
describe('wait()', function()
@@ -61,13 +61,13 @@ describe('wait()', function()
-- XXX: flaky (#11137)
helpers.retry(nil, nil, function()
- meths.nvim_set_var('counter', 0)
+ api.nvim_set_var('counter', 0)
eq(-1, call('wait', 20, 'Count() >= 5', 99999))
end)
- meths.nvim_set_var('counter', 0)
+ api.nvim_set_var('counter', 0)
eq(0, call('wait', 10000, 'Count() >= 5', 5))
- eq(5, meths.nvim_get_var('counter'))
+ eq(5, api.nvim_get_var('counter'))
end)
it('validates args', function()
diff --git a/test/functional/vimscript/writefile_spec.lua b/test/functional/vimscript/writefile_spec.lua
index 4de542f293..051e3794a3 100644
--- a/test/functional/vimscript/writefile_spec.lua
+++ b/test/functional/vimscript/writefile_spec.lua
@@ -3,8 +3,8 @@ local helpers = require('test.functional.helpers')(after_each)
local mkdir = helpers.mkdir
local clear = helpers.clear
local eq = helpers.eq
-local funcs = helpers.funcs
-local meths = helpers.meths
+local fn = helpers.fn
+local api = helpers.api
local exc_exec = helpers.exc_exec
local read_file = helpers.read_file
local write_file = helpers.write_file
@@ -34,19 +34,19 @@ end)
describe('writefile()', function()
it('writes empty list to a file', function()
eq(nil, read_file(fname))
- eq(0, funcs.writefile({}, fname))
+ eq(0, fn.writefile({}, fname))
eq('', read_file(fname))
os.remove(fname)
eq(nil, read_file(fname))
- eq(0, funcs.writefile({}, fname, 'b'))
+ eq(0, fn.writefile({}, fname, 'b'))
eq('', read_file(fname))
os.remove(fname)
eq(nil, read_file(fname))
- eq(0, funcs.writefile({}, fname, 'ab'))
+ eq(0, fn.writefile({}, fname, 'ab'))
eq('', read_file(fname))
os.remove(fname)
eq(nil, read_file(fname))
- eq(0, funcs.writefile({}, fname, 'a'))
+ eq(0, fn.writefile({}, fname, 'a'))
eq('', read_file(fname))
end)
@@ -66,41 +66,41 @@ describe('writefile()', function()
it('appends to a file', function()
eq(nil, read_file(fname))
- eq(0, funcs.writefile({ 'abc', 'def', 'ghi' }, fname))
+ eq(0, fn.writefile({ 'abc', 'def', 'ghi' }, fname))
eq('abc\ndef\nghi\n', read_file(fname))
- eq(0, funcs.writefile({ 'jkl' }, fname, 'a'))
+ eq(0, fn.writefile({ 'jkl' }, fname, 'a'))
eq('abc\ndef\nghi\njkl\n', read_file(fname))
os.remove(fname)
eq(nil, read_file(fname))
- eq(0, funcs.writefile({ 'abc', 'def', 'ghi' }, fname, 'b'))
+ eq(0, fn.writefile({ 'abc', 'def', 'ghi' }, fname, 'b'))
eq('abc\ndef\nghi', read_file(fname))
- eq(0, funcs.writefile({ 'jkl' }, fname, 'ab'))
+ eq(0, fn.writefile({ 'jkl' }, fname, 'ab'))
eq('abc\ndef\nghijkl', read_file(fname))
end)
it('correctly treats NLs', function()
- eq(0, funcs.writefile({ '\na\nb\n' }, fname, 'b'))
+ eq(0, fn.writefile({ '\na\nb\n' }, fname, 'b'))
eq('\0a\0b\0', read_file(fname))
- eq(0, funcs.writefile({ 'a\n\n\nb' }, fname, 'b'))
+ eq(0, fn.writefile({ 'a\n\n\nb' }, fname, 'b'))
eq('a\0\0\0b', read_file(fname))
end)
it('writes with s and S', function()
- eq(0, funcs.writefile({ '\na\nb\n' }, fname, 'bs'))
+ eq(0, fn.writefile({ '\na\nb\n' }, fname, 'bs'))
eq('\0a\0b\0', read_file(fname))
- eq(0, funcs.writefile({ 'a\n\n\nb' }, fname, 'bS'))
+ eq(0, fn.writefile({ 'a\n\n\nb' }, fname, 'bS'))
eq('a\0\0\0b', read_file(fname))
end)
it('correctly overwrites file', function()
- eq(0, funcs.writefile({ '\na\nb\n' }, fname, 'b'))
+ eq(0, fn.writefile({ '\na\nb\n' }, fname, 'b'))
eq('\0a\0b\0', read_file(fname))
- eq(0, funcs.writefile({ 'a\n' }, fname, 'b'))
+ eq(0, fn.writefile({ 'a\n' }, fname, 'b'))
eq('a\0', read_file(fname))
end)
it('shows correct file name when supplied numbers', function()
- meths.nvim_set_current_dir(dname)
+ api.nvim_set_current_dir(dname)
eq(
"Vim(call):E482: Can't open file 2 for writing: illegal operation on a directory",
pcall_err(command, ('call writefile([42], %s)'):format(ddname_tail))
@@ -110,12 +110,12 @@ describe('writefile()', function()
it('writefile(..., "p") creates missing parent directories', function()
os.remove(dname)
eq(nil, read_file(dfname))
- eq(0, funcs.writefile({ 'abc', 'def', 'ghi' }, dfname, 'p'))
+ eq(0, fn.writefile({ 'abc', 'def', 'ghi' }, dfname, 'p'))
eq('abc\ndef\nghi\n', read_file(dfname))
os.remove(dfname)
os.remove(dname)
eq(nil, read_file(dfname))
- eq(0, funcs.writefile({ '\na\nb\n' }, dfname, 'pb'))
+ eq(0, fn.writefile({ '\na\nb\n' }, dfname, 'pb'))
eq('\0a\0b\0', read_file(dfname))
os.remove(dfname)
os.remove(dname)