Skip to content

Commit 97fbc40

Browse files
committed
patch 8.0.1153: no tests for diff_hlID() and diff_filler()
Problem: No tests for diff_hlID() and diff_filler(). Solution: Add tests. (Dominique Pelle, closes #2156)
1 parent 2a02745 commit 97fbc40

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed

src/testdir/test_diffmode.vim

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ func Test_setting_cursor()
420420
new Xtest2
421421
put =range(1,100)
422422
wq
423-
423+
424424
tabe Xtest2
425425
$
426426
diffsp Xtest1
@@ -501,7 +501,7 @@ func Test_diffpatch()
501501
3
502502
+ 4
503503
.
504-
saveas Xpatch
504+
saveas! Xpatch
505505
bwipe!
506506
new
507507
call assert_fails('diffpatch Xpatch', 'E816:')
@@ -547,6 +547,47 @@ func Test_diff_nomodifiable()
547547
%bwipe!
548548
endfunc
549549

550+
func Test_diff_hlID()
551+
new
552+
call setline(1, [1, 2, 3])
553+
diffthis
554+
vnew
555+
call setline(1, ['1x', 2, 'x', 3])
556+
diffthis
557+
redraw
558+
559+
call assert_equal(synIDattr(diff_hlID(-1, 1), "name"), "")
560+
561+
call assert_equal(synIDattr(diff_hlID(1, 1), "name"), "DiffChange")
562+
call assert_equal(synIDattr(diff_hlID(1, 2), "name"), "DiffText")
563+
call assert_equal(synIDattr(diff_hlID(2, 1), "name"), "")
564+
call assert_equal(synIDattr(diff_hlID(3, 1), "name"), "DiffAdd")
565+
call assert_equal(synIDattr(diff_hlID(4, 1), "name"), "")
566+
567+
wincmd w
568+
call assert_equal(synIDattr(diff_hlID(1, 1), "name"), "DiffChange")
569+
call assert_equal(synIDattr(diff_hlID(2, 1), "name"), "")
570+
call assert_equal(synIDattr(diff_hlID(3, 1), "name"), "")
571+
572+
%bwipe!
573+
endfunc
574+
575+
func Test_diff_filler()
576+
new
577+
call setline(1, [1, 2, 3, 'x', 4])
578+
diffthis
579+
vnew
580+
call setline(1, [1, 2, 'y', 'y', 3, 4])
581+
diffthis
582+
redraw
583+
584+
call assert_equal([0, 0, 0, 0, 0, 0, 0, 1, 0], map(range(-1, 7), 'diff_filler(v:val)'))
585+
wincmd w
586+
call assert_equal([0, 0, 0, 0, 2, 0, 0, 0], map(range(-1, 6), 'diff_filler(v:val)'))
587+
588+
%bwipe!
589+
endfunc
590+
550591
func Test_diff_lastline()
551592
enew!
552593
only!

src/version.c

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

762762
static int included_patches[] =
763763
{ /* Add new patch number below this line */
764+
/**/
765+
1153,
764766
/**/
765767
1152,
766768
/**/

0 commit comments

Comments
 (0)