1" Tests for cursor().
2
3func Test_wrong_arguments()
4  call assert_fails('call cursor(1. 3)', 'E474:')
5endfunc
6
7func Test_move_cursor()
8  new
9  call setline(1, ['aaa', 'bbb', 'ccc', 'ddd'])
10
11  call cursor([1, 1, 0, 1])
12  call assert_equal([1, 1, 0, 1], getcurpos()[1:])
13  call cursor([4, 3, 0, 3])
14  call assert_equal([4, 3, 0, 3], getcurpos()[1:])
15
16  call cursor(2, 2)
17  call assert_equal([2, 2, 0, 2], getcurpos()[1:])
18  " line number zero keeps the line number
19  call cursor(0, 1)
20  call assert_equal([2, 1, 0, 1], getcurpos()[1:])
21  " col number zero keeps the column
22  call cursor(3, 0)
23  call assert_equal([3, 1, 0, 1], getcurpos()[1:])
24  " below last line goes to last line
25  call cursor(9, 1)
26  call assert_equal([4, 1, 0, 1], getcurpos()[1:])
27
28  quit!
29endfunc
30
31" Very short version of what matchparen does.
32function s:Highlight_Matching_Pair()
33  let save_cursor = getcurpos()
34  call setpos('.', save_cursor)
35endfunc
36
37func Test_curswant_with_autocommand()
38  new
39  call setline(1, ['func()', '{', '}', '----'])
40  autocmd! CursorMovedI * call s:Highlight_Matching_Pair()
41  call test_override("char_avail", 1)
42  exe "normal! 3Ga\<Down>X\<Esc>"
43  call test_override("char_avail", 0)
44  call assert_equal('-X---', getline(4))
45  autocmd! CursorMovedI *
46  quit!
47endfunc
48
49