diff options
Diffstat (limited to 'test/unit/api/private_helpers_spec.lua')
-rw-r--r-- | test/unit/api/private_helpers_spec.lua | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/test/unit/api/private_helpers_spec.lua b/test/unit/api/private_helpers_spec.lua index 1d7c03787b..a534d83165 100644 --- a/test/unit/api/private_helpers_spec.lua +++ b/test/unit/api/private_helpers_spec.lua @@ -1,4 +1,5 @@ -local helpers = require('test.unit.helpers') +local helpers = require('test.unit.helpers')(after_each) +local itp = helpers.gen_itp(it) local eval_helpers = require('test.unit.eval.helpers') local api_helpers = require('test.unit.api.helpers') @@ -7,6 +8,7 @@ local NULL = helpers.NULL local eq = helpers.eq local lua2typvalt = eval_helpers.lua2typvalt +local typvalt2lua = eval_helpers.typvalt2lua local typvalt = eval_helpers.typvalt local nil_value = api_helpers.nil_value @@ -14,6 +16,7 @@ local list_type = api_helpers.list_type local int_type = api_helpers.int_type local type_key = api_helpers.type_key local obj2lua = api_helpers.obj2lua +local func_type = api_helpers.func_type local api = cimport('./src/nvim/api/private/helpers.h') @@ -23,7 +26,7 @@ describe('vim_to_object', function() end local different_output_test = function(name, input, output) - it(name, function() + itp(name, function() eq(output, vim_to_object(input)) end) end @@ -74,15 +77,30 @@ describe('vim_to_object', function() different_output_test('outputs nil for nested lists (2 level, in dict)', lst3, {{lst=nil_value}, true, false, 'ttest'}) - it('outputs empty list for NULL list', function() + itp('outputs empty list for NULL list', function() local tt = typvalt('VAR_LIST', {v_list=NULL}) eq(nil, tt.vval.v_list) eq({[type_key]=list_type}, obj2lua(api.vim_to_object(tt))) end) - it('outputs empty dict for NULL dict', function() + itp('outputs empty dict for NULL dict', function() local tt = typvalt('VAR_DICT', {v_dict=NULL}) eq(nil, tt.vval.v_dict) eq({}, obj2lua(api.vim_to_object(tt))) end) + + itp('regression: partials in a list', function() + local llist = { + { + [type_key]=func_type, + value='printf', + args={'%s'}, + dict={v=1}, + }, + {}, + } + local list = lua2typvalt(llist) + eq(llist, typvalt2lua(list)) + eq({nil_value, {}}, obj2lua(api.vim_to_object(list))) + end) end) |