diff options
author | ZyX <kp-pav@yandex.ru> | 2016-11-05 00:07:34 +0300 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2017-03-29 10:08:06 +0300 |
commit | 56e51033abf00d66e9c6f9412e8f57c9a24b86ae (patch) | |
tree | 8363c013f1554e553aad5f020b23358fe941dafa /test | |
parent | e5edf07ec44f8d147d7482cae2997be62c30373f (diff) | |
download | rneovim-56e51033abf00d66e9c6f9412e8f57c9a24b86ae.tar.gz rneovim-56e51033abf00d66e9c6f9412e8f57c9a24b86ae.tar.bz2 rneovim-56e51033abf00d66e9c6f9412e8f57c9a24b86ae.zip |
unittests: Add tests for tv_list_idx_of_item
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/eval/typval_spec.lua | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/unit/eval/typval_spec.lua b/test/unit/eval/typval_spec.lua index 94ee394009..d308ee5794 100644 --- a/test/unit/eval/typval_spec.lua +++ b/test/unit/eval/typval_spec.lua @@ -1324,5 +1324,21 @@ describe('typval.c', function() end) end) end) + describe('idx_of_item()', function() + it('works', function() + local l = list(1, 2, 3, 4, 5) + local l2 = list(42, empty_list) + local lis = list_items(l) + local lis2 = list_items(l2) + + for i, li in ipairs(lis) do + eq(i - 1, lib.tv_list_idx_of_item(l, li)) + end + eq(-1, lib.tv_list_idx_of_item(l, lis2[1])) + eq(-1, lib.tv_list_idx_of_item(l, nil)) + eq(-1, lib.tv_list_idx_of_item(nil, nil)) + eq(-1, lib.tv_list_idx_of_item(nil, lis[1])) + end) + end) end) end) |