mirror of
https://github.com/neovim/neovim.git
synced 2026-04-21 14:55:33 +00:00
lua: move test helper function, map and filter, to vim.shared module
This commit is contained in:
@@ -6,7 +6,7 @@ local command = helpers.command
|
||||
local eq = helpers.eq
|
||||
local eval = helpers.eval
|
||||
local feed = helpers.feed
|
||||
local map = helpers.map
|
||||
local map = helpers.tbl_map
|
||||
local nvim = helpers.nvim
|
||||
local parse_context = helpers.parse_context
|
||||
local redir_exec = helpers.redir_exec
|
||||
|
||||
@@ -15,9 +15,9 @@ local check_cores = global_helpers.check_cores
|
||||
local check_logs = global_helpers.check_logs
|
||||
local dedent = global_helpers.dedent
|
||||
local eq = global_helpers.eq
|
||||
local filter = global_helpers.filter
|
||||
local filter = global_helpers.tbl_filter
|
||||
local is_os = global_helpers.is_os
|
||||
local map = global_helpers.map
|
||||
local map = global_helpers.tbl_map
|
||||
local ok = global_helpers.ok
|
||||
local sleep = global_helpers.sleep
|
||||
local tbl_contains = global_helpers.tbl_contains
|
||||
|
||||
@@ -384,6 +384,30 @@ describe('lua stdlib', function()
|
||||
end
|
||||
end)
|
||||
|
||||
it('vim.tbl_map', function()
|
||||
eq({}, exec_lua([[
|
||||
return vim.tbl_map(function(v) return v * 2 end, {})
|
||||
]]))
|
||||
eq({2, 4, 6}, exec_lua([[
|
||||
return vim.tbl_map(function(v) return v * 2 end, {1, 2, 3})
|
||||
]]))
|
||||
eq({{i=2}, {i=4}, {i=6}}, exec_lua([[
|
||||
return vim.tbl_map(function(v) return { i = v.i * 2 } end, {{i=1}, {i=2}, {i=3}})
|
||||
]]))
|
||||
end)
|
||||
|
||||
it('vim.tbl_filter', function()
|
||||
eq({}, exec_lua([[
|
||||
return vim.tbl_filter(function(v) return (v % 2) == 0 end, {})
|
||||
]]))
|
||||
eq({2}, exec_lua([[
|
||||
return vim.tbl_filter(function(v) return (v % 2) == 0 end, {1, 2, 3})
|
||||
]]))
|
||||
eq({{i=2}}, exec_lua([[
|
||||
return vim.tbl_filter(function(v) return (v.i % 2) == 0 end, {{i=1}, {i=2}, {i=3}})
|
||||
]]))
|
||||
end)
|
||||
|
||||
it('vim.tbl_islist', function()
|
||||
eq(true, exec_lua("return vim.tbl_islist({})"))
|
||||
eq(false, exec_lua("return vim.tbl_islist(vim.empty_dict())"))
|
||||
|
||||
@@ -6,8 +6,8 @@ local insert = helpers.insert
|
||||
local feed = helpers.feed
|
||||
local expect = helpers.expect
|
||||
local eq = helpers.eq
|
||||
local map = helpers.map
|
||||
local filter = helpers.filter
|
||||
local map = helpers.tbl_map
|
||||
local filter = helpers.tbl_filter
|
||||
local feed_command = helpers.feed_command
|
||||
local curbuf_contents = helpers.curbuf_contents
|
||||
local funcs = helpers.funcs
|
||||
|
||||
Reference in New Issue
Block a user