Mercurial > vim
comparison src/testdir/test_writefile.vim @ 19231:b8fd7364befd v8.2.0174
patch 8.2.0174: various commands not completely tested
Commit: https://github.com/vim/vim/commit/5d98dc2a48156d44139b75c689bd3137ff7fe8bf
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Jan 29 21:57:34 2020 +0100
patch 8.2.0174: various commands not completely tested
Problem: Various commands not completely tested.
Solution: Add more test cases. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5551)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 29 Jan 2020 22:00:04 +0100 |
parents | 105c6cf8b266 |
children | 1b02482e6a61 |
comparison
equal
deleted
inserted
replaced
19230:21e430519a6c | 19231:b8fd7364befd |
---|---|
177 call assert_equal('', getline(1)) | 177 call assert_equal('', getline(1)) |
178 | 178 |
179 bwipe! | 179 bwipe! |
180 set noautowrite | 180 set noautowrite |
181 endfunc | 181 endfunc |
182 | |
183 " Test for ':w !<cmd>' to pipe lines from the current buffer to an external | |
184 " command. | |
185 func Test_write_pipe_to_cmd() | |
186 if !has('unix') | |
187 return | |
188 endif | |
189 new | |
190 call setline(1, ['L1', 'L2', 'L3', 'L4']) | |
191 2,3w !cat > Xfile | |
192 call assert_equal(['L2', 'L3'], readfile('Xfile')) | |
193 close! | |
194 call delete('Xfile') | |
195 endfunc | |
196 | |
197 " Test for :saveas | |
198 func Test_saveas() | |
199 call assert_fails('saveas', 'E471:') | |
200 call writefile(['L1'], 'Xfile') | |
201 new Xfile | |
202 new | |
203 call setline(1, ['L1']) | |
204 call assert_fails('saveas Xfile', 'E139:') | |
205 close! | |
206 enew | only | |
207 call delete('Xfile') | |
208 endfunc | |
209 | |
210 func Test_write_errors() | |
211 " Test for writing partial buffer | |
212 call writefile(['L1', 'L2', 'L3'], 'Xfile') | |
213 new Xfile | |
214 call assert_fails('1,2write', 'E140:') | |
215 close! | |
216 | |
217 " Try to overwrite a directory | |
218 if has('unix') | |
219 call mkdir('Xdir1') | |
220 call assert_fails('write Xdir1', 'E17:') | |
221 call delete('Xdir1', 'd') | |
222 endif | |
223 | |
224 " Test for :wall for a buffer with no name | |
225 enew | only | |
226 call setline(1, ['L1']) | |
227 call assert_fails('wall', 'E141:') | |
228 enew! | |
229 | |
230 " Test for writing a 'readonly' file | |
231 new Xfile | |
232 set readonly | |
233 call assert_fails('write', 'E45:') | |
234 close | |
235 | |
236 " Test for writing to a read-only file | |
237 new Xfile | |
238 call setfperm('Xfile', 'r--r--r--') | |
239 call assert_fails('write', 'E505:') | |
240 call setfperm('Xfile', 'rw-rw-rw-') | |
241 close | |
242 | |
243 call delete('Xfile') | |
244 endfunc | |
245 | |
246 " vim: shiftwidth=2 sts=2 expandtab |