2014-11-09 13:31:22 -07:00
|
|
|
-- Tests for regexp with various magic settings.
|
|
|
|
|
2024-04-20 08:44:13 -07:00
|
|
|
local n = require('test.functional.testnvim')()
|
|
|
|
|
|
|
|
local clear, feed, insert = n.clear, n.feed, n.insert
|
|
|
|
local feed_command, expect = n.feed_command, n.expect
|
2014-11-09 13:31:22 -07:00
|
|
|
|
|
|
|
describe('regexp with magic settings', function()
|
|
|
|
setup(clear)
|
|
|
|
|
|
|
|
it('is working', function()
|
|
|
|
insert([[
|
|
|
|
1 a aa abb abbccc
|
|
|
|
2 d dd dee deefff
|
|
|
|
3 g gg ghh ghhiii
|
|
|
|
4 j jj jkk jkklll
|
|
|
|
5 m mm mnn mnnooo
|
|
|
|
6 x ^aa$ x
|
|
|
|
7 (a)(b) abbaa
|
|
|
|
8 axx [ab]xx
|
|
|
|
9 foobar
|
|
|
|
]])
|
|
|
|
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('/^1')
|
|
|
|
feed_command([[/a*b\{2}c\+/e]])
|
2014-11-09 13:31:22 -07:00
|
|
|
feed([[x/\Md\*e\{2}f\+/e<cr>]])
|
|
|
|
feed('x:set nomagic<cr>')
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command([[/g\*h\{2}i\+/e]])
|
2014-11-09 13:31:22 -07:00
|
|
|
feed([[x/\mj*k\{2}l\+/e<cr>]])
|
|
|
|
feed([[x/\vm*n{2}o+/e<cr>]])
|
|
|
|
feed([[x/\V^aa$<cr>]])
|
|
|
|
feed('x:set magic<cr>')
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command([[/\v(a)(b)\2\1\1/e]])
|
2014-11-09 13:31:22 -07:00
|
|
|
feed([[x/\V[ab]\(\[xy]\)\1<cr>]])
|
|
|
|
feed('x:$<cr>')
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('set undolevels=100')
|
2014-11-09 13:31:22 -07:00
|
|
|
feed('dv?bar?<cr>')
|
|
|
|
feed('Yup:<cr>')
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('?^1?,$yank A')
|
2014-11-09 13:31:22 -07:00
|
|
|
|
|
|
|
-- Put @a and clean empty line
|
2017-04-08 14:12:26 -07:00
|
|
|
feed_command('%d')
|
|
|
|
feed_command('0put a')
|
|
|
|
feed_command('$d')
|
2014-11-09 13:31:22 -07:00
|
|
|
|
|
|
|
-- Assert buffer contents.
|
|
|
|
expect([[
|
|
|
|
1 a aa abb abbcc
|
|
|
|
2 d dd dee deeff
|
|
|
|
3 g gg ghh ghhii
|
|
|
|
4 j jj jkk jkkll
|
|
|
|
5 m mm mnn mnnoo
|
|
|
|
6 x aa$ x
|
|
|
|
7 (a)(b) abba
|
|
|
|
8 axx ab]xx
|
|
|
|
9 foobar
|
|
|
|
9 foo
|
|
|
|
]])
|
|
|
|
end)
|
|
|
|
end)
|