diff options
author | ZyX <kp-pav@yandex.ru> | 2017-01-07 15:45:27 +0300 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2017-01-07 15:54:55 +0300 |
commit | 88a4820cc9f6764b285eef239e103e4fc39c5667 (patch) | |
tree | 6203eeda3359e5028e57dce1878ea5a5aaa535b0 | |
parent | 728367a196c8396c8b186f1dbe2cf878a7fec038 (diff) | |
download | rneovim-88a4820cc9f6764b285eef239e103e4fc39c5667.tar.gz rneovim-88a4820cc9f6764b285eef239e103e4fc39c5667.tar.bz2 rneovim-88a4820cc9f6764b285eef239e103e4fc39c5667.zip |
unittest: Add failing test for freeing dictionaries in a list
-rw-r--r-- | test/unit/eval/tv_clear_spec.lua | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/test/unit/eval/tv_clear_spec.lua b/test/unit/eval/tv_clear_spec.lua index d6ef0caa1a..483afaee2b 100644 --- a/test/unit/eval/tv_clear_spec.lua +++ b/test/unit/eval/tv_clear_spec.lua @@ -10,6 +10,7 @@ local a = eval_helpers.alloc_logging_helpers local type_key = eval_helpers.type_key local list_type = eval_helpers.list_type local list_items = eval_helpers.list_items +local dict_items = eval_helpers.dict_items local lua2typvalt = eval_helpers.lua2typvalt local lib = cimport('./src/nvim/eval_defs.h', './src/nvim/eval.h') @@ -76,4 +77,51 @@ describe('clear_tv()', function() a.freed(list_p), }) end) + it('successfully frees all dictionaries in [&d {}, *d]', function() + local d_inner = {} + local list = {d_inner, d_inner} + local list_tv = ffi.gc(lua2typvalt(list), nil) + local list_p = list_tv.vval.v_list + local lis = list_items(list_p) + local dict_inner_p = lis[1].li_tv.vval.v_dict + alloc_log:check({ + a.list(list_p), + a.dict(dict_inner_p), + a.li(lis[1]), + a.li(lis[2]), + }) + eq(2, dict_inner_p.dv_refcount) + lib.clear_tv(list_tv) + alloc_log:check({ + a.freed(dict_inner_p), + a.freed(lis[1]), + a.freed(lis[2]), + a.freed(list_p), + }) + end) + it('successfully frees all dictionaries in [&d {a: 1}, *d]', function() + local d_inner = {a=1} + local list = {d_inner, d_inner} + local list_tv = ffi.gc(lua2typvalt(list), nil) + local list_p = list_tv.vval.v_list + local lis = list_items(list_p) + local dict_inner_p = lis[1].li_tv.vval.v_dict + local dis = dict_items(dict_inner_p) + alloc_log:check({ + a.list(list_p), + a.dict(dict_inner_p), + a.di(dis.a, 1), + a.li(lis[1]), + a.li(lis[2]), + }) + eq(2, dict_inner_p.dv_refcount) + lib.clear_tv(list_tv) + alloc_log:check({ + a.freed(dis.a), + a.freed(dict_inner_p), + a.freed(lis[1]), + a.freed(lis[2]), + a.freed(list_p), + }) + end) end) |