Mercurial > vim
annotate src/testdir/test_hlsearch.vim @ 12225:fc791b69be77
Added tag v8.0.0992 for changeset bccf3de747249564fee1e2b1aca090391d5e5da7
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 24 Aug 2017 00:00:05 +0200 |
parents | ac20f71e8aa4 |
children | 04c168a6d998 |
rev | line source |
---|---|
10145
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Test for v:hlsearch |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 function! Test_hlsearch() |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4 new |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 call setline(1, repeat(['aaa'], 10)) |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 set hlsearch nolazyredraw |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 let r=[] |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 " redraw is needed to make hlsearch highlight the matches |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 exe "normal! /aaa\<CR>" | redraw |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 let r1 = screenattr(1, 1) |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 nohlsearch | redraw |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 call assert_notequal(r1, screenattr(1,1)) |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 let v:hlsearch=1 | redraw |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 call assert_equal(r1, screenattr(1,1)) |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 let v:hlsearch=0 | redraw |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 call assert_notequal(r1, screenattr(1,1)) |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 set hlsearch | redraw |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 call assert_equal(r1, screenattr(1,1)) |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 let v:hlsearch=0 | redraw |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 call assert_notequal(r1, screenattr(1,1)) |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 exe "normal! n" | redraw |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 call assert_equal(r1, screenattr(1,1)) |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 let v:hlsearch=0 | redraw |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 call assert_notequal(r1, screenattr(1,1)) |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 exe "normal! /\<CR>" | redraw |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 call assert_equal(r1, screenattr(1,1)) |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 set nohls |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 exe "normal! /\<CR>" | redraw |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 call assert_notequal(r1, screenattr(1,1)) |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
30 call assert_fails('let v:hlsearch=[]', 'E745') |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
31 call garbagecollect(1) |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
32 call getchar(1) |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
33 enew! |
eb9a7296ae9f
commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
34 endfunction |
11523
aad2c2ca0774
patch 8.0.0644: the timeout for 'hlsearch' is not tested
Christian Brabandt <cb@256bit.org>
parents:
10145
diff
changeset
|
35 |
aad2c2ca0774
patch 8.0.0644: the timeout for 'hlsearch' is not tested
Christian Brabandt <cb@256bit.org>
parents:
10145
diff
changeset
|
36 func Test_hlsearch_hangs() |
aad2c2ca0774
patch 8.0.0644: the timeout for 'hlsearch' is not tested
Christian Brabandt <cb@256bit.org>
parents:
10145
diff
changeset
|
37 if !has('reltime') || !has('float') |
aad2c2ca0774
patch 8.0.0644: the timeout for 'hlsearch' is not tested
Christian Brabandt <cb@256bit.org>
parents:
10145
diff
changeset
|
38 return |
aad2c2ca0774
patch 8.0.0644: the timeout for 'hlsearch' is not tested
Christian Brabandt <cb@256bit.org>
parents:
10145
diff
changeset
|
39 endif |
aad2c2ca0774
patch 8.0.0644: the timeout for 'hlsearch' is not tested
Christian Brabandt <cb@256bit.org>
parents:
10145
diff
changeset
|
40 |
11525
14b6b79d685b
patch 8.0.0645: no error for illegal back reference in NFA engine
Christian Brabandt <cb@256bit.org>
parents:
11523
diff
changeset
|
41 " This pattern takes a long time to match, it should timeout. |
11527
ac20f71e8aa4
patch 8.0.0646: the hlsearch test fails on fast systems
Christian Brabandt <cb@256bit.org>
parents:
11525
diff
changeset
|
42 new |
ac20f71e8aa4
patch 8.0.0646: the hlsearch test fails on fast systems
Christian Brabandt <cb@256bit.org>
parents:
11525
diff
changeset
|
43 call setline(1, ['aaa', repeat('abc ', 1000), 'ccc']) |
11523
aad2c2ca0774
patch 8.0.0644: the timeout for 'hlsearch' is not tested
Christian Brabandt <cb@256bit.org>
parents:
10145
diff
changeset
|
44 let start = reltime() |
aad2c2ca0774
patch 8.0.0644: the timeout for 'hlsearch' is not tested
Christian Brabandt <cb@256bit.org>
parents:
10145
diff
changeset
|
45 set hlsearch nolazyredraw redrawtime=101 |
11525
14b6b79d685b
patch 8.0.0645: no error for illegal back reference in NFA engine
Christian Brabandt <cb@256bit.org>
parents:
11523
diff
changeset
|
46 let @/ = '\%#=1a*.*X\@<=b*' |
11523
aad2c2ca0774
patch 8.0.0644: the timeout for 'hlsearch' is not tested
Christian Brabandt <cb@256bit.org>
parents:
10145
diff
changeset
|
47 redraw |
aad2c2ca0774
patch 8.0.0644: the timeout for 'hlsearch' is not tested
Christian Brabandt <cb@256bit.org>
parents:
10145
diff
changeset
|
48 let elapsed = reltimefloat(reltime(start)) |
aad2c2ca0774
patch 8.0.0644: the timeout for 'hlsearch' is not tested
Christian Brabandt <cb@256bit.org>
parents:
10145
diff
changeset
|
49 call assert_true(elapsed > 0.1) |
aad2c2ca0774
patch 8.0.0644: the timeout for 'hlsearch' is not tested
Christian Brabandt <cb@256bit.org>
parents:
10145
diff
changeset
|
50 call assert_true(elapsed < 1.0) |
aad2c2ca0774
patch 8.0.0644: the timeout for 'hlsearch' is not tested
Christian Brabandt <cb@256bit.org>
parents:
10145
diff
changeset
|
51 set nohlsearch redrawtime& |
11527
ac20f71e8aa4
patch 8.0.0646: the hlsearch test fails on fast systems
Christian Brabandt <cb@256bit.org>
parents:
11525
diff
changeset
|
52 bwipe! |
11523
aad2c2ca0774
patch 8.0.0644: the timeout for 'hlsearch' is not tested
Christian Brabandt <cb@256bit.org>
parents:
10145
diff
changeset
|
53 endfunc |