aboutsummaryrefslogtreecommitdiff
path: root/test/functional/options/defaults_spec.lua
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/options/defaults_spec.lua
parent4f81f506f96f8b5bfcf00e952ceb492d3ce9dc6e (diff)
downloadrneovim-795f896a5772d5e0795f86642bdf90c82efac45c.tar.gz
rneovim-795f896a5772d5e0795f86642bdf90c82efac45c.tar.bz2
rneovim-795f896a5772d5e0795f86642bdf90c82efac45c.zip
test: rename (meths, funcs) -> (api, fn)
Diffstat (limited to 'test/functional/options/defaults_spec.lua')
-rw-r--r--test/functional/options/defaults_spec.lua152
1 files changed, 76 insertions, 76 deletions
diff --git a/test/functional/options/defaults_spec.lua b/test/functional/options/defaults_spec.lua
index 234dc47f20..10a0baa30b 100644
--- a/test/functional/options/defaults_spec.lua
+++ b/test/functional/options/defaults_spec.lua
@@ -4,7 +4,7 @@ local Screen = require('test.functional.ui.screen')
local assert_alive = helpers.assert_alive
local assert_log = helpers.assert_log
-local meths = helpers.meths
+local api = helpers.api
local command = helpers.command
local clear = helpers.clear
local exc_exec = helpers.exc_exec
@@ -12,7 +12,7 @@ local exec_lua = helpers.exec_lua
local eval = helpers.eval
local eq = helpers.eq
local ok = helpers.ok
-local funcs = helpers.funcs
+local fn = helpers.fn
local insert = helpers.insert
local neq = helpers.neq
local mkdir = helpers.mkdir
@@ -149,7 +149,7 @@ describe('startup defaults', function()
]])
-- change "vert" character to single-cell
- funcs.setcellwidths({ { 0x2502, 0x2502, 1 } })
+ fn.setcellwidths({ { 0x2502, 0x2502, 1 } })
screen:expect([[
1 │1 |
^+-- 2 lines: 2----------│+-- 2 lines: 2---------|
@@ -159,7 +159,7 @@ describe('startup defaults', function()
]])
-- change "vert" character to double-cell
- funcs.setcellwidths({ { 0x2502, 0x2502, 2 } })
+ fn.setcellwidths({ { 0x2502, 0x2502, 2 } })
screen:expect([[
1 |1 |
^+-- 2 lines: 2----------|+-- 2 lines: 2---------|
@@ -195,8 +195,8 @@ describe('startup defaults', function()
clear { args = {}, args_rm = { '-i' }, env = env }
-- Default 'shadafile' is empty.
-- This means use the default location. :help shada-file-name
- eq('', meths.nvim_get_option_value('shadafile', {}))
- eq('', meths.nvim_get_option_value('viminfofile', {}))
+ eq('', api.nvim_get_option_value('shadafile', {}))
+ eq('', api.nvim_get_option_value('viminfofile', {}))
-- Handles viminfo/viminfofile as alias for shada/shadafile.
eq('\n shadafile=', eval('execute("set shadafile?")'))
eq('\n shadafile=', eval('execute("set viminfofile?")'))
@@ -218,13 +218,13 @@ describe('startup defaults', function()
args_rm = { 'runtimepath' },
}
-- Defaults to &runtimepath.
- eq(meths.nvim_get_option_value('runtimepath', {}), meths.nvim_get_option_value('packpath', {}))
+ eq(api.nvim_get_option_value('runtimepath', {}), api.nvim_get_option_value('packpath', {}))
-- Does not follow modifications to runtimepath.
command('set runtimepath+=foo')
- neq(meths.nvim_get_option_value('runtimepath', {}), meths.nvim_get_option_value('packpath', {}))
+ neq(api.nvim_get_option_value('runtimepath', {}), api.nvim_get_option_value('packpath', {}))
command('set packpath+=foo')
- eq(meths.nvim_get_option_value('runtimepath', {}), meths.nvim_get_option_value('packpath', {}))
+ eq(api.nvim_get_option_value('runtimepath', {}), api.nvim_get_option_value('packpath', {}))
end)
it('v:progpath is set to the absolute path', function()
@@ -316,11 +316,11 @@ describe('XDG defaults', function()
},
})
- eq('.', meths.nvim_get_option_value('backupdir', {}))
- eq('.', meths.nvim_get_option_value('viewdir', {}))
- eq('.', meths.nvim_get_option_value('directory', {}))
- eq('.', meths.nvim_get_option_value('undodir', {}))
- ok((funcs.tempname()):len() > 4)
+ eq('.', api.nvim_get_option_value('backupdir', {}))
+ eq('.', api.nvim_get_option_value('viewdir', {}))
+ eq('.', api.nvim_get_option_value('directory', {}))
+ eq('.', api.nvim_get_option_value('undodir', {}))
+ ok((fn.tempname()):len() > 4)
end)
end)
@@ -328,7 +328,7 @@ describe('XDG defaults', function()
local vimruntime = eval('$VIMRUNTIME')
-- libdir is hard to calculate reliably across various ci platforms
-- local libdir = string.gsub(vimruntime, "share/nvim/runtime$", "lib/nvim")
- local libdir = meths.nvim__get_lib_dir()
+ local libdir = api.nvim__get_lib_dir()
return vimruntime, libdir
end
@@ -428,7 +428,7 @@ describe('XDG defaults', function()
.. '/nvim/after'
):gsub('\\', '/')
),
- (meths.nvim_get_option_value('runtimepath', {})):gsub('\\', '/')
+ (api.nvim_get_option_value('runtimepath', {})):gsub('\\', '/')
)
command('set runtimepath&')
command('set backupdir&')
@@ -499,23 +499,23 @@ describe('XDG defaults', function()
.. '/nvim/after'
):gsub('\\', '/')
),
- (meths.nvim_get_option_value('runtimepath', {})):gsub('\\', '/')
+ (api.nvim_get_option_value('runtimepath', {})):gsub('\\', '/')
)
eq(
'.,' .. root_path .. ('/X'):rep(4096) .. '/' .. state_dir .. '/backup//',
- (meths.nvim_get_option_value('backupdir', {}):gsub('\\', '/'))
+ (api.nvim_get_option_value('backupdir', {}):gsub('\\', '/'))
)
eq(
root_path .. ('/X'):rep(4096) .. '/' .. state_dir .. '/swap//',
- (meths.nvim_get_option_value('directory', {})):gsub('\\', '/')
+ (api.nvim_get_option_value('directory', {})):gsub('\\', '/')
)
eq(
root_path .. ('/X'):rep(4096) .. '/' .. state_dir .. '/undo//',
- (meths.nvim_get_option_value('undodir', {})):gsub('\\', '/')
+ (api.nvim_get_option_value('undodir', {})):gsub('\\', '/')
)
eq(
root_path .. ('/X'):rep(4096) .. '/' .. state_dir .. '/view//',
- (meths.nvim_get_option_value('viewdir', {})):gsub('\\', '/')
+ (api.nvim_get_option_value('viewdir', {})):gsub('\\', '/')
)
end)
end)
@@ -571,7 +571,7 @@ describe('XDG defaults', function()
.. ',$XDG_DATA_HOME/nvim/after'
):gsub('\\', '/')
),
- (meths.nvim_get_option_value('runtimepath', {})):gsub('\\', '/')
+ (api.nvim_get_option_value('runtimepath', {})):gsub('\\', '/')
)
command('set runtimepath&')
command('set backupdir&')
@@ -599,23 +599,23 @@ describe('XDG defaults', function()
.. ',$XDG_DATA_HOME/nvim/after'
):gsub('\\', '/')
),
- (meths.nvim_get_option_value('runtimepath', {})):gsub('\\', '/')
+ (api.nvim_get_option_value('runtimepath', {})):gsub('\\', '/')
)
eq(
('.,$XDG_CONFIG_HOME/' .. state_dir .. '/backup//'),
- meths.nvim_get_option_value('backupdir', {}):gsub('\\', '/')
+ api.nvim_get_option_value('backupdir', {}):gsub('\\', '/')
)
eq(
('$XDG_CONFIG_HOME/' .. state_dir .. '/swap//'),
- meths.nvim_get_option_value('directory', {}):gsub('\\', '/')
+ api.nvim_get_option_value('directory', {}):gsub('\\', '/')
)
eq(
('$XDG_CONFIG_HOME/' .. state_dir .. '/undo//'),
- meths.nvim_get_option_value('undodir', {}):gsub('\\', '/')
+ api.nvim_get_option_value('undodir', {}):gsub('\\', '/')
)
eq(
('$XDG_CONFIG_HOME/' .. state_dir .. '/view//'),
- meths.nvim_get_option_value('viewdir', {}):gsub('\\', '/')
+ api.nvim_get_option_value('viewdir', {}):gsub('\\', '/')
)
command('set all&')
eq(
@@ -637,25 +637,25 @@ describe('XDG defaults', function()
.. ',$XDG_DATA_DIRS/nvim/after'
.. ',$XDG_DATA_HOME/nvim/after'
):gsub('\\', '/'),
- (meths.nvim_get_option_value('runtimepath', {})):gsub('\\', '/')
+ (api.nvim_get_option_value('runtimepath', {})):gsub('\\', '/')
)
eq(
('.,$XDG_CONFIG_HOME/' .. state_dir .. '/backup//'),
- meths.nvim_get_option_value('backupdir', {}):gsub('\\', '/')
+ api.nvim_get_option_value('backupdir', {}):gsub('\\', '/')
)
eq(
('$XDG_CONFIG_HOME/' .. state_dir .. '/swap//'),
- meths.nvim_get_option_value('directory', {}):gsub('\\', '/')
+ api.nvim_get_option_value('directory', {}):gsub('\\', '/')
)
eq(
('$XDG_CONFIG_HOME/' .. state_dir .. '/undo//'),
- meths.nvim_get_option_value('undodir', {}):gsub('\\', '/')
+ api.nvim_get_option_value('undodir', {}):gsub('\\', '/')
)
eq(
('$XDG_CONFIG_HOME/' .. state_dir .. '/view//'),
- meths.nvim_get_option_value('viewdir', {}):gsub('\\', '/')
+ api.nvim_get_option_value('viewdir', {}):gsub('\\', '/')
)
- eq(nil, (funcs.tempname()):match('XDG_RUNTIME_DIR'))
+ eq(nil, (fn.tempname()):match('XDG_RUNTIME_DIR'))
end)
end)
@@ -743,7 +743,7 @@ describe('XDG defaults', function()
.. path_sep
.. 'after'
),
- meths.nvim_get_option_value('runtimepath', {})
+ api.nvim_get_option_value('runtimepath', {})
)
command('set runtimepath&')
command('set backupdir&')
@@ -821,11 +821,11 @@ describe('XDG defaults', function()
.. path_sep
.. 'after'
),
- meths.nvim_get_option_value('runtimepath', {})
+ api.nvim_get_option_value('runtimepath', {})
)
eq(
'.,\\,=\\,=\\,' .. path_sep .. state_dir .. '' .. path_sep .. 'backup' .. (path_sep):rep(2),
- meths.nvim_get_option_value('backupdir', {})
+ api.nvim_get_option_value('backupdir', {})
)
eq(
'\\,=\\,=\\,'
@@ -836,7 +836,7 @@ describe('XDG defaults', function()
.. path_sep
.. 'swap'
.. (path_sep):rep(2),
- meths.nvim_get_option_value('directory', {})
+ api.nvim_get_option_value('directory', {})
)
eq(
'\\,=\\,=\\,'
@@ -847,7 +847,7 @@ describe('XDG defaults', function()
.. path_sep
.. 'undo'
.. (path_sep):rep(2),
- meths.nvim_get_option_value('undodir', {})
+ api.nvim_get_option_value('undodir', {})
)
eq(
'\\,=\\,=\\,'
@@ -858,7 +858,7 @@ describe('XDG defaults', function()
.. path_sep
.. 'view'
.. (path_sep):rep(2),
- meths.nvim_get_option_value('viewdir', {})
+ api.nvim_get_option_value('viewdir', {})
)
end)
end)
@@ -878,29 +878,29 @@ describe('stdpath()', function()
it('acceptance', function()
clear() -- Do not explicitly set any env vars.
- eq('nvim', funcs.fnamemodify(funcs.stdpath('cache'), ':t'))
- eq('nvim', funcs.fnamemodify(funcs.stdpath('config'), ':t'))
- eq(datadir, funcs.fnamemodify(funcs.stdpath('data'), ':t'))
- eq(statedir, funcs.fnamemodify(funcs.stdpath('state'), ':t'))
- eq('table', type(funcs.stdpath('config_dirs')))
- eq('table', type(funcs.stdpath('data_dirs')))
- eq('string', type(funcs.stdpath('run')))
+ eq('nvim', fn.fnamemodify(fn.stdpath('cache'), ':t'))
+ eq('nvim', fn.fnamemodify(fn.stdpath('config'), ':t'))
+ eq(datadir, fn.fnamemodify(fn.stdpath('data'), ':t'))
+ eq(statedir, fn.fnamemodify(fn.stdpath('state'), ':t'))
+ eq('table', type(fn.stdpath('config_dirs')))
+ eq('table', type(fn.stdpath('data_dirs')))
+ eq('string', type(fn.stdpath('run')))
assert_alive() -- Check for crash. #8393
end)
it('reacts to $NVIM_APPNAME', function()
local appname = 'NVIM_APPNAME_TEST' .. ('_'):rep(106)
clear({ env = { NVIM_APPNAME = appname } })
- eq(appname, funcs.fnamemodify(funcs.stdpath('config'), ':t'))
- eq(appname, funcs.fnamemodify(funcs.stdpath('cache'), ':t'))
- eq(maybe_data(appname), funcs.fnamemodify(funcs.stdpath('log'), ':t'))
- eq(maybe_data(appname), funcs.fnamemodify(funcs.stdpath('data'), ':t'))
- eq(maybe_data(appname), funcs.fnamemodify(funcs.stdpath('state'), ':t'))
+ eq(appname, fn.fnamemodify(fn.stdpath('config'), ':t'))
+ eq(appname, fn.fnamemodify(fn.stdpath('cache'), ':t'))
+ eq(maybe_data(appname), fn.fnamemodify(fn.stdpath('log'), ':t'))
+ eq(maybe_data(appname), fn.fnamemodify(fn.stdpath('data'), ':t'))
+ eq(maybe_data(appname), fn.fnamemodify(fn.stdpath('state'), ':t'))
-- config_dirs and data_dirs are empty on windows, so don't check them on
-- that platform
if not is_os('win') then
- eq(appname, funcs.fnamemodify(funcs.stdpath('config_dirs')[1], ':t'))
- eq(appname, funcs.fnamemodify(funcs.stdpath('data_dirs')[1], ':t'))
+ eq(appname, fn.fnamemodify(fn.stdpath('config_dirs')[1], ':t'))
+ eq(appname, fn.fnamemodify(fn.stdpath('data_dirs')[1], ':t'))
end
assert_alive() -- Check for crash. #8393
@@ -938,16 +938,16 @@ describe('stdpath()', function()
XDG_CONFIG_HOME = alter_slashes('/home/docwhat/.config'),
},
})
- eq(alter_slashes('/home/docwhat/.config/nvim'), funcs.stdpath('config'))
+ eq(alter_slashes('/home/docwhat/.config/nvim'), fn.stdpath('config'))
end)
it('handles changes during runtime', function()
clear({ env = {
XDG_CONFIG_HOME = alter_slashes('/home/original'),
} })
- eq(alter_slashes('/home/original/nvim'), funcs.stdpath('config'))
+ eq(alter_slashes('/home/original/nvim'), fn.stdpath('config'))
command("let $XDG_CONFIG_HOME='" .. alter_slashes('/home/new') .. "'")
- eq(alter_slashes('/home/new/nvim'), funcs.stdpath('config'))
+ eq(alter_slashes('/home/new/nvim'), fn.stdpath('config'))
end)
it("doesn't expand $VARIABLES", function()
@@ -957,14 +957,14 @@ describe('stdpath()', function()
VARIABLES = 'this-should-not-happen',
},
})
- eq(alter_slashes('$VARIABLES/nvim'), funcs.stdpath('config'))
+ eq(alter_slashes('$VARIABLES/nvim'), fn.stdpath('config'))
end)
it("doesn't expand ~/", function()
clear({ env = {
XDG_CONFIG_HOME = alter_slashes('~/frobnitz'),
} })
- eq(alter_slashes('~/frobnitz/nvim'), funcs.stdpath('config'))
+ eq(alter_slashes('~/frobnitz/nvim'), fn.stdpath('config'))
end)
end)
@@ -973,16 +973,16 @@ describe('stdpath()', function()
clear({ env = {
XDG_DATA_HOME = alter_slashes('/home/docwhat/.local'),
} })
- eq(alter_slashes('/home/docwhat/.local/' .. datadir), funcs.stdpath('data'))
+ eq(alter_slashes('/home/docwhat/.local/' .. datadir), fn.stdpath('data'))
end)
it('handles changes during runtime', function()
clear({ env = {
XDG_DATA_HOME = alter_slashes('/home/original'),
} })
- eq(alter_slashes('/home/original/' .. datadir), funcs.stdpath('data'))
+ eq(alter_slashes('/home/original/' .. datadir), fn.stdpath('data'))
command("let $XDG_DATA_HOME='" .. alter_slashes('/home/new') .. "'")
- eq(alter_slashes('/home/new/' .. datadir), funcs.stdpath('data'))
+ eq(alter_slashes('/home/new/' .. datadir), fn.stdpath('data'))
end)
it("doesn't expand $VARIABLES", function()
@@ -992,14 +992,14 @@ describe('stdpath()', function()
VARIABLES = 'this-should-not-happen',
},
})
- eq(alter_slashes('$VARIABLES/' .. datadir), funcs.stdpath('data'))
+ eq(alter_slashes('$VARIABLES/' .. datadir), fn.stdpath('data'))
end)
it("doesn't expand ~/", function()
clear({ env = {
XDG_DATA_HOME = alter_slashes('~/frobnitz'),
} })
- eq(alter_slashes('~/frobnitz/' .. datadir), funcs.stdpath('data'))
+ eq(alter_slashes('~/frobnitz/' .. datadir), fn.stdpath('data'))
end)
end)
@@ -1010,16 +1010,16 @@ describe('stdpath()', function()
XDG_STATE_HOME = alter_slashes('/home/docwhat/.local'),
},
})
- eq(alter_slashes('/home/docwhat/.local/' .. statedir), funcs.stdpath('state'))
+ eq(alter_slashes('/home/docwhat/.local/' .. statedir), fn.stdpath('state'))
end)
it('handles changes during runtime', function()
clear({ env = {
XDG_STATE_HOME = alter_slashes('/home/original'),
} })
- eq(alter_slashes('/home/original/' .. statedir), funcs.stdpath('state'))
+ eq(alter_slashes('/home/original/' .. statedir), fn.stdpath('state'))
command("let $XDG_STATE_HOME='" .. alter_slashes('/home/new') .. "'")
- eq(alter_slashes('/home/new/' .. statedir), funcs.stdpath('state'))
+ eq(alter_slashes('/home/new/' .. statedir), fn.stdpath('state'))
end)
it("doesn't expand $VARIABLES", function()
@@ -1029,14 +1029,14 @@ describe('stdpath()', function()
VARIABLES = 'this-should-not-happen',
},
})
- eq(alter_slashes('$VARIABLES/' .. statedir), funcs.stdpath('state'))
+ eq(alter_slashes('$VARIABLES/' .. statedir), fn.stdpath('state'))
end)
it("doesn't expand ~/", function()
clear({ env = {
XDG_STATE_HOME = alter_slashes('~/frobnitz'),
} })
- eq(alter_slashes('~/frobnitz/' .. statedir), funcs.stdpath('state'))
+ eq(alter_slashes('~/frobnitz/' .. statedir), fn.stdpath('state'))
end)
end)
@@ -1047,16 +1047,16 @@ describe('stdpath()', function()
XDG_CACHE_HOME = alter_slashes('/home/docwhat/.cache'),
},
})
- eq(alter_slashes('/home/docwhat/.cache/nvim'), funcs.stdpath('cache'))
+ eq(alter_slashes('/home/docwhat/.cache/nvim'), fn.stdpath('cache'))
end)
it('handles changes during runtime', function()
clear({ env = {
XDG_CACHE_HOME = alter_slashes('/home/original'),
} })
- eq(alter_slashes('/home/original/nvim'), funcs.stdpath('cache'))
+ eq(alter_slashes('/home/original/nvim'), fn.stdpath('cache'))
command("let $XDG_CACHE_HOME='" .. alter_slashes('/home/new') .. "'")
- eq(alter_slashes('/home/new/nvim'), funcs.stdpath('cache'))
+ eq(alter_slashes('/home/new/nvim'), fn.stdpath('cache'))
end)
it("doesn't expand $VARIABLES", function()
@@ -1066,14 +1066,14 @@ describe('stdpath()', function()
VARIABLES = 'this-should-not-happen',
},
})
- eq(alter_slashes('$VARIABLES/nvim'), funcs.stdpath('cache'))
+ eq(alter_slashes('$VARIABLES/nvim'), fn.stdpath('cache'))
end)
it("doesn't expand ~/", function()
clear({ env = {
XDG_CACHE_HOME = alter_slashes('~/frobnitz'),
} })
- eq(alter_slashes('~/frobnitz/nvim'), funcs.stdpath('cache'))
+ eq(alter_slashes('~/frobnitz/nvim'), fn.stdpath('cache'))
end)
end)
end)
@@ -1112,7 +1112,7 @@ describe('stdpath()', function()
local function set_paths_at_runtime(var_name, paths)
clear({ env = base_env() })
- meths.nvim_set_var('env_val', table.concat(paths, env_sep))
+ api.nvim_set_var('env_val', table.concat(paths, env_sep))
command(('let $%s=g:env_val'):format(var_name))
end
@@ -1120,12 +1120,12 @@ describe('stdpath()', function()
describe(msg, function()
it('set via system', function()
set_paths_via_system(env_var_name, paths)
- eq(expected_paths, funcs.stdpath(stdpath_arg))
+ eq(expected_paths, fn.stdpath(stdpath_arg))
end)
it('set at runtime', function()
set_paths_at_runtime(env_var_name, paths)
- eq(expected_paths, funcs.stdpath(stdpath_arg))
+ eq(expected_paths, fn.stdpath(stdpath_arg))
end)
end)
end