diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-04-13 19:53:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-13 19:53:09 +0200 |
commit | 82d48c0dab0fe595edd6331e0b6ba9630f86b34a (patch) | |
tree | 51a80521ae9bfe4f98c47934133967e456b12aef /test/helpers.lua | |
parent | cfe7f896b8e7a9188f79a4633f21e9ac4af57702 (diff) | |
parent | 7e1591e06ab85bf088c7482a15ad48fc58c1005d (diff) | |
download | rneovim-82d48c0dab0fe595edd6331e0b6ba9630f86b34a.tar.gz rneovim-82d48c0dab0fe595edd6331e0b6ba9630f86b34a.tar.bz2 rneovim-82d48c0dab0fe595edd6331e0b6ba9630f86b34a.zip |
Merge pull request #9896 from justinmk/api-async-error
API: emit nvim_error_event on failed async request
Diffstat (limited to 'test/helpers.lua')
-rw-r--r-- | test/helpers.lua | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/helpers.lua b/test/helpers.lua index 795808005d..89cf13f917 100644 --- a/test/helpers.lua +++ b/test/helpers.lua @@ -627,6 +627,19 @@ local function table_flatten(arr) return result end +-- Checks if a list-like (vector) table contains `value`. +local function table_contains(t, value) + if type(t) ~= 'table' then + error('t must be a table') + end + for _,v in ipairs(t) do + if v == value then + return true + end + end + return false +end + local function hexdump(str) local len = string.len(str) local dump = "" @@ -771,6 +784,7 @@ local module = { repeated_read_cmd = repeated_read_cmd, shallowcopy = shallowcopy, sleep = sleep, + table_contains = table_contains, table_flatten = table_flatten, tmpname = tmpname, uname = uname, |