Skip to content

Commit 518c9b1

Browse files
committed
patch 8.0.0496: insufficient testing for folding
Problem: Insufficient testing for folding. Solution: Add a couple more fold tests. (Dominique Pelle, closes #1579)
1 parent f5610da commit 518c9b1

2 files changed

Lines changed: 57 additions & 2 deletions

File tree

src/testdir/test_fold.vim

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ func! Test_address_fold()
99
call setline(1, ['int FuncName() {/*{{{*/', 1, 2, 3, 4, 5, '}/*}}}*/',
1010
\ 'after fold 1', 'after fold 2', 'after fold 3'])
1111
setl fen fdm=marker
12-
" The next ccommands should all copy the same part of the buffer,
13-
" regardless of the adressing type, since the part to be copied
12+
" The next commands should all copy the same part of the buffer,
13+
" regardless of the addressing type, since the part to be copied
1414
" is folded away
1515
:1y
1616
call assert_equal(['int FuncName() {/*{{{*/', '1', '2', '3', '4', '5', '}/*}}}*/'], getreg(0,1,1))
@@ -360,3 +360,56 @@ func! Test_move_folds_around_indent()
360360
call assert_equal([0, 1, 1, 1, 1, 0, 0, 0, 1, 1], map(range(1, line('$')), 'foldlevel(v:val)'))
361361
bw!
362362
endfunc
363+
364+
func Test_folddoopen_folddoclosed()
365+
new
366+
call setline(1, range(1, 9))
367+
set foldmethod=manual
368+
1,3 fold
369+
6,8 fold
370+
371+
" Test without range.
372+
folddoopen s/$/o/
373+
folddoclosed s/$/c/
374+
call assert_equal(['1c', '2c', '3c',
375+
\ '4o', '5o',
376+
\ '6c', '7c', '8c',
377+
\ '9o'], getline(1, '$'))
378+
379+
" Test with range.
380+
call setline(1, range(1, 9))
381+
1,8 folddoopen s/$/o/
382+
4,$ folddoclosed s/$/c/
383+
call assert_equal(['1', '2', '3',
384+
\ '4o', '5o',
385+
\ '6c', '7c', '8c',
386+
\ '9'], getline(1, '$'))
387+
388+
set foldmethod&
389+
bw!
390+
endfunc
391+
392+
func Test_fold_error()
393+
new
394+
call setline(1, [1, 2])
395+
396+
for fm in ['indent', 'expr', 'syntax', 'diff']
397+
exe 'set foldmethod=' . fm
398+
call assert_fails('norm zf', 'E350:')
399+
call assert_fails('norm zd', 'E351:')
400+
call assert_fails('norm zE', 'E352:')
401+
endfor
402+
403+
set foldmethod=manual
404+
call assert_fails('norm zd', 'E490:')
405+
call assert_fails('norm zo', 'E490:')
406+
call assert_fails('3fold', 'E16:')
407+
408+
set foldmethod=marker
409+
set nomodifiable
410+
call assert_fails('1,2fold', 'E21:')
411+
412+
set modifiable&
413+
set foldmethod&
414+
bw!
415+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
496,
767769
/**/
768770
495,
769771
/**/

0 commit comments

Comments
 (0)