annotate src/testdir/test_cursor_func.vim @ 11183:1c4ebbae41d2 v8.0.0478

patch 8.0.0478: tests use assert_true(0) and assert_false(1) to report errors commit https://github.com/vim/vim/commit/37175409d766ce67f2548dffa6d73451379b5737 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Mar 18 20:18:45 2017 +0100 patch 8.0.0478: tests use assert_true(0) and assert_false(1) to report errors Problem: Tests use assert_true(0) and assert_false(1) to report errors. Solution: Use assert_report().
author Christian Brabandt <cb@256bit.org>
date Sat, 18 Mar 2017 20:30:04 +0100
parents 7c7e496e625d
children 126cdab63a83
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7590
4d9814f9fc39 commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Tests for cursor().
4d9814f9fc39 commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
4d9814f9fc39 commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 func Test_wrong_arguments()
11183
1c4ebbae41d2 patch 8.0.0478: tests use assert_true(0) and assert_false(1) to report errors
Christian Brabandt <cb@256bit.org>
parents: 11105
diff changeset
4 call assert_fails('call cursor(1. 3)', 'E474:')
7590
4d9814f9fc39 commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 endfunc
4d9814f9fc39 commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6
4d9814f9fc39 commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 func Test_move_cursor()
4d9814f9fc39 commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 new
4d9814f9fc39 commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 call setline(1, ['aaa', 'bbb', 'ccc', 'ddd'])
4d9814f9fc39 commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10
4d9814f9fc39 commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 call cursor([1, 1, 0, 1])
4d9814f9fc39 commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 call assert_equal([1, 1, 0, 1], getcurpos()[1:])
4d9814f9fc39 commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 call cursor([4, 3, 0, 3])
4d9814f9fc39 commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 call assert_equal([4, 3, 0, 3], getcurpos()[1:])
4d9814f9fc39 commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15
4d9814f9fc39 commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 call cursor(2, 2)
8011
26f555e9aab1 commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents: 7590
diff changeset
17 call assert_equal([2, 2, 0, 2], getcurpos()[1:])
7590
4d9814f9fc39 commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 " line number zero keeps the line number
4d9814f9fc39 commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 call cursor(0, 1)
8011
26f555e9aab1 commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents: 7590
diff changeset
20 call assert_equal([2, 1, 0, 1], getcurpos()[1:])
7590
4d9814f9fc39 commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 " col number zero keeps the column
4d9814f9fc39 commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 call cursor(3, 0)
8011
26f555e9aab1 commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents: 7590
diff changeset
23 call assert_equal([3, 1, 0, 1], getcurpos()[1:])
7590
4d9814f9fc39 commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 " below last line goes to last line
4d9814f9fc39 commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 call cursor(9, 1)
8011
26f555e9aab1 commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents: 7590
diff changeset
26 call assert_equal([4, 1, 0, 1], getcurpos()[1:])
7590
4d9814f9fc39 commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27
4d9814f9fc39 commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 quit!
4d9814f9fc39 commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 endfunc
8011
26f555e9aab1 commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents: 7590
diff changeset
30
26f555e9aab1 commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents: 7590
diff changeset
31 " Very short version of what matchparen does.
26f555e9aab1 commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents: 7590
diff changeset
32 function s:Highlight_Matching_Pair()
26f555e9aab1 commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents: 7590
diff changeset
33 let save_cursor = getcurpos()
26f555e9aab1 commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents: 7590
diff changeset
34 call setpos('.', save_cursor)
26f555e9aab1 commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents: 7590
diff changeset
35 endfunc
26f555e9aab1 commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents: 7590
diff changeset
36
26f555e9aab1 commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents: 7590
diff changeset
37 func Test_curswant_with_autocommand()
26f555e9aab1 commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents: 7590
diff changeset
38 new
26f555e9aab1 commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents: 7590
diff changeset
39 call setline(1, ['func()', '{', '}', '----'])
26f555e9aab1 commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents: 7590
diff changeset
40 autocmd! CursorMovedI * call s:Highlight_Matching_Pair()
11105
7c7e496e625d patch 8.0.0440: not enough test coverage in Insert mode
Christian Brabandt <cb@256bit.org>
parents: 9121
diff changeset
41 call test_override("char_avail", 1)
8011
26f555e9aab1 commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents: 7590
diff changeset
42 exe "normal! 3Ga\<Down>X\<Esc>"
11105
7c7e496e625d patch 8.0.0440: not enough test coverage in Insert mode
Christian Brabandt <cb@256bit.org>
parents: 9121
diff changeset
43 call test_override("char_avail", 0)
8011
26f555e9aab1 commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents: 7590
diff changeset
44 call assert_equal('-X---', getline(4))
26f555e9aab1 commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents: 7590
diff changeset
45 autocmd! CursorMovedI *
26f555e9aab1 commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents: 7590
diff changeset
46 quit!
26f555e9aab1 commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents: 7590
diff changeset
47 endfunc
26f555e9aab1 commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents: 7590
diff changeset
48