aboutsummaryrefslogtreecommitdiff
path: root/test/unit/api/private_helpers_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit/api/private_helpers_spec.lua')
-rw-r--r--test/unit/api/private_helpers_spec.lua80
1 files changed, 46 insertions, 34 deletions
diff --git a/test/unit/api/private_helpers_spec.lua b/test/unit/api/private_helpers_spec.lua
index dbb4b3ae5a..9843bd5c9e 100644
--- a/test/unit/api/private_helpers_spec.lua
+++ b/test/unit/api/private_helpers_spec.lua
@@ -22,7 +22,7 @@ local api = cimport('./src/nvim/api/private/helpers.h', './src/nvim/api/private/
describe('vim_to_object', function()
local vim_to_object = function(l)
- return obj2lua(api.vim_to_object(lua2typvalt(l)))
+ return obj2lua(api.vim_to_object(lua2typvalt(l), nil, false))
end
local different_output_test = function(name, input, output)
@@ -42,65 +42,77 @@ describe('vim_to_object', function()
simple_test('converts -1.5', -1.5)
simple_test('converts empty string', '')
simple_test('converts non-empty string', 'foobar')
- simple_test('converts integer 10', {[type_key]=int_type, value=10})
+ simple_test('converts integer 10', { [type_key] = int_type, value = 10 })
simple_test('converts empty dictionary', {})
- simple_test('converts dictionary with scalar values', {test=10, test2=true, test3='test'})
- simple_test('converts dictionary with containers inside', {test={}, test2={1, 2}})
- simple_test('converts empty list', {[type_key]=list_type})
- simple_test('converts list with scalar values', {1, 2, 'test', 'foo'})
- simple_test('converts list with containers inside', {{}, {test={}, test3={test4=true}}})
+ simple_test('converts dictionary with scalar values', { test = 10, test2 = true, test3 = 'test' })
+ simple_test('converts dictionary with containers inside', { test = {}, test2 = { 1, 2 } })
+ simple_test('converts empty list', { [type_key] = list_type })
+ simple_test('converts list with scalar values', { 1, 2, 'test', 'foo' })
+ simple_test(
+ 'converts list with containers inside',
+ { {}, { test = {}, test3 = { test4 = true } } }
+ )
local dct = {}
dct.dct = dct
- different_output_test('outputs nil for nested dictionaries (1 level)', dct, {dct=nil_value})
+ different_output_test('outputs nil for nested dictionaries (1 level)', dct, { dct = nil_value })
local lst = {}
lst[1] = lst
- different_output_test('outputs nil for nested lists (1 level)', lst, {nil_value})
-
- local dct2 = {test=true, dict=nil_value}
- dct2.dct = {dct2}
- different_output_test('outputs nil for nested dictionaries (2 level, in list)',
- dct2, {dct={nil_value}, test=true, dict=nil_value})
-
- local dct3 = {test=true, dict=nil_value}
- dct3.dct = {dctin=dct3}
- different_output_test('outputs nil for nested dictionaries (2 level, in dict)',
- dct3, {dct={dctin=nil_value}, test=true, dict=nil_value})
+ different_output_test('outputs nil for nested lists (1 level)', lst, { nil_value })
+
+ local dct2 = { test = true, dict = nil_value }
+ dct2.dct = { dct2 }
+ different_output_test(
+ 'outputs nil for nested dictionaries (2 level, in list)',
+ dct2,
+ { dct = { nil_value }, test = true, dict = nil_value }
+ )
+
+ local dct3 = { test = true, dict = nil_value }
+ dct3.dct = { dctin = dct3 }
+ different_output_test(
+ 'outputs nil for nested dictionaries (2 level, in dict)',
+ dct3,
+ { dct = { dctin = nil_value }, test = true, dict = nil_value }
+ )
local lst2 = {}
- lst2[1] = {lst2}
- different_output_test('outputs nil for nested lists (2 level, in list)', lst2, {{nil_value}})
+ lst2[1] = { lst2 }
+ different_output_test('outputs nil for nested lists (2 level, in list)', lst2, { { nil_value } })
- local lst3 = {nil, true, false, 'ttest'}
- lst3[1] = {lst=lst3}
- different_output_test('outputs nil for nested lists (2 level, in dict)',
- lst3, {{lst=nil_value}, true, false, 'ttest'})
+ local lst3 = { nil, true, false, 'ttest' }
+ lst3[1] = { lst = lst3 }
+ different_output_test(
+ 'outputs nil for nested lists (2 level, in dict)',
+ lst3,
+ { { lst = nil_value }, true, false, 'ttest' }
+ )
itp('outputs empty list for NULL list', function()
- local tt = typvalt('VAR_LIST', {v_list=NULL})
+ 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)))
+ eq({ [type_key] = list_type }, obj2lua(api.vim_to_object(tt, nil, false)))
end)
itp('outputs empty dict for NULL dict', function()
- local tt = typvalt('VAR_DICT', {v_dict=NULL})
+ local tt = typvalt('VAR_DICT', { v_dict = NULL })
eq(nil, tt.vval.v_dict)
- eq({}, obj2lua(api.vim_to_object(tt)))
+ eq({}, obj2lua(api.vim_to_object(tt, nil, false)))
end)
itp('regression: partials in a list', function()
local llist = {
{
- [type_key]=func_type,
- value='printf',
- args={'%s'},
- dict={v=1},
+ [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)))
+ eq({ nil_value, {} }, obj2lua(api.vim_to_object(list, nil, false)))
end)
end)