robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

Justin M. KeyesMerge #40865 from justinmk/fixcif907614088

master
4.2 KiB136 linesraw
1-- Tests for :[count]close! and :[count]hide
2
3local t = require('test.testutil')
4local n = require('test.functional.testnvim')()
5
6local describe, it, setup = t.describe, t.it, t.setup
7local eq = t.eq
8local poke_eventloop = n.poke_eventloop
9local eval = n.eval
10local feed = n.feed
11local clear = n.clear
12local command = n.command
13
14describe('close_count', function()
15  setup(clear)
16
17  it('is working', function()
18    command('let tests = []')
19    command('for i in range(5)|new|endfor')
20    command('4wincmd w')
21    command('close!')
22    command('let buffers = []')
23    command('windo call add(buffers, bufnr("%"))')
24    eq({ 6, 5, 4, 2, 1 }, eval('buffers'))
25    command('1close!')
26    command('let buffers = []')
27    command('windo call add(buffers, bufnr("%"))')
28    eq({ 5, 4, 2, 1 }, eval('buffers'))
29    command('$close!')
30    command('let buffers = []')
31    command('windo call add(buffers, bufnr("%"))')
32    eq({ 5, 4, 2 }, eval('buffers'))
33    command('1wincmd w')
34    command('2close!')
35    command('let buffers = []')
36    command('windo call add(buffers, bufnr("%"))')
37    eq({ 5, 2 }, eval('buffers'))
38    command('1wincmd w')
39    command('new')
40    command('new')
41    command('2wincmd w')
42    command('-1close!')
43    command('let buffers = []')
44    command('windo call add(buffers, bufnr("%"))')
45    eq({ 7, 5, 2 }, eval('buffers'))
46    command('2wincmd w')
47    command('+1close!')
48    command('let buffers = []')
49    command('windo call add(buffers, bufnr("%"))')
50    eq({ 7, 5 }, eval('buffers'))
51    command('only!')
52    command('b1')
53    command('let tests = []')
54    command('for i in range(5)|new|endfor')
55    command('let buffers = []')
56    command('windo call add(buffers, bufnr("%"))')
57    eq({ 13, 12, 11, 10, 9, 1 }, eval('buffers'))
58    command('4wincmd w')
59    command('.hide')
60    command('let buffers = []')
61    command('windo call add(buffers, bufnr("%"))')
62    eq({ 13, 12, 11, 9, 1 }, eval('buffers'))
63    command('1hide')
64    command('let buffers = []')
65    command('windo call add(buffers, bufnr("%"))')
66    eq({ 12, 11, 9, 1 }, eval('buffers'))
67    command('$hide')
68    command('let buffers = []')
69    command('windo call add(buffers, bufnr("%"))')
70    eq({ 12, 11, 9 }, eval('buffers'))
71    command('1wincmd w')
72    command('2hide')
73    command('let buffers = []')
74    command('windo call add(buffers, bufnr("%"))')
75    eq({ 12, 9 }, eval('buffers'))
76    command('1wincmd w')
77    command('new')
78    command('new')
79    command('3wincmd w')
80    command('-hide')
81    command('let buffers = []')
82    command('windo call add(buffers, bufnr("%"))')
83    eq({ 15, 12, 9 }, eval('buffers'))
84    command('2wincmd w')
85    command('+hide')
86    command('let buffers = []')
87    command('windo call add(buffers, bufnr("%"))')
88    eq({ 15, 12 }, eval('buffers'))
89    command('only!')
90    command('b1')
91    command('let tests = []')
92    command('set hidden')
93    command('for i in range(5)|new|endfor')
94    command('1wincmd w')
95    command('$ hide')
96    command('let buffers = []')
97    command('windo call add(buffers, bufnr("%"))')
98    eq({ 20, 19, 18, 17, 16 }, eval('buffers'))
99    command('$-1 close!')
100    command('let buffers = []')
101    command('windo call add(buffers, bufnr("%"))')
102    eq({ 20, 19, 18, 16 }, eval('buffers'))
103    command('1wincmd w')
104    command('.+close!')
105    command('let buffers = []')
106    command('windo call add(buffers, bufnr("%"))')
107    eq({ 20, 18, 16 }, eval('buffers'))
108    command('only!')
109    command('b1')
110    command('let tests = []')
111    command('set hidden')
112    command('for i in range(5)|new|endfor')
113    command('4wincmd w')
114    feed('<C-W>c<cr>')
115    poke_eventloop()
116    command('let buffers = []')
117    command('windo call add(buffers, bufnr("%"))')
118    eq({ 25, 24, 23, 21, 1 }, eval('buffers'))
119    feed('1<C-W>c<cr>')
120    poke_eventloop()
121    command('let buffers = []')
122    command('windo call add(buffers, bufnr("%"))')
123    eq({ 24, 23, 21, 1 }, eval('buffers'))
124    feed('9<C-W>c<cr>')
125    poke_eventloop()
126    command('let buffers = []')
127    command('windo call add(buffers, bufnr("%"))')
128    eq({ 24, 23, 21 }, eval('buffers'))
129    command('1wincmd w')
130    feed('2<C-W>c<cr>')
131    poke_eventloop()
132    command('let buffers = []')
133    command('windo call add(buffers, bufnr("%"))')
134    eq({ 24, 21 }, eval('buffers'))
135  end)
136end)