mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Hope this will make people using feed_command less likely: this hides bugs. Already found at least two: 1. msgpackparse() will show internal error: hash_add() in case of duplicate keys, though it will still work correctly. Currently silenced. 2. ttimeoutlen was spelled incorrectly, resulting in option not being set when expected. Test was still functioning somehow though. Currently fixed.
142 lines
4.2 KiB
Lua
142 lines
4.2 KiB
Lua
-- Tests for :[count]close! and :[count]hide
|
|
|
|
local helpers = require('test.functional.helpers')(after_each)
|
|
|
|
local eq = helpers.eq
|
|
local wait = helpers.wait
|
|
local feed = helpers.feed
|
|
local clear = helpers.clear
|
|
local command = helpers.command
|
|
|
|
describe('close_count', function()
|
|
setup(clear)
|
|
|
|
it('is working', function()
|
|
command('let tests = []')
|
|
command('for i in range(5)')
|
|
command('new')
|
|
command('endfor')
|
|
command('4wincmd w')
|
|
command('close!')
|
|
command('let buffers = []')
|
|
command('windo call add(buffers, bufnr("%"))')
|
|
eq({6, 5, 4, 2, 1}, eval('buffers'))
|
|
command('1close!')
|
|
command('let buffers = []')
|
|
command('windo call add(buffers, bufnr("%"))')
|
|
eq({5, 4, 2, 1}, eval('buffers'))
|
|
command('$close!')
|
|
command('let buffers = []')
|
|
command('windo call add(buffers, bufnr("%"))')
|
|
eq({5, 4, 2}, eval('buffers'))
|
|
command('1wincmd w')
|
|
command('2close!')
|
|
command('let buffers = []')
|
|
command('windo call add(buffers, bufnr("%"))')
|
|
eq({5, 2}, eval('buffers'))
|
|
command('1wincmd w')
|
|
command('new')
|
|
command('new')
|
|
command('2wincmd w')
|
|
command('-1close!')
|
|
command('let buffers = []')
|
|
command('windo call add(buffers, bufnr("%"))')
|
|
eq({7, 5, 2}, eval('buffers'))
|
|
command('2wincmd w')
|
|
command('+1close!')
|
|
command('let buffers = []')
|
|
command('windo call add(buffers, bufnr("%"))')
|
|
eq({7, 5}, eval('buffers'))
|
|
command('only!')
|
|
command('b1')
|
|
command('let tests = []')
|
|
command('for i in range(5)')
|
|
command('new')
|
|
command('endfor')
|
|
command('let buffers = []')
|
|
command('windo call add(buffers, bufnr("%"))')
|
|
eq({13, 12, 11, 10, 9, 1}, eval('buffers'))
|
|
command('4wincmd w')
|
|
command('.hide')
|
|
command('let buffers = []')
|
|
command('windo call add(buffers, bufnr("%"))')
|
|
eq({13, 12, 11, 9, 1}, eval('buffers'))
|
|
command('1hide')
|
|
command('let buffers = []')
|
|
command('windo call add(buffers, bufnr("%"))')
|
|
eq({12, 11, 9, 1}, eval('buffers'))
|
|
command('$hide')
|
|
command('let buffers = []')
|
|
command('windo call add(buffers, bufnr("%"))')
|
|
eq({12, 11, 9}, eval('buffers'))
|
|
command('1wincmd w')
|
|
command('2hide')
|
|
command('let buffers = []')
|
|
command('windo call add(buffers, bufnr("%"))')
|
|
eq({12, 9}, eval('buffers'))
|
|
command('1wincmd w')
|
|
command('new')
|
|
command('new')
|
|
command('3wincmd w')
|
|
command('-hide')
|
|
command('let buffers = []')
|
|
command('windo call add(buffers, bufnr("%"))')
|
|
eq({15, 12, 9}, eval('buffers'))
|
|
command('2wincmd w')
|
|
command('+hide')
|
|
command('let buffers = []')
|
|
command('windo call add(buffers, bufnr("%"))')
|
|
eq({15, 12}, eval('buffers'))
|
|
command('only!')
|
|
command('b1')
|
|
command('let tests = []')
|
|
command('set hidden')
|
|
command('for i in range(5)')
|
|
command('new')
|
|
command('endfor')
|
|
command('1wincmd w')
|
|
command('$ hide')
|
|
command('let buffers = []')
|
|
command('windo call add(buffers, bufnr("%"))')
|
|
eq({20, 19, 18, 17, 16}, eval('buffers'))
|
|
command('$-1 close!')
|
|
command('let buffers = []')
|
|
command('windo call add(buffers, bufnr("%"))')
|
|
eq({20, 19, 18, 16}, eval('buffers'))
|
|
command('1wincmd w')
|
|
command('.+close!')
|
|
command('let buffers = []')
|
|
command('windo call add(buffers, bufnr("%"))')
|
|
eq({20, 18, 16}, eval('buffers'))
|
|
command('only!')
|
|
command('b1')
|
|
command('let tests = []')
|
|
command('set hidden')
|
|
command('for i in range(5)')
|
|
command('new')
|
|
command('endfor')
|
|
command('4wincmd w')
|
|
feed('<C-W>c<cr>')
|
|
wait()
|
|
command('let buffers = []')
|
|
command('windo call add(buffers, bufnr("%"))')
|
|
eq({25, 24, 23, 21, 1}, eval('buffers'))
|
|
feed('1<C-W>c<cr>')
|
|
wait()
|
|
command('let buffers = []')
|
|
command('windo call add(buffers, bufnr("%"))')
|
|
eq({24, 23, 21, 1}, eval('buffers'))
|
|
feed('9<C-W>c<cr>')
|
|
wait()
|
|
command('let buffers = []')
|
|
command('windo call add(buffers, bufnr("%"))')
|
|
eq({24, 23, 21}, eval('buffers'))
|
|
command('1wincmd w')
|
|
feed('2<C-W>c<cr>')
|
|
wait()
|
|
command('let buffers = []')
|
|
command('windo call add(buffers, bufnr("%"))')
|
|
eq({24, 21}, eval('buffers'))
|
|
end)
|
|
end)
|