neovim/test/functional/vimscript/container_functions_spec.lua
dundargoc 052498ed42 test: improve test conventions
Specifically, functions that are run in the context of the test runner
are put in module `test/testutil.lua` while the functions that are run
in the context of the test session are put in
`test/functional/testnvim.lua`.

Closes https://github.com/neovim/neovim/issues/27004.
2024-04-23 18:17:04 +02:00

26 lines
684 B
Lua

local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local eq = t.eq
local eval = n.eval
local api = n.api
local clear = n.clear
before_each(clear)
describe('extend()', function()
it('succeeds to extend list with itself', function()
api.nvim_set_var('l', { 1, {} })
eq({ 1, {}, 1, {} }, eval('extend(l, l)'))
eq({ 1, {}, 1, {} }, api.nvim_get_var('l'))
api.nvim_set_var('l', { 1, {} })
eq({ 1, {}, 1, {} }, eval('extend(l, l, 0)'))
eq({ 1, {}, 1, {} }, api.nvim_get_var('l'))
api.nvim_set_var('l', { 1, {} })
eq({ 1, 1, {}, {} }, eval('extend(l, l, 1)'))
eq({ 1, 1, {}, {} }, api.nvim_get_var('l'))
end)
end)