Patch 9.0.0276

6 views
Skip to first unread message

Bram Moolenaar

unread,
Aug 26, 2022, 10:38:42 AM8/26/22
to vim...@googlegroups.com

Patch 9.0.0276
Problem: 'buftype' values not sufficiently tested.
Solution: Add and extend tests with 'buftype' values. (closes #10988)
Files: src/testdir/test_bufline.vim, src/testdir/test_autocmd.vim,
src/testdir/test_functions.vim


*** ../vim-9.0.0275/src/testdir/test_bufline.vim 2022-05-22 15:33:16.000000000 +0100
--- src/testdir/test_bufline.vim 2022-08-26 15:03:57.149562715 +0100
***************
*** 255,258 ****
--- 255,278 ----
bwipe!
endfunc

+ func Test_setbufline_startup_nofile()
+ let before =<< trim [CODE]
+ set shortmess+=F
+ file Xresult
+ set buftype=nofile
+ call setbufline('', 1, 'success')
+ [CODE]
+ let after =<< trim [CODE]
+ set buftype=
+ write
+ quit
+ [CODE]
+
+ if !RunVim(before, after, '--clean')
+ return
+ endif
+ call assert_equal(['success'], readfile('Xresult'))
+ call delete('Xresult')
+ endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
*** ../vim-9.0.0275/src/testdir/test_autocmd.vim 2022-08-26 13:16:16.233122555 +0100
--- src/testdir/test_autocmd.vim 2022-08-26 15:23:12.016075333 +0100
***************
*** 576,591 ****
au! BufReadCmd
endfunc

! " BufReadCmd is triggered for a "nofile" buffer
func Test_BufReadCmdNofile()
! new somefile
! set buftype=nofile
! au BufReadCmd somefile call setline(1, 'triggered')
! edit
! call assert_equal('triggered', getline(1))
!
! au! BufReadCmd
! bwipe!
endfunc

func Test_augroup_deleted()
--- 576,601 ----
au! BufReadCmd
endfunc

! " BufReadCmd is triggered for a "nofile" buffer. Check all values.
func Test_BufReadCmdNofile()
! for val in ['nofile',
! \ 'nowrite',
! \ 'acwrite',
! \ 'quickfix',
! \ 'help',
! \ 'terminal',
! \ 'prompt',
! \ 'popup',
! \ ]
! new somefile
! exe 'set buftype=' .. val
! au BufReadCmd somefile call setline(1, 'triggered')
! edit
! call assert_equal('triggered', getline(1))
!
! au! BufReadCmd
! bwipe!
! endfor
endfunc

func Test_augroup_deleted()
***************
*** 685,699 ****
au! BufEnter

" Editing a "nofile" buffer doesn't read the file but does trigger BufEnter
! " for historic reasons.
! new somefile
! set buftype=nofile
! au BufEnter somefile call setline(1, 'some text')
! edit
! call assert_equal('some text', getline(1))
!
! bwipe!
! au! BufEnter
endfunc

" Closing a window might cause an endless loop
--- 695,718 ----
au! BufEnter

" Editing a "nofile" buffer doesn't read the file but does trigger BufEnter
! " for historic reasons. Also test other 'buftype' values.
! for val in ['nofile',
! \ 'nowrite',
! \ 'acwrite',
! \ 'quickfix',
! \ 'help',
! \ 'terminal',
! \ 'prompt',
! \ 'popup',
! \ ]
! new somefile
! exe 'set buftype=' .. val
! au BufEnter somefile call setline(1, 'some text')
! edit
! call assert_equal('some text', getline(1))
! bwipe!
! au! BufEnter
! endfor
endfunc

" Closing a window might cause an endless loop
*** ../vim-9.0.0275/src/testdir/test_functions.vim 2022-08-26 12:58:14.517930190 +0100
--- src/testdir/test_functions.vim 2022-08-26 15:32:37.644849425 +0100
***************
*** 2368,2386 ****
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, '$'))

bwipe someName
bwipe XotherName
--- 2368,2390 ----
exe 'bwipe ' .. buf2
call assert_equal(0, bufexists(buf2))

! " 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
*** ../vim-9.0.0275/src/version.c 2022-08-26 13:16:16.233122555 +0100
--- src/version.c 2022-08-26 15:31:42.948817610 +0100
***************
*** 725,726 ****
--- 725,728 ----
{ /* Add new patch number below this line */
+ /**/
+ 276,
/**/

--
Yesterday, all my deadlines seemed so far away
now it looks as though it's freeze in four days
oh I believe in cvs..
[ CVS log "Beatles style" for FreeBSD ports/INDEX, Satoshi Asami ]

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages