Mercurial > vim
comparison src/testdir/test_buffer.vim @ 19407:2f4be7ca1b1b v8.2.0261
patch 8.2.0261: some code not covered by tests
Commit: https://github.com/vim/vim/commit/f0cee1971f5258ce61f8a4e6a04d35c1e625bb01
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Feb 16 13:33:56 2020 +0100
patch 8.2.0261: some code not covered by tests
Problem: Some code not covered by tests.
Solution: Add test cases. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5645)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 16 Feb 2020 13:45:04 +0100 |
parents | 02111977dd05 |
children | 67fbe280a502 |
comparison
equal
deleted
inserted
replaced
19406:9f499efdf2aa | 19407:2f4be7ca1b1b |
---|---|
59 %bwipe! | 59 %bwipe! |
60 call delete('b1') | 60 call delete('b1') |
61 call delete('b2') | 61 call delete('b2') |
62 call delete('b3') | 62 call delete('b3') |
63 call delete('b4') | 63 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! | |
64 endfunc | 155 endfunc |
65 | 156 |
66 " vim: shiftwidth=2 sts=2 expandtab | 157 " vim: shiftwidth=2 sts=2 expandtab |