annotate src/testdir/test_match.vim @ 30582:72245f9c9405 v9.0.0626

patch 9.0.0626: too many delete() calls in tests Commit: https://github.com/vim/vim/commit/b152b6a40f729ed81a25d2fa541a4e73e201bec4 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Sep 29 21:37:33 2022 +0100 patch 9.0.0626: too many delete() calls in tests Problem: Too many delete() calls in tests. Solution: Use deferred delete where possible.
author Bram Moolenaar <Bram@vim.org>
date Thu, 29 Sep 2022 22:45:04 +0200
parents 66de6909e102
children a357a624e487
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9776
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Test for :match, :2match, :3match, clearmatches(), getmatches(), matchadd(),
12451
61450cb2b6a1 patch 8.0.1105: match() and matchend() are not tested
Christian Brabandt <cb@256bit.org>
parents: 12248
diff changeset
2 " matchaddpos(), matcharg(), matchdelete(), and setmatches().
9776
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3
17482
6cf077f59152 patch 8.1.1739: deleted match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents: 16158
diff changeset
4 source screendump.vim
17657
0da9bc55c31a patch 8.1.1826: tests use hand coded feature and option checks
Bram Moolenaar <Bram@vim.org>
parents: 17486
diff changeset
5 source check.vim
17482
6cf077f59152 patch 8.1.1739: deleted match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents: 16158
diff changeset
6
9885
4e8b05fa12c6 commit https://github.com/vim/vim/commit/4f416e41243ca151b95d39d81ce23d00b1484755
Christian Brabandt <cb@256bit.org>
parents: 9776
diff changeset
7 function Test_match()
9776
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 highlight MyGroup1 term=bold ctermbg=red guibg=red
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 highlight MyGroup2 term=italic ctermbg=green guibg=green
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 highlight MyGroup3 term=underline ctermbg=blue guibg=blue
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 " --- Check that "matcharg()" returns the correct group and pattern if a match
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 " --- is defined.
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 match MyGroup1 /TODO/
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 2match MyGroup2 /FIXME/
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 3match MyGroup3 /XXX/
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 call assert_equal(['MyGroup1', 'TODO'], matcharg(1))
17930
0cdb6ac20748 patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17837
diff changeset
18 call assert_equal(['MyGroup2', 'FIXME'], 2->matcharg())
9776
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 call assert_equal(['MyGroup3', 'XXX'], matcharg(3))
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 " --- Check that "matcharg()" returns an empty list if the argument is not 1,
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 " --- 2 or 3 (only 0 and 4 are tested).
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 call assert_equal([], matcharg(0))
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 call assert_equal([], matcharg(4))
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 " --- Check that "matcharg()" returns ['', ''] if a match is not defined.
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 match
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 2match
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 3match
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 call assert_equal(['', ''], matcharg(1))
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 call assert_equal(['', ''], matcharg(2))
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 call assert_equal(['', ''], matcharg(3))
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 " --- Check that "matchadd()" and "getmatches()" agree on added matches and
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 " --- that default values apply.
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 let m1 = matchadd("MyGroup1", "TODO")
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 let m2 = matchadd("MyGroup2", "FIXME", 42)
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 let m3 = matchadd("MyGroup3", "XXX", 60, 17)
30574
66de6909e102 patch 9.0.0622: matchaddpos() can get slow when adding many matches
Bram Moolenaar <Bram@vim.org>
parents: 30570
diff changeset
39 let ans = [{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id': 1000},
66de6909e102 patch 9.0.0622: matchaddpos() can get slow when adding many matches
Bram Moolenaar <Bram@vim.org>
parents: 30570
diff changeset
40 \ {'group': 'MyGroup2', 'pattern': 'FIXME', 'priority': 42, 'id': 1001},
9776
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 \ {'group': 'MyGroup3', 'pattern': 'XXX', 'priority': 60, 'id': 17}]
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42 call assert_equal(ans, getmatches())
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 " --- Check that "matchdelete()" deletes the matches defined in the previous
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 " --- test correctly.
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 call matchdelete(m1)
17930
0cdb6ac20748 patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17837
diff changeset
47 eval m2->matchdelete()
9776
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 call matchdelete(m3)
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 call assert_equal([], getmatches())
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 " --- Check that "matchdelete()" returns 0 if successful and otherwise -1.
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 let m = matchadd("MyGroup1", "TODO")
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 call assert_equal(0, matchdelete(m))
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54 call assert_fails('call matchdelete(42)', 'E803:')
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 " --- Check that "clearmatches()" clears all matches defined by ":match" and
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 " --- "matchadd()".
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 let m1 = matchadd("MyGroup1", "TODO")
17930
0cdb6ac20748 patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17837
diff changeset
59 let m2 = "MyGroup2"->matchadd("FIXME", 42)
9776
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 let m3 = matchadd("MyGroup3", "XXX", 60, 17)
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 match MyGroup1 /COFFEE/
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 2match MyGroup2 /HUMPPA/
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63 3match MyGroup3 /VIM/
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64 call clearmatches()
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65 call assert_equal([], getmatches())
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67 " --- Check that "setmatches()" restores a list of matches saved by
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
68 " --- "getmatches()" without changes. (Matches with equal priority must also
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
69 " --- remain in the same order.)
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
70 let m1 = matchadd("MyGroup1", "TODO")
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
71 let m2 = matchadd("MyGroup2", "FIXME", 42)
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
72 let m3 = matchadd("MyGroup3", "XXX", 60, 17)
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73 match MyGroup1 /COFFEE/
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
74 2match MyGroup2 /HUMPPA/
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
75 3match MyGroup3 /VIM/
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
76 let ml = getmatches()
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
77 call clearmatches()
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
78 call setmatches(ml)
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
79 call assert_equal(ml, getmatches())
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
80 call clearmatches()
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
81
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
82 " --- Check that "setmatches()" will not add two matches with the same ID. The
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
83 " --- expected behaviour (for now) is to add the first match but not the
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
84 " --- second and to return 0 (even though it is a matter of debate whether
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
85 " --- this can be considered successful behaviour).
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
86 let data = [{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id': 1},
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
87 \ {'group': 'MyGroup2', 'pattern': 'FIXME', 'priority': 10, 'id': 1}]
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
88 call assert_fails('call setmatches(data)', 'E801:')
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
89 call assert_equal([data[0]], getmatches())
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
90 call clearmatches()
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
91
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
92 " --- Check that "setmatches()" returns 0 if successful and otherwise -1.
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
93 " --- (A range of valid and invalid input values are tried out to generate the
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
94 " --- return values.)
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
95 call assert_equal(0, setmatches([]))
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
96 call assert_equal(0, setmatches([{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id': 1}]))
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
97 call clearmatches()
30015
adb0de8be4ce patch 9.0.0345: error message for list argument could be clearer
Bram Moolenaar <Bram@vim.org>
parents: 27626
diff changeset
98 call assert_fails('call setmatches(0)', 'E1211:')
9776
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
99 call assert_fails('call setmatches([0])', 'E474:')
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
100 call assert_fails("call setmatches([{'wrong key': 'wrong value'}])", 'E474:')
21052
f3c72001de63 patch 8.2.1077: no enough test coverage for highlighting
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
101 call assert_equal(-1, setmatches([{'group' : 'Search', 'priority' : 10, 'id' : 5, 'pos1' : {}}]))
9776
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
102
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
103 call setline(1, 'abcdefghijklmnopq')
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
104 call matchaddpos("MyGroup1", [[1, 5], [1, 8, 3]], 10, 3)
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
105 1
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
106 redraw!
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
107 let v1 = screenattr(1, 1)
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
108 let v5 = screenattr(1, 5)
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
109 let v6 = screenattr(1, 6)
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
110 let v8 = screenattr(1, 8)
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
111 let v10 = screenattr(1, 10)
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
112 let v11 = screenattr(1, 11)
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
113 call assert_notequal(v1, v5)
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
114 call assert_equal(v6, v1)
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
115 call assert_equal(v8, v5)
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
116 call assert_equal(v10, v5)
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
117 call assert_equal(v11, v1)
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
118 call assert_equal([{'group': 'MyGroup1', 'id': 3, 'priority': 10, 'pos1': [1, 5, 1], 'pos2': [1, 8, 3]}], getmatches())
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
119 call clearmatches()
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
120
15607
2dcaa860e3fc patch 8.1.0811: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 14407
diff changeset
121 call setline(1, 'abcdΣabcdef')
30574
66de6909e102 patch 9.0.0622: matchaddpos() can get slow when adding many matches
Bram Moolenaar <Bram@vim.org>
parents: 30570
diff changeset
122 eval "MyGroup1"->matchaddpos([[1, 4, 2], [1, 9, 2]], 10, 42)
15607
2dcaa860e3fc patch 8.1.0811: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 14407
diff changeset
123 1
2dcaa860e3fc patch 8.1.0811: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 14407
diff changeset
124 redraw!
2dcaa860e3fc patch 8.1.0811: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 14407
diff changeset
125 let v1 = screenattr(1, 1)
2dcaa860e3fc patch 8.1.0811: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 14407
diff changeset
126 let v4 = screenattr(1, 4)
2dcaa860e3fc patch 8.1.0811: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 14407
diff changeset
127 let v5 = screenattr(1, 5)
2dcaa860e3fc patch 8.1.0811: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 14407
diff changeset
128 let v6 = screenattr(1, 6)
2dcaa860e3fc patch 8.1.0811: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 14407
diff changeset
129 let v7 = screenattr(1, 7)
2dcaa860e3fc patch 8.1.0811: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 14407
diff changeset
130 let v8 = screenattr(1, 8)
2dcaa860e3fc patch 8.1.0811: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 14407
diff changeset
131 let v9 = screenattr(1, 9)
2dcaa860e3fc patch 8.1.0811: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 14407
diff changeset
132 let v10 = screenattr(1, 10)
30574
66de6909e102 patch 9.0.0622: matchaddpos() can get slow when adding many matches
Bram Moolenaar <Bram@vim.org>
parents: 30570
diff changeset
133 call assert_equal([{'group': 'MyGroup1', 'id': 42, 'priority': 10, 'pos1': [1, 4, 2], 'pos2': [1, 9, 2]}], getmatches())
15607
2dcaa860e3fc patch 8.1.0811: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 14407
diff changeset
134 call assert_notequal(v1, v4)
2dcaa860e3fc patch 8.1.0811: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 14407
diff changeset
135 call assert_equal(v5, v4)
2dcaa860e3fc patch 8.1.0811: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 14407
diff changeset
136 call assert_equal(v6, v1)
2dcaa860e3fc patch 8.1.0811: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 14407
diff changeset
137 call assert_equal(v7, v1)
2dcaa860e3fc patch 8.1.0811: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 14407
diff changeset
138 call assert_equal(v8, v4)
2dcaa860e3fc patch 8.1.0811: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 14407
diff changeset
139 call assert_equal(v9, v4)
2dcaa860e3fc patch 8.1.0811: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 14407
diff changeset
140 call assert_equal(v10, v1)
9776
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
141
15607
2dcaa860e3fc patch 8.1.0811: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 14407
diff changeset
142 " Check, that setmatches() can correctly restore the matches from matchaddpos()
2dcaa860e3fc patch 8.1.0811: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 14407
diff changeset
143 call matchadd('MyGroup1', '\%2lmatchadd')
2dcaa860e3fc patch 8.1.0811: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 14407
diff changeset
144 let m=getmatches()
2dcaa860e3fc patch 8.1.0811: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 14407
diff changeset
145 call clearmatches()
2dcaa860e3fc patch 8.1.0811: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 14407
diff changeset
146 call setmatches(m)
30574
66de6909e102 patch 9.0.0622: matchaddpos() can get slow when adding many matches
Bram Moolenaar <Bram@vim.org>
parents: 30570
diff changeset
147 call assert_equal([{'group': 'MyGroup1', 'id': 42, 'priority': 10, 'pos1': [1, 4, 2], 'pos2': [1,9, 2]}, {'group': 'MyGroup1', 'pattern': '\%2lmatchadd', 'priority': 10, 'id': 1106}], getmatches())
9776
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
148
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
149 highlight MyGroup1 NONE
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
150 highlight MyGroup2 NONE
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
151 highlight MyGroup3 NONE
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
152 endfunc
2409d7038822 commit https://github.com/vim/vim/commit/d76a0c15f8bdbc901015879177fd5076d34c7a06
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
153
18951
2ade39e58400 patch 8.2.0036: not enough test coverage for match functions
Bram Moolenaar <Bram@vim.org>
parents: 17930
diff changeset
154 func Test_match_error()
2ade39e58400 patch 8.2.0036: not enough test coverage for match functions
Bram Moolenaar <Bram@vim.org>
parents: 17930
diff changeset
155 call assert_fails('match Error', 'E475:')
2ade39e58400 patch 8.2.0036: not enough test coverage for match functions
Bram Moolenaar <Bram@vim.org>
parents: 17930
diff changeset
156 call assert_fails('match Error /', 'E475:')
2ade39e58400 patch 8.2.0036: not enough test coverage for match functions
Bram Moolenaar <Bram@vim.org>
parents: 17930
diff changeset
157 call assert_fails('4match Error /x/', 'E476:')
2ade39e58400 patch 8.2.0036: not enough test coverage for match functions
Bram Moolenaar <Bram@vim.org>
parents: 17930
diff changeset
158 call assert_fails('match Error /x/ x', 'E488:')
2ade39e58400 patch 8.2.0036: not enough test coverage for match functions
Bram Moolenaar <Bram@vim.org>
parents: 17930
diff changeset
159 endfunc
2ade39e58400 patch 8.2.0036: not enough test coverage for match functions
Bram Moolenaar <Bram@vim.org>
parents: 17930
diff changeset
160
2ade39e58400 patch 8.2.0036: not enough test coverage for match functions
Bram Moolenaar <Bram@vim.org>
parents: 17930
diff changeset
161 func Test_matchadd_error()
2ade39e58400 patch 8.2.0036: not enough test coverage for match functions
Bram Moolenaar <Bram@vim.org>
parents: 17930
diff changeset
162 call assert_fails("call matchadd('GroupDoesNotExist', 'X')", 'E28:')
21265
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 21052
diff changeset
163 call assert_fails("call matchadd('Search', '\\(')", 'E54:')
18951
2ade39e58400 patch 8.2.0036: not enough test coverage for match functions
Bram Moolenaar <Bram@vim.org>
parents: 17930
diff changeset
164 call assert_fails("call matchadd('Search', 'XXX', 1, 123, 1)", 'E715:')
2ade39e58400 patch 8.2.0036: not enough test coverage for match functions
Bram Moolenaar <Bram@vim.org>
parents: 17930
diff changeset
165 call assert_fails("call matchadd('Error', 'XXX', 1, 3)", 'E798:')
2ade39e58400 patch 8.2.0036: not enough test coverage for match functions
Bram Moolenaar <Bram@vim.org>
parents: 17930
diff changeset
166 call assert_fails("call matchadd('Error', 'XXX', 1, 0)", 'E799:')
20178
2fb397573541 patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
167 call assert_fails("call matchadd('Error', 'XXX', [], 0)", 'E745:')
21052
f3c72001de63 patch 8.2.1077: no enough test coverage for highlighting
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
168 call assert_equal(-1, matchadd('', 'pat'))
f3c72001de63 patch 8.2.1077: no enough test coverage for highlighting
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
169 call assert_equal(-1, matchadd('Search', ''))
18951
2ade39e58400 patch 8.2.0036: not enough test coverage for match functions
Bram Moolenaar <Bram@vim.org>
parents: 17930
diff changeset
170 endfunc
2ade39e58400 patch 8.2.0036: not enough test coverage for match functions
Bram Moolenaar <Bram@vim.org>
parents: 17930
diff changeset
171
9885
4e8b05fa12c6 commit https://github.com/vim/vim/commit/4f416e41243ca151b95d39d81ce23d00b1484755
Christian Brabandt <cb@256bit.org>
parents: 9776
diff changeset
172 func Test_matchaddpos()
4e8b05fa12c6 commit https://github.com/vim/vim/commit/4f416e41243ca151b95d39d81ce23d00b1484755
Christian Brabandt <cb@256bit.org>
parents: 9776
diff changeset
173 syntax on
4e8b05fa12c6 commit https://github.com/vim/vim/commit/4f416e41243ca151b95d39d81ce23d00b1484755
Christian Brabandt <cb@256bit.org>
parents: 9776
diff changeset
174 set hlsearch
4e8b05fa12c6 commit https://github.com/vim/vim/commit/4f416e41243ca151b95d39d81ce23d00b1484755
Christian Brabandt <cb@256bit.org>
parents: 9776
diff changeset
175
4e8b05fa12c6 commit https://github.com/vim/vim/commit/4f416e41243ca151b95d39d81ce23d00b1484755
Christian Brabandt <cb@256bit.org>
parents: 9776
diff changeset
176 call setline(1, ['12345', 'NP'])
4e8b05fa12c6 commit https://github.com/vim/vim/commit/4f416e41243ca151b95d39d81ce23d00b1484755
Christian Brabandt <cb@256bit.org>
parents: 9776
diff changeset
177 call matchaddpos('Error', [[1,2], [1,6], [2,2]])
4e8b05fa12c6 commit https://github.com/vim/vim/commit/4f416e41243ca151b95d39d81ce23d00b1484755
Christian Brabandt <cb@256bit.org>
parents: 9776
diff changeset
178 redraw!
4e8b05fa12c6 commit https://github.com/vim/vim/commit/4f416e41243ca151b95d39d81ce23d00b1484755
Christian Brabandt <cb@256bit.org>
parents: 9776
diff changeset
179 call assert_notequal(screenattr(2,2), 0)
4e8b05fa12c6 commit https://github.com/vim/vim/commit/4f416e41243ca151b95d39d81ce23d00b1484755
Christian Brabandt <cb@256bit.org>
parents: 9776
diff changeset
180 call assert_equal(screenattr(2,2), screenattr(1,2))
4e8b05fa12c6 commit https://github.com/vim/vim/commit/4f416e41243ca151b95d39d81ce23d00b1484755
Christian Brabandt <cb@256bit.org>
parents: 9776
diff changeset
181 call assert_notequal(screenattr(2,2), screenattr(1,6))
4e8b05fa12c6 commit https://github.com/vim/vim/commit/4f416e41243ca151b95d39d81ce23d00b1484755
Christian Brabandt <cb@256bit.org>
parents: 9776
diff changeset
182 1
4e8b05fa12c6 commit https://github.com/vim/vim/commit/4f416e41243ca151b95d39d81ce23d00b1484755
Christian Brabandt <cb@256bit.org>
parents: 9776
diff changeset
183 call matchadd('Search', 'N\|\n')
4e8b05fa12c6 commit https://github.com/vim/vim/commit/4f416e41243ca151b95d39d81ce23d00b1484755
Christian Brabandt <cb@256bit.org>
parents: 9776
diff changeset
184 redraw!
4e8b05fa12c6 commit https://github.com/vim/vim/commit/4f416e41243ca151b95d39d81ce23d00b1484755
Christian Brabandt <cb@256bit.org>
parents: 9776
diff changeset
185 call assert_notequal(screenattr(2,1), 0)
4e8b05fa12c6 commit https://github.com/vim/vim/commit/4f416e41243ca151b95d39d81ce23d00b1484755
Christian Brabandt <cb@256bit.org>
parents: 9776
diff changeset
186 call assert_equal(screenattr(2,1), screenattr(1,6))
4e8b05fa12c6 commit https://github.com/vim/vim/commit/4f416e41243ca151b95d39d81ce23d00b1484755
Christian Brabandt <cb@256bit.org>
parents: 9776
diff changeset
187 exec "norm! i0\<Esc>"
4e8b05fa12c6 commit https://github.com/vim/vim/commit/4f416e41243ca151b95d39d81ce23d00b1484755
Christian Brabandt <cb@256bit.org>
parents: 9776
diff changeset
188 redraw!
4e8b05fa12c6 commit https://github.com/vim/vim/commit/4f416e41243ca151b95d39d81ce23d00b1484755
Christian Brabandt <cb@256bit.org>
parents: 9776
diff changeset
189 call assert_equal(screenattr(2,2), screenattr(1,6))
4e8b05fa12c6 commit https://github.com/vim/vim/commit/4f416e41243ca151b95d39d81ce23d00b1484755
Christian Brabandt <cb@256bit.org>
parents: 9776
diff changeset
190
10273
489eae19cad9 commit https://github.com/vim/vim/commit/a6c27ee6db2c328e0ab0e6d143e2a295a0bb9c9a
Christian Brabandt <cb@256bit.org>
parents: 9992
diff changeset
191 " Check overlapping pos
489eae19cad9 commit https://github.com/vim/vim/commit/a6c27ee6db2c328e0ab0e6d143e2a295a0bb9c9a
Christian Brabandt <cb@256bit.org>
parents: 9992
diff changeset
192 call clearmatches()
489eae19cad9 commit https://github.com/vim/vim/commit/a6c27ee6db2c328e0ab0e6d143e2a295a0bb9c9a
Christian Brabandt <cb@256bit.org>
parents: 9992
diff changeset
193 call setline(1, ['1234567890', 'NH'])
489eae19cad9 commit https://github.com/vim/vim/commit/a6c27ee6db2c328e0ab0e6d143e2a295a0bb9c9a
Christian Brabandt <cb@256bit.org>
parents: 9992
diff changeset
194 call matchaddpos('Error', [[1,1,5], [1,3,5], [2,2]])
489eae19cad9 commit https://github.com/vim/vim/commit/a6c27ee6db2c328e0ab0e6d143e2a295a0bb9c9a
Christian Brabandt <cb@256bit.org>
parents: 9992
diff changeset
195 redraw!
489eae19cad9 commit https://github.com/vim/vim/commit/a6c27ee6db2c328e0ab0e6d143e2a295a0bb9c9a
Christian Brabandt <cb@256bit.org>
parents: 9992
diff changeset
196 call assert_notequal(screenattr(2,2), 0)
489eae19cad9 commit https://github.com/vim/vim/commit/a6c27ee6db2c328e0ab0e6d143e2a295a0bb9c9a
Christian Brabandt <cb@256bit.org>
parents: 9992
diff changeset
197 call assert_equal(screenattr(2,2), screenattr(1,5))
489eae19cad9 commit https://github.com/vim/vim/commit/a6c27ee6db2c328e0ab0e6d143e2a295a0bb9c9a
Christian Brabandt <cb@256bit.org>
parents: 9992
diff changeset
198 call assert_equal(screenattr(2,2), screenattr(1,7))
489eae19cad9 commit https://github.com/vim/vim/commit/a6c27ee6db2c328e0ab0e6d143e2a295a0bb9c9a
Christian Brabandt <cb@256bit.org>
parents: 9992
diff changeset
199 call assert_notequal(screenattr(2,2), screenattr(1,8))
489eae19cad9 commit https://github.com/vim/vim/commit/a6c27ee6db2c328e0ab0e6d143e2a295a0bb9c9a
Christian Brabandt <cb@256bit.org>
parents: 9992
diff changeset
200
10287
1c1fcf515607 commit https://github.com/vim/vim/commit/8507747600bddfd6a68aed057840856bf5548e61
Christian Brabandt <cb@256bit.org>
parents: 10273
diff changeset
201 call clearmatches()
1c1fcf515607 commit https://github.com/vim/vim/commit/8507747600bddfd6a68aed057840856bf5548e61
Christian Brabandt <cb@256bit.org>
parents: 10273
diff changeset
202 call matchaddpos('Error', [[1], [2,2]])
1c1fcf515607 commit https://github.com/vim/vim/commit/8507747600bddfd6a68aed057840856bf5548e61
Christian Brabandt <cb@256bit.org>
parents: 10273
diff changeset
203 redraw!
1c1fcf515607 commit https://github.com/vim/vim/commit/8507747600bddfd6a68aed057840856bf5548e61
Christian Brabandt <cb@256bit.org>
parents: 10273
diff changeset
204 call assert_equal(screenattr(2,2), screenattr(1,1))
1c1fcf515607 commit https://github.com/vim/vim/commit/8507747600bddfd6a68aed057840856bf5548e61
Christian Brabandt <cb@256bit.org>
parents: 10273
diff changeset
205 call assert_equal(screenattr(2,2), screenattr(1,10))
1c1fcf515607 commit https://github.com/vim/vim/commit/8507747600bddfd6a68aed057840856bf5548e61
Christian Brabandt <cb@256bit.org>
parents: 10273
diff changeset
206 call assert_notequal(screenattr(2,2), screenattr(1,11))
1c1fcf515607 commit https://github.com/vim/vim/commit/8507747600bddfd6a68aed057840856bf5548e61
Christian Brabandt <cb@256bit.org>
parents: 10273
diff changeset
207
21052
f3c72001de63 patch 8.2.1077: no enough test coverage for highlighting
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
208 " matchaddpos() with line number as 0
f3c72001de63 patch 8.2.1077: no enough test coverage for highlighting
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
209 call clearmatches()
f3c72001de63 patch 8.2.1077: no enough test coverage for highlighting
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
210 let id = matchaddpos('Search', [[0], [3], [0]])
f3c72001de63 patch 8.2.1077: no enough test coverage for highlighting
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
211 call assert_equal([{'group' : 'Search', 'priority' : 10, 'id' : id, 'pos1' : [3]}], getmatches())
f3c72001de63 patch 8.2.1077: no enough test coverage for highlighting
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
212 call clearmatches()
f3c72001de63 patch 8.2.1077: no enough test coverage for highlighting
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
213 let id = matchaddpos('Search', [0, 3, 0])
f3c72001de63 patch 8.2.1077: no enough test coverage for highlighting
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
214 call assert_equal([{'group' : 'Search', 'priority' : 10, 'id' : id, 'pos1' : [3]}], getmatches())
f3c72001de63 patch 8.2.1077: no enough test coverage for highlighting
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
215
9885
4e8b05fa12c6 commit https://github.com/vim/vim/commit/4f416e41243ca151b95d39d81ce23d00b1484755
Christian Brabandt <cb@256bit.org>
parents: 9776
diff changeset
216 nohl
10287
1c1fcf515607 commit https://github.com/vim/vim/commit/8507747600bddfd6a68aed057840856bf5548e61
Christian Brabandt <cb@256bit.org>
parents: 10273
diff changeset
217 call clearmatches()
9885
4e8b05fa12c6 commit https://github.com/vim/vim/commit/4f416e41243ca151b95d39d81ce23d00b1484755
Christian Brabandt <cb@256bit.org>
parents: 9776
diff changeset
218 syntax off
4e8b05fa12c6 commit https://github.com/vim/vim/commit/4f416e41243ca151b95d39d81ce23d00b1484755
Christian Brabandt <cb@256bit.org>
parents: 9776
diff changeset
219 set hlsearch&
4e8b05fa12c6 commit https://github.com/vim/vim/commit/4f416e41243ca151b95d39d81ce23d00b1484755
Christian Brabandt <cb@256bit.org>
parents: 9776
diff changeset
220 endfunc
4e8b05fa12c6 commit https://github.com/vim/vim/commit/4f416e41243ca151b95d39d81ce23d00b1484755
Christian Brabandt <cb@256bit.org>
parents: 9776
diff changeset
221
30570
86683eee58ac patch 9.0.0620: matchaddpos() can only add up to 8 matches
Bram Moolenaar <Bram@vim.org>
parents: 30015
diff changeset
222 " Add 12 match positions (previously the limit was 8 positions).
86683eee58ac patch 9.0.0620: matchaddpos() can only add up to 8 matches
Bram Moolenaar <Bram@vim.org>
parents: 30015
diff changeset
223 func Test_matchaddpos_dump()
86683eee58ac patch 9.0.0620: matchaddpos() can only add up to 8 matches
Bram Moolenaar <Bram@vim.org>
parents: 30015
diff changeset
224 CheckScreendump
86683eee58ac patch 9.0.0620: matchaddpos() can only add up to 8 matches
Bram Moolenaar <Bram@vim.org>
parents: 30015
diff changeset
225
86683eee58ac patch 9.0.0620: matchaddpos() can only add up to 8 matches
Bram Moolenaar <Bram@vim.org>
parents: 30015
diff changeset
226 let lines =<< trim END
86683eee58ac patch 9.0.0620: matchaddpos() can only add up to 8 matches
Bram Moolenaar <Bram@vim.org>
parents: 30015
diff changeset
227 call setline(1, ['1234567890123']->repeat(14))
86683eee58ac patch 9.0.0620: matchaddpos() can only add up to 8 matches
Bram Moolenaar <Bram@vim.org>
parents: 30015
diff changeset
228 call matchaddpos('Search', range(1, 12)->map({i, v -> [v, v]}))
86683eee58ac patch 9.0.0620: matchaddpos() can only add up to 8 matches
Bram Moolenaar <Bram@vim.org>
parents: 30015
diff changeset
229 END
86683eee58ac patch 9.0.0620: matchaddpos() can only add up to 8 matches
Bram Moolenaar <Bram@vim.org>
parents: 30015
diff changeset
230 call writefile(lines, 'Xmatchaddpos', 'D')
86683eee58ac patch 9.0.0620: matchaddpos() can only add up to 8 matches
Bram Moolenaar <Bram@vim.org>
parents: 30015
diff changeset
231 let buf = RunVimInTerminal('-S Xmatchaddpos', #{rows: 14})
86683eee58ac patch 9.0.0620: matchaddpos() can only add up to 8 matches
Bram Moolenaar <Bram@vim.org>
parents: 30015
diff changeset
232 call VerifyScreenDump(buf, 'Test_matchaddpos_1', {})
86683eee58ac patch 9.0.0620: matchaddpos() can only add up to 8 matches
Bram Moolenaar <Bram@vim.org>
parents: 30015
diff changeset
233
86683eee58ac patch 9.0.0620: matchaddpos() can only add up to 8 matches
Bram Moolenaar <Bram@vim.org>
parents: 30015
diff changeset
234 call StopVimInTerminal(buf)
86683eee58ac patch 9.0.0620: matchaddpos() can only add up to 8 matches
Bram Moolenaar <Bram@vim.org>
parents: 30015
diff changeset
235 endfunc
86683eee58ac patch 9.0.0620: matchaddpos() can only add up to 8 matches
Bram Moolenaar <Bram@vim.org>
parents: 30015
diff changeset
236
14407
631344964949 patch 8.1.0218: cannot add matches to another window
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
237 func Test_matchaddpos_otherwin()
631344964949 patch 8.1.0218: cannot add matches to another window
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
238 syntax on
631344964949 patch 8.1.0218: cannot add matches to another window
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
239 new
631344964949 patch 8.1.0218: cannot add matches to another window
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
240 call setline(1, ['12345', 'NP'])
631344964949 patch 8.1.0218: cannot add matches to another window
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
241 let winid = win_getid()
631344964949 patch 8.1.0218: cannot add matches to another window
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
242
631344964949 patch 8.1.0218: cannot add matches to another window
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
243 wincmd w
631344964949 patch 8.1.0218: cannot add matches to another window
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
244 call matchadd('Search', '4', 10, -1, {'window': winid})
631344964949 patch 8.1.0218: cannot add matches to another window
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
245 call matchaddpos('Error', [[1,2], [2,2]], 10, -1, {'window': winid})
631344964949 patch 8.1.0218: cannot add matches to another window
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
246 redraw!
631344964949 patch 8.1.0218: cannot add matches to another window
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
247 call assert_notequal(screenattr(1,2), 0)
631344964949 patch 8.1.0218: cannot add matches to another window
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
248 call assert_notequal(screenattr(1,4), 0)
631344964949 patch 8.1.0218: cannot add matches to another window
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
249 call assert_notequal(screenattr(2,2), 0)
631344964949 patch 8.1.0218: cannot add matches to another window
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
250 call assert_equal(screenattr(1,2), screenattr(2,2))
631344964949 patch 8.1.0218: cannot add matches to another window
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
251 call assert_notequal(screenattr(1,2), screenattr(1,4))
631344964949 patch 8.1.0218: cannot add matches to another window
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
252
16158
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
253 let savematches = getmatches(winid)
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
254 let expect = [
30574
66de6909e102 patch 9.0.0622: matchaddpos() can get slow when adding many matches
Bram Moolenaar <Bram@vim.org>
parents: 30570
diff changeset
255 \ {'group': 'Search', 'pattern': '4', 'priority': 10, 'id': 1000},
66de6909e102 patch 9.0.0622: matchaddpos() can get slow when adding many matches
Bram Moolenaar <Bram@vim.org>
parents: 30570
diff changeset
256 \ {'group': 'Error', 'id': 1001, 'priority': 10, 'pos1': [1, 2, 1], 'pos2': [2, 2, 1]},
16158
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
257 \]
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
258 call assert_equal(expect, savematches)
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
259
17837
f71ee7b04f0b patch 8.1.1915: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
260 eval winid->clearmatches()
16158
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
261 call assert_equal([], getmatches(winid))
21052
f3c72001de63 patch 8.2.1077: no enough test coverage for highlighting
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
262 call assert_fails('echo getmatches(-1)', 'E957:')
16158
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
263
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
264 call setmatches(savematches, winid)
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
265 call assert_equal(expect, savematches)
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
266
14407
631344964949 patch 8.1.0218: cannot add matches to another window
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
267 wincmd w
631344964949 patch 8.1.0218: cannot add matches to another window
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
268 bwipe!
631344964949 patch 8.1.0218: cannot add matches to another window
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
269 call clearmatches()
631344964949 patch 8.1.0218: cannot add matches to another window
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
270 syntax off
631344964949 patch 8.1.0218: cannot add matches to another window
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
271 endfunc
631344964949 patch 8.1.0218: cannot add matches to another window
Christian Brabandt <cb@256bit.org>
parents: 12451
diff changeset
272
9992
3e3b0ce24b61 commit https://github.com/vim/vim/commit/e17bdffff78ebd6a4e3cff26754cc667557ea810
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
273 func Test_matchaddpos_using_negative_priority()
3e3b0ce24b61 commit https://github.com/vim/vim/commit/e17bdffff78ebd6a4e3cff26754cc667557ea810
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
274 set hlsearch
3e3b0ce24b61 commit https://github.com/vim/vim/commit/e17bdffff78ebd6a4e3cff26754cc667557ea810
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
275
3e3b0ce24b61 commit https://github.com/vim/vim/commit/e17bdffff78ebd6a4e3cff26754cc667557ea810
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
276 call clearmatches()
3e3b0ce24b61 commit https://github.com/vim/vim/commit/e17bdffff78ebd6a4e3cff26754cc667557ea810
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
277
3e3b0ce24b61 commit https://github.com/vim/vim/commit/e17bdffff78ebd6a4e3cff26754cc667557ea810
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
278 call setline(1, 'x')
3e3b0ce24b61 commit https://github.com/vim/vim/commit/e17bdffff78ebd6a4e3cff26754cc667557ea810
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
279 let @/='x'
3e3b0ce24b61 commit https://github.com/vim/vim/commit/e17bdffff78ebd6a4e3cff26754cc667557ea810
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
280 redraw!
3e3b0ce24b61 commit https://github.com/vim/vim/commit/e17bdffff78ebd6a4e3cff26754cc667557ea810
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
281 let search_attr = screenattr(1,1)
3e3b0ce24b61 commit https://github.com/vim/vim/commit/e17bdffff78ebd6a4e3cff26754cc667557ea810
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
282
3e3b0ce24b61 commit https://github.com/vim/vim/commit/e17bdffff78ebd6a4e3cff26754cc667557ea810
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
283 let @/=''
3e3b0ce24b61 commit https://github.com/vim/vim/commit/e17bdffff78ebd6a4e3cff26754cc667557ea810
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
284 call matchaddpos('Error', [1], 10)
3e3b0ce24b61 commit https://github.com/vim/vim/commit/e17bdffff78ebd6a4e3cff26754cc667557ea810
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
285 redraw!
3e3b0ce24b61 commit https://github.com/vim/vim/commit/e17bdffff78ebd6a4e3cff26754cc667557ea810
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
286 let error_attr = screenattr(1,1)
3e3b0ce24b61 commit https://github.com/vim/vim/commit/e17bdffff78ebd6a4e3cff26754cc667557ea810
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
287
3e3b0ce24b61 commit https://github.com/vim/vim/commit/e17bdffff78ebd6a4e3cff26754cc667557ea810
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
288 call setline(2, '-1 match priority')
3e3b0ce24b61 commit https://github.com/vim/vim/commit/e17bdffff78ebd6a4e3cff26754cc667557ea810
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
289 call matchaddpos('Error', [2], -1)
3e3b0ce24b61 commit https://github.com/vim/vim/commit/e17bdffff78ebd6a4e3cff26754cc667557ea810
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
290 redraw!
3e3b0ce24b61 commit https://github.com/vim/vim/commit/e17bdffff78ebd6a4e3cff26754cc667557ea810
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
291 let negative_match_priority_attr = screenattr(2,1)
3e3b0ce24b61 commit https://github.com/vim/vim/commit/e17bdffff78ebd6a4e3cff26754cc667557ea810
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
292
3e3b0ce24b61 commit https://github.com/vim/vim/commit/e17bdffff78ebd6a4e3cff26754cc667557ea810
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
293 call assert_notequal(negative_match_priority_attr, search_attr, "Match with negative priority is incorrectly highlighted with Search highlight.")
3e3b0ce24b61 commit https://github.com/vim/vim/commit/e17bdffff78ebd6a4e3cff26754cc667557ea810
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
294 call assert_equal(negative_match_priority_attr, error_attr)
3e3b0ce24b61 commit https://github.com/vim/vim/commit/e17bdffff78ebd6a4e3cff26754cc667557ea810
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
295
3e3b0ce24b61 commit https://github.com/vim/vim/commit/e17bdffff78ebd6a4e3cff26754cc667557ea810
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
296 nohl
3e3b0ce24b61 commit https://github.com/vim/vim/commit/e17bdffff78ebd6a4e3cff26754cc667557ea810
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
297 set hlsearch&
3e3b0ce24b61 commit https://github.com/vim/vim/commit/e17bdffff78ebd6a4e3cff26754cc667557ea810
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
298 endfunc
3e3b0ce24b61 commit https://github.com/vim/vim/commit/e17bdffff78ebd6a4e3cff26754cc667557ea810
Christian Brabandt <cb@256bit.org>
parents: 9909
diff changeset
299
18951
2ade39e58400 patch 8.2.0036: not enough test coverage for match functions
Bram Moolenaar <Bram@vim.org>
parents: 17930
diff changeset
300 func Test_matchaddpos_error()
2ade39e58400 patch 8.2.0036: not enough test coverage for match functions
Bram Moolenaar <Bram@vim.org>
parents: 17930
diff changeset
301 call assert_fails("call matchaddpos('Error', 1)", 'E686:')
2ade39e58400 patch 8.2.0036: not enough test coverage for match functions
Bram Moolenaar <Bram@vim.org>
parents: 17930
diff changeset
302 call assert_fails("call matchaddpos('Error', [1], 1, 1)", 'E798:')
2ade39e58400 patch 8.2.0036: not enough test coverage for match functions
Bram Moolenaar <Bram@vim.org>
parents: 17930
diff changeset
303 call assert_fails("call matchaddpos('Error', [1], 1, 2)", 'E798:')
2ade39e58400 patch 8.2.0036: not enough test coverage for match functions
Bram Moolenaar <Bram@vim.org>
parents: 17930
diff changeset
304 call assert_fails("call matchaddpos('Error', [1], 1, 0)", 'E799:')
2ade39e58400 patch 8.2.0036: not enough test coverage for match functions
Bram Moolenaar <Bram@vim.org>
parents: 17930
diff changeset
305 call assert_fails("call matchaddpos('Error', [1], 1, 123, 1)", 'E715:')
2ade39e58400 patch 8.2.0036: not enough test coverage for match functions
Bram Moolenaar <Bram@vim.org>
parents: 17930
diff changeset
306 call assert_fails("call matchaddpos('Error', [1], 1, 5, {'window':12345})", 'E957:')
2ade39e58400 patch 8.2.0036: not enough test coverage for match functions
Bram Moolenaar <Bram@vim.org>
parents: 17930
diff changeset
307 " Why doesn't the following error have an error code E...?
2ade39e58400 patch 8.2.0036: not enough test coverage for match functions
Bram Moolenaar <Bram@vim.org>
parents: 17930
diff changeset
308 call assert_fails("call matchaddpos('Error', [{}])", 'E290:')
20178
2fb397573541 patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
309 call assert_equal(-1, matchaddpos('Error', test_null_list()))
2fb397573541 patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
310 call assert_fails("call matchaddpos('Error', [1], [], 1)", 'E745:')
21052
f3c72001de63 patch 8.2.1077: no enough test coverage for highlighting
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
311 call assert_equal(-1, matchaddpos('Search', [[]]))
f3c72001de63 patch 8.2.1077: no enough test coverage for highlighting
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
312 call assert_fails("call matchaddpos('Search', [[{}]])", 'E728:')
f3c72001de63 patch 8.2.1077: no enough test coverage for highlighting
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
313 call assert_fails("call matchaddpos('Search', [[2, {}]])", 'E728:')
f3c72001de63 patch 8.2.1077: no enough test coverage for highlighting
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
314 call assert_fails("call matchaddpos('Search', [[3, 4, {}]])", 'E728:')
18951
2ade39e58400 patch 8.2.0036: not enough test coverage for match functions
Bram Moolenaar <Bram@vim.org>
parents: 17930
diff changeset
315 endfunc
2ade39e58400 patch 8.2.0036: not enough test coverage for match functions
Bram Moolenaar <Bram@vim.org>
parents: 17930
diff changeset
316
17486
bdf277d2d14c patch 8.1.1741: cleared/added match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents: 17482
diff changeset
317 func OtherWindowCommon()
17482
6cf077f59152 patch 8.1.1739: deleted match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents: 16158
diff changeset
318 let lines =<< trim END
6cf077f59152 patch 8.1.1739: deleted match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents: 16158
diff changeset
319 call setline(1, 'Hello Vim world')
6cf077f59152 patch 8.1.1739: deleted match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents: 16158
diff changeset
320 let mid = matchadd('Error', 'world', 1)
6cf077f59152 patch 8.1.1739: deleted match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents: 16158
diff changeset
321 let winid = win_getid()
6cf077f59152 patch 8.1.1739: deleted match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents: 16158
diff changeset
322 new
6cf077f59152 patch 8.1.1739: deleted match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents: 16158
diff changeset
323 END
17486
bdf277d2d14c patch 8.1.1741: cleared/added match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents: 17482
diff changeset
324 call writefile(lines, 'XscriptMatchCommon')
bdf277d2d14c patch 8.1.1741: cleared/added match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents: 17482
diff changeset
325 let buf = RunVimInTerminal('-S XscriptMatchCommon', #{rows: 12})
19954
c087099e9163 patch 8.2.0533: tests using term_wait() can still be flaky
Bram Moolenaar <Bram@vim.org>
parents: 18951
diff changeset
326 call TermWait(buf)
17486
bdf277d2d14c patch 8.1.1741: cleared/added match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents: 17482
diff changeset
327 return buf
bdf277d2d14c patch 8.1.1741: cleared/added match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents: 17482
diff changeset
328 endfunc
bdf277d2d14c patch 8.1.1741: cleared/added match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents: 17482
diff changeset
329
bdf277d2d14c patch 8.1.1741: cleared/added match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents: 17482
diff changeset
330 func Test_matchdelete_other_window()
17657
0da9bc55c31a patch 8.1.1826: tests use hand coded feature and option checks
Bram Moolenaar <Bram@vim.org>
parents: 17486
diff changeset
331 CheckScreendump
0da9bc55c31a patch 8.1.1826: tests use hand coded feature and option checks
Bram Moolenaar <Bram@vim.org>
parents: 17486
diff changeset
332
17486
bdf277d2d14c patch 8.1.1741: cleared/added match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents: 17482
diff changeset
333 let buf = OtherWindowCommon()
17482
6cf077f59152 patch 8.1.1739: deleted match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents: 16158
diff changeset
334 call term_sendkeys(buf, ":call matchdelete(mid, winid)\<CR>")
6cf077f59152 patch 8.1.1739: deleted match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents: 16158
diff changeset
335 call VerifyScreenDump(buf, 'Test_matchdelete_1', {})
6cf077f59152 patch 8.1.1739: deleted match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents: 16158
diff changeset
336
6cf077f59152 patch 8.1.1739: deleted match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents: 16158
diff changeset
337 call StopVimInTerminal(buf)
17486
bdf277d2d14c patch 8.1.1741: cleared/added match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents: 17482
diff changeset
338 call delete('XscriptMatchCommon')
bdf277d2d14c patch 8.1.1741: cleared/added match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents: 17482
diff changeset
339 endfunc
bdf277d2d14c patch 8.1.1741: cleared/added match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents: 17482
diff changeset
340
18951
2ade39e58400 patch 8.2.0036: not enough test coverage for match functions
Bram Moolenaar <Bram@vim.org>
parents: 17930
diff changeset
341 func Test_matchdelete_error()
2ade39e58400 patch 8.2.0036: not enough test coverage for match functions
Bram Moolenaar <Bram@vim.org>
parents: 17930
diff changeset
342 call assert_fails("call matchdelete(0)", 'E802:')
2ade39e58400 patch 8.2.0036: not enough test coverage for match functions
Bram Moolenaar <Bram@vim.org>
parents: 17930
diff changeset
343 call assert_fails("call matchdelete(1, -1)", 'E957:')
2ade39e58400 patch 8.2.0036: not enough test coverage for match functions
Bram Moolenaar <Bram@vim.org>
parents: 17930
diff changeset
344 endfunc
2ade39e58400 patch 8.2.0036: not enough test coverage for match functions
Bram Moolenaar <Bram@vim.org>
parents: 17930
diff changeset
345
17486
bdf277d2d14c patch 8.1.1741: cleared/added match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents: 17482
diff changeset
346 func Test_matchclear_other_window()
20625
116c7bd5e980 patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents: 20178
diff changeset
347 CheckRunVimInTerminal
17486
bdf277d2d14c patch 8.1.1741: cleared/added match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents: 17482
diff changeset
348 let buf = OtherWindowCommon()
bdf277d2d14c patch 8.1.1741: cleared/added match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents: 17482
diff changeset
349 call term_sendkeys(buf, ":call clearmatches(winid)\<CR>")
bdf277d2d14c patch 8.1.1741: cleared/added match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents: 17482
diff changeset
350 call VerifyScreenDump(buf, 'Test_matchclear_1', {})
bdf277d2d14c patch 8.1.1741: cleared/added match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents: 17482
diff changeset
351
bdf277d2d14c patch 8.1.1741: cleared/added match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents: 17482
diff changeset
352 call StopVimInTerminal(buf)
bdf277d2d14c patch 8.1.1741: cleared/added match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents: 17482
diff changeset
353 call delete('XscriptMatchCommon')
bdf277d2d14c patch 8.1.1741: cleared/added match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents: 17482
diff changeset
354 endfunc
bdf277d2d14c patch 8.1.1741: cleared/added match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents: 17482
diff changeset
355
bdf277d2d14c patch 8.1.1741: cleared/added match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents: 17482
diff changeset
356 func Test_matchadd_other_window()
20625
116c7bd5e980 patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents: 20178
diff changeset
357 CheckRunVimInTerminal
17486
bdf277d2d14c patch 8.1.1741: cleared/added match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents: 17482
diff changeset
358 let buf = OtherWindowCommon()
bdf277d2d14c patch 8.1.1741: cleared/added match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents: 17482
diff changeset
359 call term_sendkeys(buf, ":call matchadd('Search', 'Hello', 1, -1, #{window: winid})\<CR>")
bdf277d2d14c patch 8.1.1741: cleared/added match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents: 17482
diff changeset
360 call term_sendkeys(buf, ":\<CR>")
bdf277d2d14c patch 8.1.1741: cleared/added match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents: 17482
diff changeset
361 call VerifyScreenDump(buf, 'Test_matchadd_1', {})
bdf277d2d14c patch 8.1.1741: cleared/added match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents: 17482
diff changeset
362
bdf277d2d14c patch 8.1.1741: cleared/added match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents: 17482
diff changeset
363 call StopVimInTerminal(buf)
bdf277d2d14c patch 8.1.1741: cleared/added match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents: 17482
diff changeset
364 call delete('XscriptMatchCommon')
17482
6cf077f59152 patch 8.1.1739: deleted match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents: 16158
diff changeset
365 endfunc
6cf077f59152 patch 8.1.1739: deleted match highlighting not updated in other window
Bram Moolenaar <Bram@vim.org>
parents: 16158
diff changeset
366
26334
baec4e1cee43 patch 8.2.3698: match highlighting continues over breakindent
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
367 func Test_match_in_linebreak()
baec4e1cee43 patch 8.2.3698: match highlighting continues over breakindent
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
368 CheckRunVimInTerminal
baec4e1cee43 patch 8.2.3698: match highlighting continues over breakindent
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
369
baec4e1cee43 patch 8.2.3698: match highlighting continues over breakindent
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
370 let lines =<< trim END
baec4e1cee43 patch 8.2.3698: match highlighting continues over breakindent
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
371 set breakindent linebreak breakat+=]
baec4e1cee43 patch 8.2.3698: match highlighting continues over breakindent
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
372 call printf('%s]%s', repeat('x', 50), repeat('x', 70))->setline(1)
baec4e1cee43 patch 8.2.3698: match highlighting continues over breakindent
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
373 call matchaddpos('ErrorMsg', [[1, 51]])
baec4e1cee43 patch 8.2.3698: match highlighting continues over breakindent
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
374 END
30582
72245f9c9405 patch 9.0.0626: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30574
diff changeset
375 call writefile(lines, 'XscriptMatchLinebreak', 'D')
26334
baec4e1cee43 patch 8.2.3698: match highlighting continues over breakindent
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
376 let buf = RunVimInTerminal('-S XscriptMatchLinebreak', #{rows: 10})
baec4e1cee43 patch 8.2.3698: match highlighting continues over breakindent
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
377 call VerifyScreenDump(buf, 'Test_match_linebreak', {})
baec4e1cee43 patch 8.2.3698: match highlighting continues over breakindent
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
378
baec4e1cee43 patch 8.2.3698: match highlighting continues over breakindent
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
379 call StopVimInTerminal(buf)
baec4e1cee43 patch 8.2.3698: match highlighting continues over breakindent
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
380 endfunc
baec4e1cee43 patch 8.2.3698: match highlighting continues over breakindent
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
381
26823
f1618f8705e4 patch 8.2.3940: match highlight disappears when doing incsearch for ":s/pat"
Bram Moolenaar <Bram@vim.org>
parents: 26334
diff changeset
382 func Test_match_with_incsearch()
f1618f8705e4 patch 8.2.3940: match highlight disappears when doing incsearch for ":s/pat"
Bram Moolenaar <Bram@vim.org>
parents: 26334
diff changeset
383 CheckRunVimInTerminal
f1618f8705e4 patch 8.2.3940: match highlight disappears when doing incsearch for ":s/pat"
Bram Moolenaar <Bram@vim.org>
parents: 26334
diff changeset
384
f1618f8705e4 patch 8.2.3940: match highlight disappears when doing incsearch for ":s/pat"
Bram Moolenaar <Bram@vim.org>
parents: 26334
diff changeset
385 let lines =<< trim END
f1618f8705e4 patch 8.2.3940: match highlight disappears when doing incsearch for ":s/pat"
Bram Moolenaar <Bram@vim.org>
parents: 26334
diff changeset
386 set incsearch
f1618f8705e4 patch 8.2.3940: match highlight disappears when doing incsearch for ":s/pat"
Bram Moolenaar <Bram@vim.org>
parents: 26334
diff changeset
387 call setline(1, range(20))
f1618f8705e4 patch 8.2.3940: match highlight disappears when doing incsearch for ":s/pat"
Bram Moolenaar <Bram@vim.org>
parents: 26334
diff changeset
388 call matchaddpos('ErrorMsg', [3])
f1618f8705e4 patch 8.2.3940: match highlight disappears when doing incsearch for ":s/pat"
Bram Moolenaar <Bram@vim.org>
parents: 26334
diff changeset
389 END
30582
72245f9c9405 patch 9.0.0626: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30574
diff changeset
390 call writefile(lines, 'XmatchWithIncsearch', 'D')
26823
f1618f8705e4 patch 8.2.3940: match highlight disappears when doing incsearch for ":s/pat"
Bram Moolenaar <Bram@vim.org>
parents: 26334
diff changeset
391 let buf = RunVimInTerminal('-S XmatchWithIncsearch', #{rows: 6})
f1618f8705e4 patch 8.2.3940: match highlight disappears when doing incsearch for ":s/pat"
Bram Moolenaar <Bram@vim.org>
parents: 26334
diff changeset
392 call VerifyScreenDump(buf, 'Test_match_with_incsearch_1', {})
f1618f8705e4 patch 8.2.3940: match highlight disappears when doing incsearch for ":s/pat"
Bram Moolenaar <Bram@vim.org>
parents: 26334
diff changeset
393
f1618f8705e4 patch 8.2.3940: match highlight disappears when doing incsearch for ":s/pat"
Bram Moolenaar <Bram@vim.org>
parents: 26334
diff changeset
394 call term_sendkeys(buf, ":s/0")
f1618f8705e4 patch 8.2.3940: match highlight disappears when doing incsearch for ":s/pat"
Bram Moolenaar <Bram@vim.org>
parents: 26334
diff changeset
395 call VerifyScreenDump(buf, 'Test_match_with_incsearch_2', {})
f1618f8705e4 patch 8.2.3940: match highlight disappears when doing incsearch for ":s/pat"
Bram Moolenaar <Bram@vim.org>
parents: 26334
diff changeset
396
f1618f8705e4 patch 8.2.3940: match highlight disappears when doing incsearch for ":s/pat"
Bram Moolenaar <Bram@vim.org>
parents: 26334
diff changeset
397 call term_sendkeys(buf, "\<CR>")
f1618f8705e4 patch 8.2.3940: match highlight disappears when doing incsearch for ":s/pat"
Bram Moolenaar <Bram@vim.org>
parents: 26334
diff changeset
398 call StopVimInTerminal(buf)
f1618f8705e4 patch 8.2.3940: match highlight disappears when doing incsearch for ":s/pat"
Bram Moolenaar <Bram@vim.org>
parents: 26334
diff changeset
399 endfunc
f1618f8705e4 patch 8.2.3940: match highlight disappears when doing incsearch for ":s/pat"
Bram Moolenaar <Bram@vim.org>
parents: 26334
diff changeset
400
21052
f3c72001de63 patch 8.2.1077: no enough test coverage for highlighting
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
401 " Test for deleting matches outside of the screen redraw top/bottom lines
f3c72001de63 patch 8.2.1077: no enough test coverage for highlighting
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
402 " This should cause a redraw of those lines.
f3c72001de63 patch 8.2.1077: no enough test coverage for highlighting
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
403 func Test_matchdelete_redraw()
f3c72001de63 patch 8.2.1077: no enough test coverage for highlighting
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
404 new
f3c72001de63 patch 8.2.1077: no enough test coverage for highlighting
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
405 call setline(1, range(1, 500))
f3c72001de63 patch 8.2.1077: no enough test coverage for highlighting
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
406 call cursor(250, 1)
f3c72001de63 patch 8.2.1077: no enough test coverage for highlighting
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
407 let m1 = matchaddpos('Search', [[250]])
f3c72001de63 patch 8.2.1077: no enough test coverage for highlighting
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
408 let m2 = matchaddpos('Search', [[10], [450]])
f3c72001de63 patch 8.2.1077: no enough test coverage for highlighting
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
409 redraw!
f3c72001de63 patch 8.2.1077: no enough test coverage for highlighting
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
410 let m3 = matchaddpos('Search', [[240], [260]])
f3c72001de63 patch 8.2.1077: no enough test coverage for highlighting
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
411 call matchdelete(m2)
f3c72001de63 patch 8.2.1077: no enough test coverage for highlighting
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
412 let m = getmatches()
f3c72001de63 patch 8.2.1077: no enough test coverage for highlighting
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
413 call assert_equal(2, len(m))
f3c72001de63 patch 8.2.1077: no enough test coverage for highlighting
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
414 call assert_equal([250], m[0].pos1)
f3c72001de63 patch 8.2.1077: no enough test coverage for highlighting
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
415 redraw!
f3c72001de63 patch 8.2.1077: no enough test coverage for highlighting
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
416 call matchdelete(m1)
f3c72001de63 patch 8.2.1077: no enough test coverage for highlighting
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
417 call assert_equal(1, len(getmatches()))
f3c72001de63 patch 8.2.1077: no enough test coverage for highlighting
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
418 bw!
f3c72001de63 patch 8.2.1077: no enough test coverage for highlighting
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
419 endfunc
f3c72001de63 patch 8.2.1077: no enough test coverage for highlighting
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
420
27067
89bc175b25a5 patch 8.2.4062: match highlighting of tab too short
Bram Moolenaar <Bram@vim.org>
parents: 26823
diff changeset
421 func Test_match_tab_with_linebreak()
89bc175b25a5 patch 8.2.4062: match highlighting of tab too short
Bram Moolenaar <Bram@vim.org>
parents: 26823
diff changeset
422 CheckRunVimInTerminal
89bc175b25a5 patch 8.2.4062: match highlighting of tab too short
Bram Moolenaar <Bram@vim.org>
parents: 26823
diff changeset
423
89bc175b25a5 patch 8.2.4062: match highlighting of tab too short
Bram Moolenaar <Bram@vim.org>
parents: 26823
diff changeset
424 let lines =<< trim END
89bc175b25a5 patch 8.2.4062: match highlighting of tab too short
Bram Moolenaar <Bram@vim.org>
parents: 26823
diff changeset
425 set linebreak
89bc175b25a5 patch 8.2.4062: match highlighting of tab too short
Bram Moolenaar <Bram@vim.org>
parents: 26823
diff changeset
426 call setline(1, "\tix")
89bc175b25a5 patch 8.2.4062: match highlighting of tab too short
Bram Moolenaar <Bram@vim.org>
parents: 26823
diff changeset
427 call matchadd('ErrorMsg', '\t')
89bc175b25a5 patch 8.2.4062: match highlighting of tab too short
Bram Moolenaar <Bram@vim.org>
parents: 26823
diff changeset
428 END
30582
72245f9c9405 patch 9.0.0626: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30574
diff changeset
429 call writefile(lines, 'XscriptMatchTabLinebreak', 'D')
27067
89bc175b25a5 patch 8.2.4062: match highlighting of tab too short
Bram Moolenaar <Bram@vim.org>
parents: 26823
diff changeset
430 let buf = RunVimInTerminal('-S XscriptMatchTabLinebreak', #{rows: 10})
89bc175b25a5 patch 8.2.4062: match highlighting of tab too short
Bram Moolenaar <Bram@vim.org>
parents: 26823
diff changeset
431 call VerifyScreenDump(buf, 'Test_match_tab_linebreak', {})
89bc175b25a5 patch 8.2.4062: match highlighting of tab too short
Bram Moolenaar <Bram@vim.org>
parents: 26823
diff changeset
432
89bc175b25a5 patch 8.2.4062: match highlighting of tab too short
Bram Moolenaar <Bram@vim.org>
parents: 26823
diff changeset
433 call StopVimInTerminal(buf)
89bc175b25a5 patch 8.2.4062: match highlighting of tab too short
Bram Moolenaar <Bram@vim.org>
parents: 26823
diff changeset
434 endfunc
89bc175b25a5 patch 8.2.4062: match highlighting of tab too short
Bram Moolenaar <Bram@vim.org>
parents: 26823
diff changeset
435
89bc175b25a5 patch 8.2.4062: match highlighting of tab too short
Bram Moolenaar <Bram@vim.org>
parents: 26823
diff changeset
436
9909
3ee84d270ea7 commit https://github.com/vim/vim/commit/9e4d8215d386100ab660d7d11e6620fd148b605e
Christian Brabandt <cb@256bit.org>
parents: 9885
diff changeset
437 " vim: shiftwidth=2 sts=2 expandtab