Skip to content

Commit

Permalink
patch 7.4.2123
Browse files Browse the repository at this point in the history
Problem:    No new style test for diff mode.
Solution:   Add a test.  Check that folds are in sync.
  • Loading branch information
brammool committed Jul 30, 2016
1 parent b822cb0 commit 42093c0
Show file tree
Hide file tree
Showing 6 changed files with 170 additions and 149 deletions.
3 changes: 2 additions & 1 deletion src/Makefile
Expand Up @@ -2042,7 +2042,7 @@ test1 \
test11 test12 test13 test14 test15 test16 test17 test18 test19 \
test20 test21 test22 test23 test24 test25 test26 test27 test28 test29 \
test30 test31 test32 test33 test34 test36 test37 test38 test39 \
test40 test41 test42 test43 test44 test45 test46 test47 test48 test49 \
test40 test41 test42 test43 test44 test45 test46 test48 test49 \
test50 test51 test52 test53 test54 test55 test56 test57 test58 test59 \
test60 test62 test63 test64 test65 test66 test67 test68 test69 \
test70 test71 test72 test73 test74 test75 test76 test77 test78 test79 \
Expand All @@ -2064,6 +2064,7 @@ test_arglist \
test_cscope \
test_cursor_func \
test_delete \
test_diffmode \
test_digraph \
test_ex_undo \
test_execute_func \
Expand Down
2 changes: 1 addition & 1 deletion src/testdir/Make_all.mak
Expand Up @@ -43,7 +43,6 @@ SCRIPTS_ALL = \
test44.out \
test45.out \
test46.out \
test47.out \
test48.out \
test51.out \
test53.out \
Expand Down Expand Up @@ -168,6 +167,7 @@ NEW_TESTS = test_arglist.res \
test_channel.res \
test_cmdline.res \
test_cscope.res \
test_diffmode.res \
test_digraph.res \
test_farsi.res \
test_gn.res \
Expand Down
103 changes: 0 additions & 103 deletions src/testdir/test47.in

This file was deleted.

44 changes: 0 additions & 44 deletions src/testdir/test47.ok

This file was deleted.

165 changes: 165 additions & 0 deletions src/testdir/test_diffmode.vim
@@ -0,0 +1,165 @@
" Tests for diff mode

func Test_diff_fold_sync()
enew!
let l = range(50)
call setline(1, l)
diffthis
let winone = win_getid()
new
let l[25] = 'diff'
call setline(1, l)
diffthis
let wintwo = win_getid()
" line 15 is inside the closed fold
call assert_equal(19, foldclosedend(10))
call win_gotoid(winone)
call assert_equal(19, foldclosedend(10))
" open the fold
normal zv
call assert_equal(-1, foldclosedend(10))
" fold in other window must have opened too
call win_gotoid(wintwo)
call assert_equal(-1, foldclosedend(10))

" cursor position is in sync
normal 23G
call win_gotoid(winone)
call assert_equal(23, getcurpos()[1])

windo diffoff
close!
set nomodified
endfunc

func Test_vert_split()
" Disable the title to avoid xterm keeping the wrong one.
set notitle noicon
new
let l = ['1 aa', '2 bb', '3 cc', '4 dd', '5 ee']
call setline(1, l)
w! Xtest
normal dd
$
put
normal kkrXoxxx
w! Xtest2
file Nop
normal ggoyyyjjjozzzz
set foldmethod=marker foldcolumn=4
call assert_equal(0, &diff)
call assert_equal('marker', &foldmethod)
call assert_equal(4, &foldcolumn)
call assert_equal(0, &scrollbind)
call assert_equal(0, &cursorbind)
call assert_equal(1, &wrap)

vert diffsplit Xtest
vert diffsplit Xtest2
call assert_equal(1, &diff)
call assert_equal('diff', &foldmethod)
call assert_equal(2, &foldcolumn)
call assert_equal(1, &scrollbind)
call assert_equal(1, &cursorbind)
call assert_equal(0, &wrap)

let diff_fdm = &fdm
let diff_fdc = &fdc
" repeat entering diff mode here to see if this saves the wrong settings
diffthis
" jump to second window for a moment to have filler line appear at start of
" first window
wincmd w
normal gg
wincmd p
normal gg
call assert_equal(2, winline())
normal j
call assert_equal(4, winline())
normal j
call assert_equal(5, winline())
normal j
call assert_equal(6, winline())
normal j
call assert_equal(8, winline())
normal j
call assert_equal(9, winline())

wincmd w
normal gg
call assert_equal(1, winline())
normal j
call assert_equal(2, winline())
normal j
call assert_equal(4, winline())
normal j
call assert_equal(5, winline())
normal j
call assert_equal(8, winline())

wincmd w
normal gg
call assert_equal(2, winline())
normal j
call assert_equal(3, winline())
normal j
call assert_equal(4, winline())
normal j
call assert_equal(5, winline())
normal j
call assert_equal(6, winline())
normal j
call assert_equal(7, winline())
normal j
call assert_equal(8, winline())

" Test diffoff
diffoff!
1wincmd 2
let &diff = 1
let &fdm = diff_fdm
let &fdc = diff_fdc
4wincmd w
diffoff!
1wincmd w
call assert_equal(0, &diff)
call assert_equal('marker', &foldmethod)
call assert_equal(4, &foldcolumn)
call assert_equal(0, &scrollbind)
call assert_equal(0, &cursorbind)
call assert_equal(1, &wrap)

wincmd w
call assert_equal(0, &diff)
call assert_equal('marker', &foldmethod)
call assert_equal(4, &foldcolumn)
call assert_equal(0, &scrollbind)
call assert_equal(0, &cursorbind)
call assert_equal(1, &wrap)

wincmd w
call assert_equal(0, &diff)
call assert_equal('marker', &foldmethod)
call assert_equal(4, &foldcolumn)
call assert_equal(0, &scrollbind)
call assert_equal(0, &cursorbind)
call assert_equal(1, &wrap)

windo bw!
endfunc

func Test_filler_lines()
" Test that diffing shows correct filler lines
enew!
put =range(4,10)
1d _
vnew
put =range(1,10)
1d _
windo diffthis
wincmd h
call assert_equal(1, line('w0'))
unlet! diff_fdm diff_fdc

windo bw!
endfunc
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -763,6 +763,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
2123,
/**/
2122,
/**/
Expand Down

0 comments on commit 42093c0

Please sign in to comment.