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