blob: dc35bb4b83bbbc08e74117ddac69490ffa849f81 [file] [log] [blame]
Bram Moolenaar9f6277b2020-02-11 22:04:02 +01001" Tests for Vim buffer
2
3" Test for the :bunload command with an offset
4func Test_bunload_with_offset()
5 %bwipe!
6 call writefile(['B1'], 'b1')
7 call writefile(['B2'], 'b2')
8 call writefile(['B3'], 'b3')
9 call writefile(['B4'], 'b4')
10
11 " Load four buffers. Unload the second and third buffers and then
12 " execute .+3bunload to unload the last buffer.
13 edit b1
14 new b2
15 new b3
16 new b4
17
18 bunload b2
19 bunload b3
20 exe bufwinnr('b1') . 'wincmd w'
21 .+3bunload
22 call assert_equal(0, getbufinfo('b4')[0].loaded)
23 call assert_equal('b1',
24 \ fnamemodify(getbufinfo({'bufloaded' : 1})[0].name, ':t'))
25
26 " Load four buffers. Unload the third and fourth buffers. Execute .+3bunload
27 " and check whether the second buffer is unloaded.
28 ball
29 bunload b3
30 bunload b4
31 exe bufwinnr('b1') . 'wincmd w'
32 .+3bunload
33 call assert_equal(0, getbufinfo('b2')[0].loaded)
34 call assert_equal('b1',
35 \ fnamemodify(getbufinfo({'bufloaded' : 1})[0].name, ':t'))
36
37 " Load four buffers. Unload the second and third buffers and from the last
38 " buffer execute .-3bunload to unload the first buffer.
39 ball
40 bunload b2
41 bunload b3
42 exe bufwinnr('b4') . 'wincmd w'
43 .-3bunload
44 call assert_equal(0, getbufinfo('b1')[0].loaded)
45 call assert_equal('b4',
46 \ fnamemodify(getbufinfo({'bufloaded' : 1})[0].name, ':t'))
47
48 " Load four buffers. Unload the first and second buffers. Execute .-3bunload
49 " from the last buffer and check whether the third buffer is unloaded.
50 ball
51 bunload b1
52 bunload b2
53 exe bufwinnr('b4') . 'wincmd w'
54 .-3bunload
55 call assert_equal(0, getbufinfo('b3')[0].loaded)
56 call assert_equal('b4',
57 \ fnamemodify(getbufinfo({'bufloaded' : 1})[0].name, ':t'))
58
59 %bwipe!
60 call delete('b1')
61 call delete('b2')
62 call delete('b3')
63 call delete('b4')
64endfunc
65
66" vim: shiftwidth=2 sts=2 expandtab