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)
diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim
index 4b09285..189a2bc 100644
--- a/src/testdir/test_autocmd.vim
+++ b/src/testdir/test_autocmd.vim
@@ -576,16 +576,26 @@
au! BufReadCmd
endfunc
-" BufReadCmd is triggered for a "nofile" buffer
+" BufReadCmd is triggered for a "nofile" buffer. Check all values.
func Test_BufReadCmdNofile()
- new somefile
- set buftype=nofile
- au BufReadCmd somefile call setline(1, 'triggered')
- edit
- call assert_equal('triggered', getline(1))
+ 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!
+ au! BufReadCmd
+ bwipe!
+ endfor
endfunc
func Test_augroup_deleted()
@@ -685,15 +695,24 @@
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
+ " 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