diff options
Diffstat (limited to 'test/functional/legacy/061_undo_tree_spec.lua')
-rw-r--r-- | test/functional/legacy/061_undo_tree_spec.lua | 56 |
1 files changed, 24 insertions, 32 deletions
diff --git a/test/functional/legacy/061_undo_tree_spec.lua b/test/functional/legacy/061_undo_tree_spec.lua index 9bf69ccba1..1a8ef067d0 100644 --- a/test/functional/legacy/061_undo_tree_spec.lua +++ b/test/functional/legacy/061_undo_tree_spec.lua @@ -1,8 +1,8 @@ -- Tests for undo tree and :earlier and :later. local helpers = require('test.functional.helpers')(after_each) +local feed_command = helpers.feed_command local write_file = helpers.write_file -local execute = helpers.execute local command = helpers.command local source = helpers.source local expect = helpers.expect @@ -44,7 +44,7 @@ describe('undo tree:', function() -- function to allow multiple attempts. local function test_earlier_later() clear() - execute('e Xtest') + feed_command('e Xtest') -- Assert that no undo history is present. eq({}, eval('undotree().entries')) -- Delete three characters and undo. @@ -88,51 +88,43 @@ describe('undo tree:', function() feed('Ab<esc>') feed('Ac<esc>') expect_line('123456abc') - execute('earlier 1s') + feed_command('earlier 1s') expect_line('123456') - execute('earlier 3s') + feed_command('earlier 3s') expect_line('123456789') - execute('later 1s') + feed_command('later 1s') expect_line('123456') - execute('later 1h') + feed_command('later 1h') expect_line('123456abc') end - -- Retry up to 3 times. pcall() is _not_ used for the final attempt, so - -- that failure messages can bubble up. - for _ = 1, 2 do - local success = pcall(test_earlier_later) - if success then - return - end - end - test_earlier_later() + helpers.retry(2, nil, test_earlier_later) end) it('file-write specifications', function() feed('ione one one<esc>') - execute('w Xtest') + feed_command('w Xtest') feed('otwo<esc>') feed('otwo<esc>') - execute('w') + feed_command('w') feed('othree<esc>') - execute('earlier 1f') + feed_command('earlier 1f') expect([[ one one one two two]]) - execute('earlier 1f') + feed_command('earlier 1f') expect('one one one') - execute('earlier 1f') + feed_command('earlier 1f') expect_empty_buffer() - execute('later 1f') + feed_command('later 1f') expect('one one one') - execute('later 1f') + feed_command('later 1f') expect([[ one one one two two]]) - execute('later 1f') + feed_command('later 1f') expect([[ one one one two @@ -201,20 +193,20 @@ describe('undo tree:', function() feed('ob<esc>') feed([[o1<esc>a2<C-R>=setline('.','1234')<cr><esc>]]) expect([[ - + a b 12034]]) feed('uu') expect([[ - + a b 1]]) feed('oc<esc>') feed([[o1<esc>a2<C-R>=setline('.','1234')<cr><esc>]]) expect([[ - + a b 1 @@ -222,16 +214,16 @@ describe('undo tree:', function() 12034]]) feed('u') expect([[ - + a b 1 c 12]]) feed('od<esc>') - execute('so! Xtest.source') + feed_command('so! Xtest.source') expect([[ - + a b 1 @@ -241,7 +233,7 @@ describe('undo tree:', function() 12123]]) feed('u') expect([[ - + a b 1 @@ -254,7 +246,7 @@ describe('undo tree:', function() -- interactive use (even in Vim; see ":help :undojoin"): feed(normal_commands) expect([[ - + a b 1 @@ -264,7 +256,7 @@ describe('undo tree:', function() 12123]]) feed('u') expect([[ - + a b 1 |