functests: Refactor legacy/003_cindent_spec and legacy/increment_spec

This commit is contained in:
ZyX
2017-04-08 22:17:39 +03:00
parent 7766b24f3c
commit cca029bc8d
2 changed files with 570 additions and 570 deletions

View File

@@ -5,14 +5,14 @@
local helpers = require('test.functional.helpers')(after_each) local helpers = require('test.functional.helpers')(after_each)
local feed, insert = helpers.feed, helpers.insert local feed, insert = helpers.feed, helpers.insert
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect
-- Inserts text as usual, and additionally positions the cursor on line 1 and -- Inserts text as usual, and additionally positions the cursor on line 1 and
-- sets 'cindent' and tab settings. (In the original "test3.in" the modeline at -- sets 'cindent' and tab settings. (In the original "test3.in" the modeline at
-- the top of the file takes care of this.) -- the top of the file takes care of this.)
local function insert_(content) local function insert_(content)
insert(content) insert(content)
execute('1', 'set cin ts=4 sw=4') feed_command('1', 'set cin ts=4 sw=4')
end end
describe('cindent', function() describe('cindent', function()
@@ -978,7 +978,7 @@ describe('cindent', function()
/* end of AUTO */ /* end of AUTO */
]=]) ]=])
execute('/start of AUTO') feed_command('/start of AUTO')
feed('=/end of AUTO<cr>') feed('=/end of AUTO<cr>')
expect([=[ expect([=[
@@ -1954,8 +1954,8 @@ describe('cindent', function()
} }
]=]) ]=])
execute('set tw=0 wm=60 columns=80 noai fo=croq') feed_command('set tw=0 wm=60 columns=80 noai fo=croq')
execute('/serious/e') feed_command('/serious/e')
feed('a about life, the universe, and the rest<esc>') feed('a about life, the universe, and the rest<esc>')
expect([=[ expect([=[
@@ -1994,8 +1994,8 @@ describe('cindent', function()
} }
]=]) ]=])
execute('set nocin') feed_command('set nocin')
execute('/comments') feed_command('/comments')
feed('joabout life<esc>/happens<cr>') feed('joabout life<esc>/happens<cr>')
feed('jothere<esc>/below<cr>') feed('jothere<esc>/below<cr>')
feed('oline<esc>/this<cr>') feed('oline<esc>/this<cr>')
@@ -2034,8 +2034,8 @@ describe('cindent', function()
+ vec2[2] * vec[2]; + vec2[2] * vec[2];
} }
]=]) ]=])
execute('set cin') feed_command('set cin')
execute('/vec2') feed_command('/vec2')
feed('==<cr>') feed('==<cr>')
expect([=[ expect([=[
@@ -2067,9 +2067,9 @@ describe('cindent', function()
} }
]=]) ]=])
execute('set cin') feed_command('set cin')
execute('set cino=}4') feed_command('set cino=}4')
execute('/testing1') feed_command('/testing1')
feed('k2==/testing2<cr>') feed('k2==/testing2<cr>')
feed('k2==<cr>') feed('k2==<cr>')
@@ -2118,9 +2118,9 @@ describe('cindent', function()
} }
]=]) ]=])
execute('set cin') feed_command('set cin')
execute('set cino=(0,)20') feed_command('set cino=(0,)20')
execute('/main') feed_command('/main')
feed('=][<cr>') feed('=][<cr>')
expect([=[ expect([=[
@@ -2164,9 +2164,9 @@ describe('cindent', function()
} }
]=]) ]=])
execute('set cin') feed_command('set cin')
execute('set cino=es,n0s') feed_command('set cino=es,n0s')
execute('/main') feed_command('/main')
feed('=][<cr>') feed('=][<cr>')
expect([=[ expect([=[
@@ -2202,8 +2202,8 @@ describe('cindent', function()
} }
]=]) ]=])
execute('set cin') feed_command('set cin')
execute('set cino=') feed_command('set cino=')
feed(']]=][<cr>') feed(']]=][<cr>')
expect([=[ expect([=[
@@ -2280,7 +2280,7 @@ describe('cindent', function()
} }
]=]) ]=])
execute('set cino={s,e-s') feed_command('set cino={s,e-s')
feed(']]=][<cr>') feed(']]=][<cr>')
expect([=[ expect([=[
@@ -2336,7 +2336,7 @@ describe('cindent', function()
/* foo */ /* foo */
]=]) ]=])
execute('set cino={s,fs') feed_command('set cino={s,fs')
feed(']]=/ foo<cr>') feed(']]=/ foo<cr>')
expect([=[ expect([=[
@@ -2390,8 +2390,8 @@ describe('cindent', function()
} }
]=]) ]=])
execute('set cino=') feed_command('set cino=')
execute('/while') feed_command('/while')
feed('ohere<esc>') feed('ohere<esc>')
expect([=[ expect([=[
@@ -2420,8 +2420,8 @@ describe('cindent', function()
} }
]=]) ]=])
execute('set cino= com=') feed_command('set cino= com=')
execute('/comment') feed_command('/comment')
feed('olabel2: b();<cr>label3 /* post */:<cr>/* pre */ label4:<cr>f(/*com*/);<cr>if (/*com*/)<cr>cmd();<esc>') feed('olabel2: b();<cr>label3 /* post */:<cr>/* pre */ label4:<cr>f(/*com*/);<cr>if (/*com*/)<cr>cmd();<esc>')
expect([=[ expect([=[
@@ -2453,8 +2453,8 @@ describe('cindent', function()
*/ */
]=]) ]=])
execute('set comments& comments^=s:/*,m:**,ex:*/') feed_command('set comments& comments^=s:/*,m:**,ex:*/')
execute('/simple') feed_command('/simple')
feed('=5j<cr>') feed('=5j<cr>')
expect([=[ expect([=[
@@ -2482,8 +2482,8 @@ describe('cindent', function()
} }
]=]) ]=])
execute('set cino=c0') feed_command('set cino=c0')
execute('set comments& comments-=s1:/* comments^=s0:/*') feed_command('set comments& comments-=s1:/* comments^=s0:/*')
feed('2kdd]]=][<cr>') feed('2kdd]]=][<cr>')
expect([=[ expect([=[
@@ -2511,8 +2511,8 @@ describe('cindent', function()
} }
]=]) ]=])
execute('set cino=c0,C1') feed_command('set cino=c0,C1')
execute('set comments& comments-=s1:/* comments^=s0:/*') feed_command('set comments& comments-=s1:/* comments^=s0:/*')
feed('2kdd]]=][<cr>') feed('2kdd]]=][<cr>')
expect([=[ expect([=[
@@ -2540,7 +2540,7 @@ describe('cindent', function()
} }
]=]) ]=])
execute('set cino=') feed_command('set cino=')
feed(']]=][<cr>') feed(']]=][<cr>')
expect([=[ expect([=[
@@ -2570,7 +2570,7 @@ describe('cindent', function()
} }
]=]) ]=])
execute('set cino=(s') feed_command('set cino=(s')
feed('2kdd]]=][<cr>') feed('2kdd]]=][<cr>')
expect([=[ expect([=[
@@ -2600,7 +2600,7 @@ describe('cindent', function()
} }
]=]) ]=])
execute('set cino=(s,U1 ') feed_command('set cino=(s,U1 ')
feed('2kdd]]=][<cr>') feed('2kdd]]=][<cr>')
expect([=[ expect([=[
@@ -2629,7 +2629,7 @@ describe('cindent', function()
} }
]=]) ]=])
execute('set cino=(0') feed_command('set cino=(0')
feed('2kdd]]=][<cr>') feed('2kdd]]=][<cr>')
expect([=[ expect([=[
@@ -2657,7 +2657,7 @@ describe('cindent', function()
} }
]=]) ]=])
execute('set cino=(0,w1 ') feed_command('set cino=(0,w1 ')
feed('2kdd]]=][<cr>') feed('2kdd]]=][<cr>')
expect([=[ expect([=[
@@ -2689,7 +2689,7 @@ describe('cindent', function()
} }
]=]) ]=])
execute('set cino=(s') feed_command('set cino=(s')
feed('2kdd]]=][<cr>') feed('2kdd]]=][<cr>')
expect([=[ expect([=[
@@ -2725,7 +2725,7 @@ describe('cindent', function()
} }
]=]) ]=])
execute('set cino=(s,m1 ') feed_command('set cino=(s,m1 ')
feed('2kdd]]=][<cr>') feed('2kdd]]=][<cr>')
expect([=[ expect([=[
@@ -2762,7 +2762,7 @@ describe('cindent', function()
} }
]=]) ]=])
execute('set cino=b1') feed_command('set cino=b1')
feed('2kdd]]=][<cr>') feed('2kdd]]=][<cr>')
expect([=[ expect([=[
@@ -2801,7 +2801,7 @@ describe('cindent', function()
} }
]=]) ]=])
execute('set cino=(0,W5') feed_command('set cino=(0,W5')
feed('2kdd]]=][<cr>') feed('2kdd]]=][<cr>')
expect([=[ expect([=[
@@ -2834,7 +2834,7 @@ describe('cindent', function()
} }
]=]) ]=])
execute('set cino=/6') feed_command('set cino=/6')
feed('2kdd]]=][<cr>') feed('2kdd]]=][<cr>')
expect([=[ expect([=[
@@ -2860,7 +2860,7 @@ describe('cindent', function()
} }
]=]) ]=])
execute('set cino=') feed_command('set cino=')
feed('2kdd]]/comment 1/+1<cr>') feed('2kdd]]/comment 1/+1<cr>')
feed('==<cr>') feed('==<cr>')
@@ -2890,7 +2890,7 @@ describe('cindent', function()
}; };
]=]) ]=])
execute('set cino=g0') feed_command('set cino=g0')
feed('2kdd]]=][<cr>') feed('2kdd]]=][<cr>')
expect([=[ expect([=[
@@ -2921,7 +2921,7 @@ describe('cindent', function()
}; };
]=]) ]=])
execute('set cino=(0,gs,hs') feed_command('set cino=(0,gs,hs')
feed('2kdd]]=][<cr>') feed('2kdd]]=][<cr>')
expect([=[ expect([=[
@@ -2951,7 +2951,7 @@ describe('cindent', function()
} }
]=]) ]=])
execute('set cino=+20') feed_command('set cino=+20')
feed('2kdd]]=][<cr>') feed('2kdd]]=][<cr>')
expect([=[ expect([=[
@@ -3009,7 +3009,7 @@ describe('cindent', function()
} }
]=]) ]=])
execute('set cino=(0,W2s') feed_command('set cino=(0,W2s')
feed('2kdd]]=][<cr>') feed('2kdd]]=][<cr>')
expect([=[ expect([=[
@@ -3066,7 +3066,7 @@ describe('cindent', function()
} }
]=]) ]=])
execute('set cino=M1') feed_command('set cino=M1')
feed('2kdd]]=][<cr>') feed('2kdd]]=][<cr>')
expect([=[ expect([=[
@@ -3095,7 +3095,7 @@ describe('cindent', function()
} }
]=]) ]=])
execute('set cino=(0,ts') feed_command('set cino=(0,ts')
feed('2kdd2j=][<cr>') feed('2kdd2j=][<cr>')
expect([=[ expect([=[
@@ -3127,7 +3127,7 @@ describe('cindent', function()
} }
]=]) ]=])
execute('set cino=(0') feed_command('set cino=(0')
feed('2kdd2j=][<cr>') feed('2kdd2j=][<cr>')
expect([=[ expect([=[
@@ -3221,7 +3221,7 @@ describe('cindent', function()
} }
]=]) ]=])
execute('set cino&') feed_command('set cino&')
feed('2kdd2j=7][<cr>') feed('2kdd2j=7][<cr>')
expect([=[ expect([=[
@@ -3328,8 +3328,8 @@ describe('cindent', function()
} }
]=]) ]=])
execute('set cino&') feed_command('set cino&')
execute('set cino+=l1') feed_command('set cino+=l1')
feed('2kdd2j=][<cr>') feed('2kdd2j=][<cr>')
expect([=[ expect([=[
@@ -3373,7 +3373,7 @@ describe('cindent', function()
} }
]=]) ]=])
execute('set cino&') feed_command('set cino&')
feed('2kdd2j=][<cr>') feed('2kdd2j=][<cr>')
expect([=[ expect([=[
@@ -3399,7 +3399,7 @@ describe('cindent', function()
} }
]=]) ]=])
execute('set com=s1:/*,m:*,ex:*/') feed_command('set com=s1:/*,m:*,ex:*/')
feed(']]3jofoo();<esc>') feed(']]3jofoo();<esc>')
expect([=[ expect([=[
@@ -3429,7 +3429,7 @@ describe('cindent', function()
} }
]=]) ]=])
execute('set cino&') feed_command('set cino&')
feed('2kdd2j=][<cr>') feed('2kdd2j=][<cr>')
expect([=[ expect([=[
@@ -3477,7 +3477,7 @@ describe('cindent', function()
} }
]=]) ]=])
execute('set cino=k2s,(0') feed_command('set cino=k2s,(0')
feed('2kdd3j=][<cr>') feed('2kdd3j=][<cr>')
expect([=[ expect([=[
@@ -3541,7 +3541,7 @@ describe('cindent', function()
} }
]=]) ]=])
execute('set cino=k2s,(s') feed_command('set cino=k2s,(s')
feed('2kdd3j=][<cr>') feed('2kdd3j=][<cr>')
expect([=[ expect([=[
@@ -3606,7 +3606,7 @@ describe('cindent', function()
} }
]=]) ]=])
execute('set cino=k2s,(s,U1') feed_command('set cino=k2s,(s,U1')
feed('2kdd3j=][<cr>') feed('2kdd3j=][<cr>')
expect([=[ expect([=[
@@ -3677,7 +3677,7 @@ describe('cindent', function()
} }
]=]) ]=])
execute('set cino=k2s,(0,W4') feed_command('set cino=k2s,(0,W4')
feed('2kdd3j=][<cr>') feed('2kdd3j=][<cr>')
expect([=[ expect([=[
@@ -3742,7 +3742,7 @@ describe('cindent', function()
} }
]=]) ]=])
execute('set cino=k2s,u2') feed_command('set cino=k2s,u2')
feed('2kdd3j=][<cr>') feed('2kdd3j=][<cr>')
expect([=[ expect([=[
@@ -3805,7 +3805,7 @@ describe('cindent', function()
} }
]=]) ]=])
execute('set cino=k2s,(0,w1') feed_command('set cino=k2s,(0,w1')
feed('2kdd3j=][<cr>') feed('2kdd3j=][<cr>')
expect([=[ expect([=[
@@ -3864,7 +3864,7 @@ describe('cindent', function()
} }
]=]) ]=])
execute('set cino=k2,(s') feed_command('set cino=k2,(s')
feed('2kdd3j=][<cr>') feed('2kdd3j=][<cr>')
expect([=[ expect([=[
@@ -3956,8 +3956,8 @@ describe('cindent', function()
NAMESPACEEND NAMESPACEEND
]=]) ]=])
execute('set cino=N-s') feed_command('set cino=N-s')
execute('/^NAMESPACESTART') feed_command('/^NAMESPACESTART')
feed('=/^NAMESPACEEND<cr>') feed('=/^NAMESPACEEND<cr>')
expect([=[ expect([=[
@@ -4047,8 +4047,8 @@ describe('cindent', function()
JSEND JSEND
]=]) ]=])
execute('set cino=j1,J1') feed_command('set cino=j1,J1')
execute('/^JSSTART') feed_command('/^JSSTART')
feed('=/^JSEND<cr>') feed('=/^JSEND<cr>')
expect([=[ expect([=[
@@ -4082,8 +4082,8 @@ describe('cindent', function()
JSEND JSEND
]=]) ]=])
execute('set cino=j1,J1') feed_command('set cino=j1,J1')
execute('/^JSSTART') feed_command('/^JSSTART')
feed('=/^JSEND<cr>') feed('=/^JSEND<cr>')
expect([=[ expect([=[
@@ -4112,8 +4112,8 @@ describe('cindent', function()
JSEND JSEND
]=]) ]=])
execute('set cino=j1,J1') feed_command('set cino=j1,J1')
execute('/^JSSTART') feed_command('/^JSSTART')
feed('=/^JSEND<cr>') feed('=/^JSEND<cr>')
expect([=[ expect([=[
@@ -4195,8 +4195,8 @@ describe('cindent', function()
JSEND JSEND
]=]) ]=])
execute('set cino=j1,J1') feed_command('set cino=j1,J1')
execute('/^JSSTART') feed_command('/^JSSTART')
feed('=/^JSEND<cr>') feed('=/^JSEND<cr>')
expect([=[ expect([=[
@@ -4285,8 +4285,8 @@ describe('cindent', function()
JSEND JSEND
]=]) ]=])
execute('set cino=j1,J1') feed_command('set cino=j1,J1')
execute('/^JSSTART') feed_command('/^JSSTART')
feed('=/^JSEND<cr>') feed('=/^JSEND<cr>')
expect([=[ expect([=[
@@ -4333,8 +4333,8 @@ describe('cindent', function()
JSEND JSEND
]=]) ]=])
execute('set cino=j1,J1') feed_command('set cino=j1,J1')
execute('/^JSSTART') feed_command('/^JSSTART')
feed('=/^JSEND<cr>') feed('=/^JSEND<cr>')
expect([=[ expect([=[
@@ -4517,8 +4517,8 @@ describe('cindent', function()
]=]) ]=])
-- :set cino=j1,J1,+2 -- :set cino=j1,J1,+2
execute('set cino=j1,J1,+2') feed_command('set cino=j1,J1,+2')
execute('/^JSSTART') feed_command('/^JSSTART')
feed('=/^JSEND<cr>') feed('=/^JSEND<cr>')
expect([=[ expect([=[

View File

@@ -1,7 +1,7 @@
-- Tests for using Ctrl-A/Ctrl-X on visual selections -- Tests for using Ctrl-A/Ctrl-X on visual selections
local helpers = require('test.functional.helpers')(after_each) local helpers = require('test.functional.helpers')(after_each)
local source, execute = helpers.source, helpers.execute local source, command = helpers.source, helpers.command
local call, clear = helpers.call, helpers.clear local call, clear = helpers.call, helpers.clear
local eq, nvim = helpers.eq, helpers.meths local eq, nvim = helpers.eq, helpers.meths
@@ -742,14 +742,14 @@ describe('Ctrl-A/Ctrl-X on visual selections', function()
local id = string.format('%02d', i) local id = string.format('%02d', i)
it('works on Test ' .. id, function() it('works on Test ' .. id, function()
execute('set nrformats&vi') -- &vi makes Vim compatible command('set nrformats&vi') -- &vi makes Vim compatible
call('Test_visual_increment_' .. id) call('Test_visual_increment_' .. id)
eq({}, nvim.get_vvar('errors')) eq({}, nvim.get_vvar('errors'))
end) end)
end end
it('does not drop leading zeroes', function() it('does not drop leading zeroes', function()
execute('set nrformats&vi') -- &vi makes Vim compatible command('set nrformats&vi') -- &vi makes Vim compatible
call('Test_normal_increment_01') call('Test_normal_increment_01')
eq({}, nvim.get_vvar('errors')) eq({}, nvim.get_vvar('errors'))
end) end)