aboutsummaryrefslogtreecommitdiff
path: root/test/unit/eval/helpers.lua
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2017-03-12 13:41:11 +0300
committerZyX <kp-pav@yandex.ru>2017-03-29 10:08:06 +0300
commita394167177390a66c275d32e3862c82c546970ff (patch)
tree484af6ef5a62874075e4d538934afaa4ace04f2d /test/unit/eval/helpers.lua
parenta32db8ed19c35847373d4a7fd56d7797a5a26897 (diff)
downloadrneovim-a394167177390a66c275d32e3862c82c546970ff.tar.gz
rneovim-a394167177390a66c275d32e3862c82c546970ff.tar.bz2
rneovim-a394167177390a66c275d32e3862c82c546970ff.zip
unittests: Test tv_list_item_\* functions
To check that memory is free()d correctly.
Diffstat (limited to 'test/unit/eval/helpers.lua')
-rw-r--r--test/unit/eval/helpers.lua11
1 files changed, 7 insertions, 4 deletions
diff --git a/test/unit/eval/helpers.lua b/test/unit/eval/helpers.lua
index c603953a05..8bf06e61f1 100644
--- a/test/unit/eval/helpers.lua
+++ b/test/unit/eval/helpers.lua
@@ -12,6 +12,7 @@ local null_string = {[true]='NULL string'}
local null_list = {[true]='NULL list'}
local null_dict = {[true]='NULL dict'}
local type_key = {[true]='type key'}
+local locks_key = {[true]='locks key'}
local list_type = {[true]='list type'}
local dict_type = {[true]='dict type'}
local func_type = {[true]='func type'}
@@ -23,9 +24,9 @@ local nil_value = {[true]='nil'}
local lua2typvalt
local function li_alloc(nogc)
- local gcfunc = eval.listitem_free
+ local gcfunc = eval.tv_list_item_free
if nogc then gcfunc = nil end
- local li = ffi.gc(eval.listitem_alloc(), gcfunc)
+ local li = ffi.gc(eval.tv_list_item_alloc(), gcfunc)
li.li_next = nil
li.li_prev = nil
li.li_tv = {v_type=eval.VAR_UNKNOWN, v_lock=eval.VAR_UNLOCKED}
@@ -373,8 +374,9 @@ lua2typvalt = function(l, processed)
end
end
+local void_ptr = ffi.typeof('void *')
local function void(ptr)
- return ffi.cast('void*', ptr)
+ return ffi.cast(void_ptr, ptr)
end
local alloc_logging_helpers = {
@@ -386,7 +388,7 @@ local alloc_logging_helpers = {
end,
str = function(s, size) return {func='malloc', args={size + 1}, ret=void(s)} end,
- freed = function(p) return {func='free', args={p and void(p)}} end,
+ freed = function(p) return {func='free', args={type(p) == 'table' and p or void(p)}} end,
}
return {
@@ -402,6 +404,7 @@ return {
nil_value=nil_value,
type_key=type_key,
+ locks_key=locks_key,
list=list,
lst2tbl=lst2tbl,