neovim/test/functional/legacy/101_hlsearch_spec.lua

68 lines
1.8 KiB
Lua
Raw Normal View History

2014-11-10 06:47:57 -07:00
-- Test for v:hlsearch
local helpers = require('test.functional.helpers')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect = helpers.execute, helpers.expect
local eval = helpers.eval
2014-11-10 06:47:57 -07:00
describe('v:hlsearch', function()
setup(clear)
it('is working', function()
-- Last abc: Q
execute('new')
execute([[call setline(1, repeat(['aaa'], 10))]])
execute('set hlsearch nolazyredraw')
execute('let r=[]')
execute('command -nargs=0 -bar AddR :call add(r, [screenattr(1, 1), v:hlsearch])')
execute('/aaa')
execute('AddR')
execute('nohlsearch')
execute('AddR')
execute('let v:hlsearch=1')
execute('AddR')
execute('let v:hlsearch=0')
execute('AddR')
execute('set hlsearch')
execute('AddR')
execute('let v:hlsearch=0')
execute('AddR')
feed('n:AddR<cr>')
execute('let v:hlsearch=0')
execute('AddR')
execute('/')
execute('AddR')
execute('set nohls')
execute('/')
execute('AddR')
2014-11-10 06:47:57 -07:00
execute('let r1=r[0][0]')
-- I guess it is not guaranteed that screenattr outputs always the same character
execute([[call map(r, 'v:val[1].":".(v:val[0]==r1?"highlighted":"not highlighted")')]])
execute('try')
execute(' let v:hlsearch=[]')
execute('catch')
execute([[ call add(r, matchstr(v:exception,'^Vim(let):E\d\+:'))]])
execute('endtry')
execute('bwipeout!')
execute('$put=r')
execute('call garbagecollect(1)')
execute('call getchar()')
execute('1d', '1d')
2014-11-10 06:47:57 -07:00
-- Assert buffer contents.
expect([[
1:highlighted
0:not highlighted
1:highlighted
0:not highlighted
1:highlighted
0:not highlighted
1:highlighted
0:not highlighted
1:highlighted
0:not highlighted
2014-11-10 06:47:57 -07:00
Vim(let):E706:]])
end)
end)