mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 03:05:11 -07:00
test: add more structure to vim.bo/wo tests
This commit is contained in:
parent
c966654faa
commit
d27bbebf8e
@ -504,63 +504,71 @@ describe('lua stdlib', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
describe('options', function()
|
describe('options', function()
|
||||||
it('vim.bo', function()
|
describe('vim.bo', function()
|
||||||
eq('', fn.luaeval 'vim.bo.filetype')
|
it('can get and set options', function()
|
||||||
exec_lua(function()
|
eq('', fn.luaeval 'vim.bo.filetype')
|
||||||
_G.BUF = vim.api.nvim_create_buf(false, true)
|
exec_lua(function()
|
||||||
vim.api.nvim_set_option_value('filetype', 'markdown', {})
|
_G.BUF = vim.api.nvim_create_buf(false, true)
|
||||||
vim.api.nvim_set_option_value('modifiable', false, { buf = _G.BUF })
|
vim.api.nvim_set_option_value('filetype', 'markdown', {})
|
||||||
|
vim.api.nvim_set_option_value('modifiable', false, { buf = _G.BUF })
|
||||||
|
end)
|
||||||
|
eq(false, fn.luaeval 'vim.bo.modified')
|
||||||
|
eq('markdown', fn.luaeval 'vim.bo.filetype')
|
||||||
|
eq(false, fn.luaeval 'vim.bo[BUF].modifiable')
|
||||||
|
exec_lua(function()
|
||||||
|
vim.bo.filetype = ''
|
||||||
|
vim.bo[_G.BUF].modifiable = true
|
||||||
|
end)
|
||||||
|
eq('', fn.luaeval 'vim.bo.filetype')
|
||||||
|
eq(true, fn.luaeval 'vim.bo[BUF].modifiable')
|
||||||
end)
|
end)
|
||||||
eq(false, fn.luaeval 'vim.bo.modified')
|
|
||||||
eq('markdown', fn.luaeval 'vim.bo.filetype')
|
it('errors', function()
|
||||||
eq(false, fn.luaeval 'vim.bo[BUF].modifiable')
|
matches("Unknown option 'nosuchopt'$", pcall_err(exec_lua, 'return vim.bo.nosuchopt'))
|
||||||
exec_lua(function()
|
matches('Expected Lua string$', pcall_err(exec_lua, 'return vim.bo[0][0].autoread'))
|
||||||
vim.bo.filetype = ''
|
matches('Invalid buffer id: %-1$', pcall_err(exec_lua, 'return vim.bo[-1].filetype'))
|
||||||
vim.bo[_G.BUF].modifiable = true
|
|
||||||
end)
|
end)
|
||||||
eq('', fn.luaeval 'vim.bo.filetype')
|
|
||||||
eq(true, fn.luaeval 'vim.bo[BUF].modifiable')
|
|
||||||
matches("Unknown option 'nosuchopt'$", pcall_err(exec_lua, 'return vim.bo.nosuchopt'))
|
|
||||||
matches('Expected Lua string$', pcall_err(exec_lua, 'return vim.bo[0][0].autoread'))
|
|
||||||
matches('Invalid buffer id: %-1$', pcall_err(exec_lua, 'return vim.bo[-1].filetype'))
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('vim.wo', function()
|
describe('vim.wo', function()
|
||||||
exec_lua(function()
|
it('can get and set options', function()
|
||||||
vim.api.nvim_set_option_value('cole', 2, {})
|
exec_lua(function()
|
||||||
vim.cmd 'split'
|
vim.api.nvim_set_option_value('cole', 2, {})
|
||||||
vim.api.nvim_set_option_value('cole', 2, {})
|
vim.cmd 'split'
|
||||||
end)
|
vim.api.nvim_set_option_value('cole', 2, {})
|
||||||
eq(2, fn.luaeval 'vim.wo.cole')
|
end)
|
||||||
exec_lua(function()
|
eq(2, fn.luaeval 'vim.wo.cole')
|
||||||
vim.wo.conceallevel = 0
|
exec_lua(function()
|
||||||
end)
|
vim.wo.conceallevel = 0
|
||||||
eq(0, fn.luaeval 'vim.wo.cole')
|
end)
|
||||||
eq(0, fn.luaeval 'vim.wo[0].cole')
|
eq(0, fn.luaeval 'vim.wo.cole')
|
||||||
eq(0, fn.luaeval 'vim.wo[1001].cole')
|
eq(0, fn.luaeval 'vim.wo[0].cole')
|
||||||
matches("Unknown option 'notanopt'$", pcall_err(exec_lua, 'return vim.wo.notanopt'))
|
eq(0, fn.luaeval 'vim.wo[1001].cole')
|
||||||
matches('Invalid window id: %-1$', pcall_err(exec_lua, 'return vim.wo[-1].list'))
|
matches("Unknown option 'notanopt'$", pcall_err(exec_lua, 'return vim.wo.notanopt'))
|
||||||
eq(2, fn.luaeval 'vim.wo[1000].cole')
|
matches('Invalid window id: %-1$', pcall_err(exec_lua, 'return vim.wo[-1].list'))
|
||||||
exec_lua(function()
|
eq(2, fn.luaeval 'vim.wo[1000].cole')
|
||||||
vim.wo[1000].cole = 0
|
exec_lua(function()
|
||||||
end)
|
vim.wo[1000].cole = 0
|
||||||
eq(0, fn.luaeval 'vim.wo[1000].cole')
|
end)
|
||||||
|
eq(0, fn.luaeval 'vim.wo[1000].cole')
|
||||||
|
|
||||||
-- Can handle global-local values
|
-- Can handle global-local values
|
||||||
exec_lua [[vim.o.scrolloff = 100]]
|
exec_lua [[vim.o.scrolloff = 100]]
|
||||||
exec_lua [[vim.wo.scrolloff = 200]]
|
exec_lua [[vim.wo.scrolloff = 200]]
|
||||||
eq(200, fn.luaeval 'vim.wo.scrolloff')
|
eq(200, fn.luaeval 'vim.wo.scrolloff')
|
||||||
exec_lua [[vim.wo.scrolloff = -1]]
|
exec_lua [[vim.wo.scrolloff = -1]]
|
||||||
eq(100, fn.luaeval 'vim.wo.scrolloff')
|
eq(100, fn.luaeval 'vim.wo.scrolloff')
|
||||||
exec_lua(function()
|
exec_lua(function()
|
||||||
vim.wo[0][0].scrolloff = 200
|
vim.wo[0][0].scrolloff = 200
|
||||||
vim.cmd 'enew'
|
vim.cmd 'enew'
|
||||||
|
end)
|
||||||
|
eq(100, fn.luaeval 'vim.wo.scrolloff')
|
||||||
end)
|
end)
|
||||||
eq(100, fn.luaeval 'vim.wo.scrolloff')
|
|
||||||
|
|
||||||
matches('only bufnr=0 is supported', pcall_err(exec_lua, 'vim.wo[0][10].signcolumn = "no"'))
|
it('errors', function()
|
||||||
|
matches('only bufnr=0 is supported', pcall_err(exec_lua, 'vim.wo[0][10].signcolumn = "no"'))
|
||||||
matches('only bufnr=0 is supported', pcall_err(exec_lua, 'local a = vim.wo[0][10].signcolumn'))
|
matches('only bufnr=0 is supported', pcall_err(exec_lua, 'local a = vim.wo[0][10].signcolumn'))
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('vim.opt', function()
|
describe('vim.opt', function()
|
||||||
|
Loading…
Reference in New Issue
Block a user