0
0
mirror of https://github.com/vim/vim.git synced 2025-10-07 05:54:16 -04:00

patch 9.0.0276: 'buftype' values not sufficiently tested

Problem:    'buftype' values not sufficiently tested.
Solution:   Add and extend tests with 'buftype' values. (closes #10988)
This commit is contained in:
zeertzjq
2022-08-26 15:34:52 +01:00
committed by Bram Moolenaar
parent a9b5b85068
commit 93f72cc119
4 changed files with 75 additions and 30 deletions

View File

@@ -2368,19 +2368,23 @@ func Test_bufadd_bufload()
exe 'bwipe ' .. buf2
call assert_equal(0, bufexists(buf2))
" when 'buftype' is "nofile" then bufload() does not read the file
bwipe! XotherName
let buf = bufadd('XotherName')
call setbufvar(buf, '&bt', 'nofile')
call bufload(buf)
call assert_equal([''], getbufline(buf, 1, '$'))
" when 'buftype' is "acwrite" then bufload() DOES read the file
bwipe! XotherName
let buf = bufadd('XotherName')
call setbufvar(buf, '&bt', 'acwrite')
call bufload(buf)
call assert_equal(['some', 'text'], getbufline(buf, 1, '$'))
" When 'buftype' is "nofile" then bufload() does not read the file.
" Other values too.
for val in [['nofile', 0],
\ ['nowrite', 1],
\ ['acwrite', 1],
\ ['quickfix', 0],
\ ['help', 1],
\ ['terminal', 0],
\ ['prompt', 0],
\ ['popup', 0],
\ ]
bwipe! XotherName
let buf = bufadd('XotherName')
call setbufvar(buf, '&bt', val[0])
call bufload(buf)
call assert_equal(val[1] ? ['some', 'text'] : [''], getbufline(buf, 1, '$'), val[0])
endfor
bwipe someName
bwipe XotherName