Mercurial > vim
comparison src/testdir/test_match.vim @ 21052:f3c72001de63 v8.2.1077
patch 8.2.1077: no enough test coverage for highlighting
Commit: https://github.com/vim/vim/commit/75e15670b8749845cde2962ddb738dd5c6e73191
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jun 28 13:10:22 2020 +0200
patch 8.2.1077: no enough test coverage for highlighting
Problem: No enough test coverage for highlighting.
Solution: Add more tests. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/6351)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 28 Jun 2020 13:15:05 +0200 |
parents | 116c7bd5e980 |
children | 6a4806e326dd |
comparison
equal
deleted
inserted
replaced
21051:2cf2f56a250f | 21052:f3c72001de63 |
---|---|
96 call assert_equal(0, setmatches([{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id': 1}])) | 96 call assert_equal(0, setmatches([{'group': 'MyGroup1', 'pattern': 'TODO', 'priority': 10, 'id': 1}])) |
97 call clearmatches() | 97 call clearmatches() |
98 call assert_fails('call setmatches(0)', 'E714:') | 98 call assert_fails('call setmatches(0)', 'E714:') |
99 call assert_fails('call setmatches([0])', 'E474:') | 99 call assert_fails('call setmatches([0])', 'E474:') |
100 call assert_fails("call setmatches([{'wrong key': 'wrong value'}])", 'E474:') | 100 call assert_fails("call setmatches([{'wrong key': 'wrong value'}])", 'E474:') |
101 call assert_equal(-1, setmatches([{'group' : 'Search', 'priority' : 10, 'id' : 5, 'pos1' : {}}])) | |
101 | 102 |
102 call setline(1, 'abcdefghijklmnopq') | 103 call setline(1, 'abcdefghijklmnopq') |
103 call matchaddpos("MyGroup1", [[1, 5], [1, 8, 3]], 10, 3) | 104 call matchaddpos("MyGroup1", [[1, 5], [1, 8, 3]], 10, 3) |
104 1 | 105 1 |
105 redraw! | 106 redraw! |
162 call assert_fails("call matchadd('Search', '\\(')", 'E475:') | 163 call assert_fails("call matchadd('Search', '\\(')", 'E475:') |
163 call assert_fails("call matchadd('Search', 'XXX', 1, 123, 1)", 'E715:') | 164 call assert_fails("call matchadd('Search', 'XXX', 1, 123, 1)", 'E715:') |
164 call assert_fails("call matchadd('Error', 'XXX', 1, 3)", 'E798:') | 165 call assert_fails("call matchadd('Error', 'XXX', 1, 3)", 'E798:') |
165 call assert_fails("call matchadd('Error', 'XXX', 1, 0)", 'E799:') | 166 call assert_fails("call matchadd('Error', 'XXX', 1, 0)", 'E799:') |
166 call assert_fails("call matchadd('Error', 'XXX', [], 0)", 'E745:') | 167 call assert_fails("call matchadd('Error', 'XXX', [], 0)", 'E745:') |
168 call assert_equal(-1, matchadd('', 'pat')) | |
169 call assert_equal(-1, matchadd('Search', '')) | |
167 endfunc | 170 endfunc |
168 | 171 |
169 func Test_matchaddpos() | 172 func Test_matchaddpos() |
170 syntax on | 173 syntax on |
171 set hlsearch | 174 set hlsearch |
199 call matchaddpos('Error', [[1], [2,2]]) | 202 call matchaddpos('Error', [[1], [2,2]]) |
200 redraw! | 203 redraw! |
201 call assert_equal(screenattr(2,2), screenattr(1,1)) | 204 call assert_equal(screenattr(2,2), screenattr(1,1)) |
202 call assert_equal(screenattr(2,2), screenattr(1,10)) | 205 call assert_equal(screenattr(2,2), screenattr(1,10)) |
203 call assert_notequal(screenattr(2,2), screenattr(1,11)) | 206 call assert_notequal(screenattr(2,2), screenattr(1,11)) |
207 | |
208 " matchaddpos() with line number as 0 | |
209 call clearmatches() | |
210 let id = matchaddpos('Search', [[0], [3], [0]]) | |
211 call assert_equal([{'group' : 'Search', 'priority' : 10, 'id' : id, 'pos1' : [3]}], getmatches()) | |
212 call clearmatches() | |
213 let id = matchaddpos('Search', [0, 3, 0]) | |
214 call assert_equal([{'group' : 'Search', 'priority' : 10, 'id' : id, 'pos1' : [3]}], getmatches()) | |
204 | 215 |
205 nohl | 216 nohl |
206 call clearmatches() | 217 call clearmatches() |
207 syntax off | 218 syntax off |
208 set hlsearch& | 219 set hlsearch& |
231 \] | 242 \] |
232 call assert_equal(expect, savematches) | 243 call assert_equal(expect, savematches) |
233 | 244 |
234 eval winid->clearmatches() | 245 eval winid->clearmatches() |
235 call assert_equal([], getmatches(winid)) | 246 call assert_equal([], getmatches(winid)) |
247 call assert_fails('echo getmatches(-1)', 'E957:') | |
236 | 248 |
237 call setmatches(savematches, winid) | 249 call setmatches(savematches, winid) |
238 call assert_equal(expect, savematches) | 250 call assert_equal(expect, savematches) |
239 | 251 |
240 wincmd w | 252 wincmd w |
279 call assert_fails("call matchaddpos('Error', [1], 1, 5, {'window':12345})", 'E957:') | 291 call assert_fails("call matchaddpos('Error', [1], 1, 5, {'window':12345})", 'E957:') |
280 " Why doesn't the following error have an error code E...? | 292 " Why doesn't the following error have an error code E...? |
281 call assert_fails("call matchaddpos('Error', [{}])", 'E290:') | 293 call assert_fails("call matchaddpos('Error', [{}])", 'E290:') |
282 call assert_equal(-1, matchaddpos('Error', test_null_list())) | 294 call assert_equal(-1, matchaddpos('Error', test_null_list())) |
283 call assert_fails("call matchaddpos('Error', [1], [], 1)", 'E745:') | 295 call assert_fails("call matchaddpos('Error', [1], [], 1)", 'E745:') |
296 call assert_equal(-1, matchaddpos('Search', [[]])) | |
297 call assert_fails("call matchaddpos('Search', [[{}]])", 'E728:') | |
298 call assert_fails("call matchaddpos('Search', [[2, {}]])", 'E728:') | |
299 call assert_fails("call matchaddpos('Search', [[3, 4, {}]])", 'E728:') | |
284 endfunc | 300 endfunc |
285 | 301 |
286 func OtherWindowCommon() | 302 func OtherWindowCommon() |
287 let lines =<< trim END | 303 let lines =<< trim END |
288 call setline(1, 'Hello Vim world') | 304 call setline(1, 'Hello Vim world') |
331 | 347 |
332 call StopVimInTerminal(buf) | 348 call StopVimInTerminal(buf) |
333 call delete('XscriptMatchCommon') | 349 call delete('XscriptMatchCommon') |
334 endfunc | 350 endfunc |
335 | 351 |
352 " Test for deleting matches outside of the screen redraw top/bottom lines | |
353 " This should cause a redraw of those lines. | |
354 func Test_matchdelete_redraw() | |
355 new | |
356 call setline(1, range(1, 500)) | |
357 call cursor(250, 1) | |
358 let m1 = matchaddpos('Search', [[250]]) | |
359 let m2 = matchaddpos('Search', [[10], [450]]) | |
360 redraw! | |
361 let m3 = matchaddpos('Search', [[240], [260]]) | |
362 call matchdelete(m2) | |
363 let m = getmatches() | |
364 call assert_equal(2, len(m)) | |
365 call assert_equal([250], m[0].pos1) | |
366 redraw! | |
367 call matchdelete(m1) | |
368 call assert_equal(1, len(getmatches())) | |
369 bw! | |
370 endfunc | |
371 | |
336 " vim: shiftwidth=2 sts=2 expandtab | 372 " vim: shiftwidth=2 sts=2 expandtab |