neovim/test/functional/legacy/textobjects_spec.lua
ZyX 65fb622000 functests: Replace execute with either command or feed_command
Hope this will make people using feed_command less likely: this hides bugs.
Already found at least two:

1. msgpackparse() will show internal error: hash_add() in case of duplicate
   keys, though it will still work correctly. Currently silenced.
2. ttimeoutlen was spelled incorrectly, resulting in option not being set when
   expected. Test was still functioning somehow though. Currently fixed.
2017-04-09 03:24:08 +03:00

62 lines
1.3 KiB
Lua

local helpers = require('test.functional.helpers')(after_each)
local call = helpers.call
local clear = helpers.clear
local command = helpers.command
local expect = helpers.expect
local source = helpers.source
describe('Text object', function()
before_each(function()
clear()
command('set shada=')
source([[
function SelectionOut(data)
new
call setline(1, a:data)
call setreg('"', '')
normal! ggfrmavi)y
$put =getreg('\"')
call setreg('"', '')
normal! `afbmavi)y
$put =getreg('\"')
call setreg('"', '')
normal! `afgmavi)y
$put =getreg('\"')
endfunction
]])
end)
it('Test for vi) without cpo-M', function()
command('set cpo-=M')
call('SelectionOut', '(red \\(blue) green)')
expect([[
(red \(blue) green)
red \(blue
red \(blue
]])
end)
it('Test for vi) with cpo-M #1', function()
command('set cpo+=M')
call('SelectionOut', '(red \\(blue) green)')
expect([[
(red \(blue) green)
red \(blue) green
blue
red \(blue) green]])
end)
it('Test for vi) with cpo-M #2', function()
command('set cpo+=M')
call('SelectionOut', '(red (blue\\) green)')
expect([[
(red (blue\) green)
red (blue\) green
blue\
red (blue\) green]])
end)
end)