File: //home/btminers/.vim/bundle/conflict-marker.vim/test/test_jump.vimspec
let s:lines = [
\ '',
\ '<<<<<<< HEAD',
\ 'ourselves1',
\ '=======',
\ 'themselves1',
\ '>>>>>>> 8374eabc232',
\ '',
\ '',
\ '<<<<<<< HEAD',
\ 'ourselves2',
\ '=======',
\ 'themselves2',
\ '>>>>>>> 8374eabc232',
\ '',
\ '',
\ '<<<<<<< HEAD',
\ 'ourselves3',
\ '=======',
\ 'themselves3',
\ '>>>>>>> 8374eabc232',
\ '',
\ ]
lockvar s:lines
let s:lines_diff3 = [
\ '',
\ '<<<<<<< HEAD',
\ 'ourselves1',
\ '|||||||',
\ 'base1',
\ '=======',
\ 'themselves1',
\ '>>>>>>> 8374eabc232',
\ '',
\ '',
\ '<<<<<<< HEAD',
\ 'ourselves2',
\ '|||||||',
\ 'base2',
\ '=======',
\ 'themselves2',
\ '>>>>>>> 8374eabc232',
\ '',
\ '',
\ '<<<<<<< HEAD',
\ 'ourselves3',
\ '|||||||',
\ 'base3',
\ '=======',
\ 'themselves3',
\ '>>>>>>> 8374eabc232',
\ '',
\ ]
lockvar s:lines_diff3
let s:lines_long_markers = [
\ '',
\ '<<<<<<<<<<<<<< HEAD',
\ 'ourselves1',
\ '==============',
\ 'themselves1',
\ '>>>>>>>>>>>>>> 8374eabc232',
\ '',
\ '',
\ '<<<<<<<< HEAD',
\ 'ourselves2',
\ '========',
\ 'themselves2',
\ '>>>>>>>> 8374eabc232',
\ '',
\ ]
lockvar s:lines_long_markers
function! s:setup(lines) abort
new
for l in range(1, len(a:lines))
call setline(l, a:lines[l-1])
endfor
endfunction
Describe :ConflictMarkerNextHunk
Context applying to diff2
Before
call s:setup(s:lines)
End
After
close!
End
It moves cursor to next hunk
normal! gg
for l in [2, 9, 16]
ConflictMarkerNextHunk
Assert Equals(line('.'), l)
endfor
End
It doesn't move cursor at the end of buffer
normal! G
ConflictMarkerNextHunk
Assert Equals(line('.'), line('$'))
End
It doesn't accept at cursor
normal! ggj
ConflictMarkerNextHunk
Assert Equals(line('.'), 9)
End
It accepts position at cursor with bang
normal! ggj
ConflictMarkerNextHunk!
Assert Equals(line('.'), 2)
End
End
Context applying to diff3
Before
call s:setup(s:lines_diff3)
End
After
close!
End
It moves cursor to next hunk
normal! gg
for l in [2, 11, 20]
ConflictMarkerNextHunk
Assert Equals(line('.'), l)
endfor
End
It doesn't move cursor at the end of buffer
normal! G
ConflictMarkerNextHunk
Assert Equals(line('.'), line('$'))
End
It doesn't accept at cursor
normal! ggj
ConflictMarkerNextHunk
Assert Equals(line('.'), 11)
End
It accepts position at cursor with bang
normal! ggj
ConflictMarkerNextHunk!
Assert Equals(line('.'), 2)
End
End
Context markers with more than 7 characters
Before
call s:setup(s:lines_long_markers)
End
After
close!
End
It moves cursor to next hunk
normal! gg
for l in [2, 9]
ConflictMarkerNextHunk
Assert Equals(line('.'), l)
endfor
End
It accepts position at cursor with bang
normal! ggj
ConflictMarkerNextHunk!
Assert Equals(line('.'), 2)
End
End
End
Describe :ConflictMarkerPrevHunk
Context applying to diff2
Before
call s:setup(s:lines)
End
After
close!
End
It moves cursor to previous hunk
normal! G
for l in [16, 9, 2]
ConflictMarkerPrevHunk
Assert Equals(line('.'), l)
endfor
End
It doesn't move cursor at the top of buffer
normal! gg
ConflictMarkerPrevHunk
Assert Equals(line('.'), 1)
End
It doesn't accept at cursor
normal! Gk
ConflictMarkerPrevHunk
Assert Equals(line('.'), 9)
End
It accepts position at cursor with bang
normal! Gk
ConflictMarkerPrevHunk!
Assert Equals(line('.'), 16)
End
End
Context applying to diff3
Before
call s:setup(s:lines_diff3)
End
After
close!
End
It moves cursor to previous hunk
normal! G
for l in [20, 11, 2]
ConflictMarkerPrevHunk
Assert Equals(line('.'), l)
endfor
End
It doesn't move cursor at the top of buffer
normal! gg
ConflictMarkerPrevHunk
Assert Equals(line('.'), 1)
End
It doesn't accept at cursor
normal! Gk
ConflictMarkerPrevHunk
Assert Equals(line('.'), 11)
End
It accepts position at cursor with bang
normal! Gk
ConflictMarkerPrevHunk!
Assert Equals(line('.'), 20)
End
End
Context markers with more than 7 characters
Before
call s:setup(s:lines_long_markers)
End
After
close!
End
It moves cursor to previous hunk
normal! G
for l in [9, 2]
ConflictMarkerPrevHunk
Assert Equals(line('.'), l)
endfor
End
It accepts position at cursor with bang
normal! Gk
ConflictMarkerPrevHunk!
Assert Equals(line('.'), 9)
End
End
End