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