test(api): allow added optional params

This commit is contained in:
Barrett Ruth
2026-07-13 14:46:58 -05:00
parent 715d8887ec
commit 6ffbb2962c

View File

@@ -93,6 +93,9 @@ describe('api metadata', function()
error(('"%s": parameter %d was optional, now required'):format(old_fn.name, idx))
end
end
while #new_fn.parameters > #old_fn.parameters and new_fn.parameters[#new_fn.parameters][3] do
table.remove(new_fn.parameters)
end
old_fn = normalize_func_metadata(old_fn)
new_fn = normalize_func_metadata(new_fn)
if old_fn.return_type == 'void' then
@@ -248,6 +251,22 @@ describe('api metadata', function()
)
end)
it('optional param may be added', function()
assert_func_backcompat({
name = 'nvim_example',
method = false,
since = 1,
return_type = 'void',
parameters = { { 'String', 'src', false } },
}, {
name = 'nvim_example',
method = false,
since = 1,
return_type = 'void',
parameters = { { 'String', 'src', false }, { 'Dict', 'opts', true } },
})
end)
it('UI events are compatible with old metadata or have new level', function()
local ui_events_new = name_table(api_info.ui_events)
local ui_events_compat = {}