annotate src/testdir/test_charsearch.vim @ 19783:546bdeef35f1 v8.2.0448

patch 8.2.0448: various functions not properly tested Commit: https://github.com/vim/vim/commit/0e05de46226eb4e5ea580beefa71831f92d613d3 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Mar 25 22:23:46 2020 +0100 patch 8.2.0448: various functions not properly tested Problem: Various functions not properly tested. Solution: Add more tests, especially for failures. (Yegappan Lakshmanan, closes #5843)
author Bram Moolenaar <Bram@vim.org>
date Wed, 25 Mar 2020 22:30:04 +0100
parents f70a3c1000bb
children a4bd28e2cf1d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19625
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 17994
diff changeset
1 " Test for character search commands - t, T, f, F, ; and ,
10072
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 10145
diff changeset
3 func Test_charsearch()
10072
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 enew!
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 call append(0, ['Xabcdefghijkemnopqretuvwxyz',
10145
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents: 10072
diff changeset
6 \ 'Yabcdefghijkemnopqretuvwxyz',
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents: 10072
diff changeset
7 \ 'Zabcdefghijkemnokqretkvwxyz'])
10072
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 " check that "fe" and ";" work
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 1
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 normal! ylfep;;p,,p
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 call assert_equal('XabcdeXfghijkeXmnopqreXtuvwxyz', getline(1))
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 " check that save/restore works
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 2
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 normal! ylfep
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 let csave = getcharsearch()
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 normal! fip
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 call setcharsearch(csave)
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 normal! ;p;p
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 call assert_equal('YabcdeYfghiYjkeYmnopqreYtuvwxyz', getline(2))
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 " check that setcharsearch() changes the settings.
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 3
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 normal! ylfep
17994
0dcc2ee838dd patch 8.1.1993: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
24 eval {'char': 'k'}->setcharsearch()
10072
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 normal! ;p
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 call setcharsearch({'forward': 0})
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 normal! $;p
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 call setcharsearch({'until': 1})
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 set cpo-=;
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 normal! ;;p
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 call assert_equal('ZabcdeZfghijkZZemnokqretkZvwxyz', getline(3))
19783
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19625
diff changeset
32
546bdeef35f1 patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 19625
diff changeset
33 call assert_fails("call setcharsearch([])", 'E715:')
10072
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 enew!
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 10145
diff changeset
35 endfunc
10072
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 " Test for t,f,F,T movement commands and 'cpo-;' setting
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 10145
diff changeset
38 func Test_search_cmds()
10072
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 enew!
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 call append(0, ["aaa two three four", " zzz", "yyy ",
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 \ "bbb yee yoo four", "ccc two three four",
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42 \ "ddd yee yoo four"])
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 set cpo-=;
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 1
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 normal! 0tt;D
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 2
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 normal! 0fz;D
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 3
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 normal! $Fy;D
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 4
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 normal! $Ty;D
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 set cpo+=;
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 5
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54 normal! 0tt;;D
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 6
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 normal! $Ty;;D
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 call assert_equal('aaa two', getline(1))
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 call assert_equal(' z', getline(2))
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 call assert_equal('y', getline(3))
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 call assert_equal('bbb y', getline(4))
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 call assert_equal('ccc', getline(5))
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63 call assert_equal('ddd yee y', getline(6))
c104f09ae2f4 commit https://github.com/vim/vim/commit/cd055da370114f66c960be9c8b1eb0f33a9e0a85
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64 enew!
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 10145
diff changeset
65 endfunc
19625
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 17994
diff changeset
66
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 17994
diff changeset
67 " Test for character search in virtual edit mode with <Tab>
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 17994
diff changeset
68 func Test_csearch_virtualedit()
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 17994
diff changeset
69 new
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 17994
diff changeset
70 set virtualedit=all
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 17994
diff changeset
71 call setline(1, "a\tb")
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 17994
diff changeset
72 normal! tb
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 17994
diff changeset
73 call assert_equal([0, 1, 2, 6], getpos('.'))
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 17994
diff changeset
74 set virtualedit&
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 17994
diff changeset
75 close!
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 17994
diff changeset
76 endfunc
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 17994
diff changeset
77
f70a3c1000bb patch 8.2.0369: various Normal mode commands not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 17994
diff changeset
78 " vim: shiftwidth=2 sts=2 expandtab