From 6ffbb2962c2ef9b2174e19f2e609fe6962e7a6b4 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Mon, 13 Jul 2026 14:46:58 -0500 Subject: [PATCH] test(api): allow added optional params --- test/functional/api/version_spec.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/functional/api/version_spec.lua b/test/functional/api/version_spec.lua index 2b5ef149ae..0a55f30ee7 100644 --- a/test/functional/api/version_spec.lua +++ b/test/functional/api/version_spec.lua @@ -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 = {}