aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/vim_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/lua/vim_spec.lua')
-rw-r--r--test/functional/lua/vim_spec.lua56
1 files changed, 23 insertions, 33 deletions
diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua
index 0f51831d52..dd0c3d3868 100644
--- a/test/functional/lua/vim_spec.lua
+++ b/test/functional/lua/vim_spec.lua
@@ -129,51 +129,41 @@ describe('lua stdlib', function()
eq(1, fn.luaeval('vim.stricmp("\\0C\\0", "\\0B\\0")'))
end)
- local function test_vim_deprecate(current_version)
+ --- @param prerel string | nil
+ local function test_vim_deprecate(prerel)
-- vim.deprecate(name, alternative, version, plugin, backtrace)
-- See MAINTAIN.md for the soft/hard deprecation policy
- describe(('vim.deprecate [current_version = %s]'):format(current_version), function()
- before_each(function()
- -- mock vim.version() behavior, should be pinned for consistent testing
- exec_lua(
- [[
- local current_version_mock = vim.version.parse(...)
- getmetatable(vim.version).__call = function()
- return current_version_mock
- end
- ]],
- current_version
- )
- end)
+ describe(('vim.deprecate prerel=%s,'):format(prerel or 'nil'), function()
+ it('plugin=nil', function()
+ local curver = exec_lua('return vim.version()') --[[@as {major:number, minor:number}]]
+ -- "0.10" or "0.10-dev+xxx"
+ local curstr = ('%s.%s%s'):format(curver.major, curver.minor, prerel or '')
+ -- "0.10" or "0.11"
+ local nextver = ('%s.%s'):format(curver.major, curver.minor + (prerel and 0 or 1))
+ local was_removed = prerel and 'was removed' or 'will be removed'
- it('when plugin = nil', function()
- local cur = vim.version.parse(current_version)
- local cur_to_compare = cur.major .. '.' .. cur.minor
- local was_removed = (
- vim.version.ge(cur_to_compare, '0.10') and 'was removed' or 'will be removed'
- )
eq(
dedent([[
foo.bar() is deprecated, use zub.wooo{ok=yay} instead. :help deprecated
- Feature %s in Nvim 0.10]]):format(was_removed),
- exec_lua('return vim.deprecate(...)', 'foo.bar()', 'zub.wooo{ok=yay}', '0.10')
+ Feature was removed in Nvim %s]]):format(curstr),
+ exec_lua('return vim.deprecate(...)', 'foo.bar()', 'zub.wooo{ok=yay}', curstr)
)
- -- Same message, skipped.
- eq(vim.NIL, exec_lua('return vim.deprecate(...)', 'foo.bar()', 'zub.wooo{ok=yay}', '0.10'))
+ -- Same message as above; skipped this time.
+ eq(vim.NIL, exec_lua('return vim.deprecate(...)', 'foo.bar()', 'zub.wooo{ok=yay}', curstr))
- -- Don't show error if not hard-deprecated (only soft-deprecated)
+ -- No error if soft-deprecated.
eq(
vim.NIL,
- exec_lua('return vim.deprecate(...)', 'foo.baz()', 'foo.better_baz()', '0.12.0')
+ exec_lua('return vim.deprecate(...)', 'foo.baz()', 'foo.better_baz()', '0.99.0')
)
- -- Show error if hard-deprecated
+ -- Show error if hard-deprecated.
eq(
- dedent [[
+ dedent([[
foo.hard_dep() is deprecated, use vim.new_api() instead. :help deprecated
- Feature will be removed in Nvim 0.11]],
- exec_lua('return vim.deprecate(...)', 'foo.hard_dep()', 'vim.new_api()', '0.11')
+ Feature %s in Nvim %s]]):format(was_removed, nextver),
+ exec_lua('return vim.deprecate(...)', 'foo.hard_dep()', 'vim.new_api()', nextver)
)
-- To be deleted in the next major version (1.0)
@@ -185,7 +175,7 @@ describe('lua stdlib', function()
)
end)
- it('when plugin is specified', function()
+ it('plugin specified', function()
-- When `plugin` is specified, don't show ":help deprecated". #22235
eq(
dedent [[
@@ -219,8 +209,8 @@ describe('lua stdlib', function()
end)
end
- test_vim_deprecate('0.10')
- test_vim_deprecate('0.10-dev+g0000000')
+ test_vim_deprecate()
+ test_vim_deprecate('-dev+g0000000')
it('vim.startswith', function()
eq(true, fn.luaeval('vim.startswith("123", "1")'))