@@ -61,6 +61,97 @@ func Test_bunload_with_offset()
6161 call delete (' b2' )
6262 call delete (' b3' )
6363 call delete (' b4' )
64+
65+ call assert_fails (' 1,4bunload' , ' E16:' )
66+ call assert_fails (' ,100bunload' , ' E16:' )
67+
68+ " Use a try-catch for this test. When assert_fails() is used for this
69+ " test, the command fails with E515: instead of E90:
70+ let caught_E90 = 0
71+ try
72+ $bunload
73+ catch /E90:/
74+ let caught_E90 = 1
75+ endtry
76+ call assert_equal (1 , caught_E90)
77+ call assert_fails (' $bunload' , ' E515:' )
78+ endfunc
79+
80+ " Test for :buffer, :bnext, :bprevious, :brewind, :blast and :bmodified
81+ " commands
82+ func Test_buflist_browse ()
83+ % bwipe!
84+ call assert_fails (' buffer 1000' , ' E86:' )
85+
86+ call writefile ([' foo1' , ' foo2' , ' foo3' , ' foo4' ], ' Xfile1' )
87+ call writefile ([' bar1' , ' bar2' , ' bar3' , ' bar4' ], ' Xfile2' )
88+ call writefile ([' baz1' , ' baz2' , ' baz3' , ' baz4' ], ' Xfile3' )
89+ edit Xfile1
90+ let b1 = bufnr ()
91+ edit Xfile2
92+ let b2 = bufnr ()
93+ edit + /baz4 Xfile3
94+ let b3 = bufnr ()
95+
96+ call assert_fails (' buffer ' .. b1 .. ' abc' , ' E488:' )
97+ call assert_equal (b3, bufnr ())
98+ call assert_equal (4 , line (' .' ))
99+ exe ' buffer +/bar2 ' .. b2
100+ call assert_equal (b2, bufnr ())
101+ call assert_equal (2 , line (' .' ))
102+ exe ' buffer +/bar1'
103+ call assert_equal (b2, bufnr ())
104+ call assert_equal (1 , line (' .' ))
105+
106+ brewind + /foo3
107+ call assert_equal (b1, bufnr ())
108+ call assert_equal (3 , line (' .' ))
109+
110+ blast + /baz2
111+ call assert_equal (b3, bufnr ())
112+ call assert_equal (2 , line (' .' ))
113+
114+ bprevious + /bar4
115+ call assert_equal (b2, bufnr ())
116+ call assert_equal (4 , line (' .' ))
117+
118+ bnext + /baz3
119+ call assert_equal (b3, bufnr ())
120+ call assert_equal (3 , line (' .' ))
121+
122+ call assert_fails (' bmodified' , ' E84:' )
123+ call setbufvar (b2, ' &modified' , 1 )
124+ exe ' bmodified +/bar3'
125+ call assert_equal (b2, bufnr ())
126+ call assert_equal (3 , line (' .' ))
127+
128+ " With no listed buffers in the list, :bnext and :bprev should fail
129+ % bwipe!
130+ set nobuflisted
131+ call assert_fails (' bnext' , ' E85:' )
132+ call assert_fails (' bprev' , ' E85:' )
133+ set buflisted
134+
135+ call assert_fails (' sandbox bnext' , ' E48:' )
136+
137+ call delete (' Xfile1' )
138+ call delete (' Xfile2' )
139+ call delete (' Xfile3' )
140+ % bwipe!
141+ endfunc
142+
143+ " Test for :bdelete
144+ func Test_bdelete_cmd ()
145+ % bwipe!
146+ call assert_fails (' bdelete 5' , ' E516:' )
147+
148+ " Deleting a unlisted and unloaded buffer
149+ edit Xfile1
150+ let bnr = bufnr ()
151+ set nobuflisted
152+ enew
153+ call assert_fails (' bdelete ' .. bnr, ' E516:' )
154+ % bwipe!
64155endfunc
65156
66157" vim: shiftwidth = 2 sts = 2 expandtab
0 commit comments