tests: Split test 61 into several it() blocks.

This commit is contained in:
Lucas Hoffmann
2015-06-22 11:15:50 +02:00
parent 2ce3656754
commit 1c7372361f

View File

@@ -20,21 +20,25 @@ local function write_file(name, text)
file:close()
end
describe('the undo tree', function()
setup(function()
clear()
write_file('Xtest.source', 'o1\x1ba2\x12=string(123)\n\x1b')
write_file('Xtest0', '\n123456789\n')
end)
describe('undo:', function()
before_each(clear)
teardown(function()
os.remove('Xtest0')
os.remove('Xtest')
os.remove('Xtest.source')
end)
it('is working', function()
execute('e Xtest0')
describe(':earlier and :later', function()
before_each(function()
os.remove('Xtest')
end)
teardown(function()
os.remove('Xtest')
end)
it('work with time specifications and g- and g+', function()
-- We write the test text to a file in order to prevent nvim to record
-- the inserting of the text into the undo history.
write_file('Xtest', '\n123456789\n')
execute('e Xtest')
-- Assert that no undo history is present.
eq({}, eval('undotree().entries'))
-- Delete three characters and undo.
@@ -88,59 +92,11 @@ describe('the undo tree', function()
expect_line('123456')
execute('later 1h')
expect_line('123456abc')
end)
-- Test that setting 'ul' breaks change blocks, we need to use source() in
-- order to test this, as interactive changes are not grouped.
execute('new')
-- First verify that scripts produce single big undo blocks.
source([[
normal Aaaaa
normal obbbb
normal occcc
]])
expect([[
aaaa
bbbb
cccc]])
feed('u')
expect_empty_buffer()
-- Verify that undo blocks can be broken inside scripts by setting 'ul'.
source([[
normal Aaaaa
set ul=100
normal obbbb
set ul=100
normal occcc
]])
expect([[
aaaa
bbbb
cccc]])
feed('u')
expect([[
aaaa
bbbb]])
feed('u')
expect('aaaa')
feed('u')
expect_empty_buffer()
-- Test undojoin.
feed('Goaaaa<esc>')
feed('obbbb<esc>u')
expect_line('aaaa')
source([[
normal obbbb
set ul=100
undojoin
normal occcc
]])
feed('u')
expect_line('aaaa')
execute('e! Xtest')
it('work with file write specifications', function()
feed('ione one one<esc>')
execute('w!')
execute('w Xtest')
feed('otwo<esc>')
feed('otwo<esc>')
execute('w')
@@ -167,8 +123,65 @@ describe('the undo tree', function()
two
two
three]])
end)
end)
it('scripts produce one undo block for all changes by default', function()
source([[
normal Aaaaa
normal obbbb
normal occcc
]])
expect([[
aaaa
bbbb
cccc]])
feed('u')
expect_empty_buffer()
end)
it('setting undolevel can break change blocks (inside scripts)', function()
-- We need to use source() in order to test this, as interactive changes
-- are not grouped.
source([[
normal Aaaaa
set ul=100
normal obbbb
set ul=100
normal occcc
]])
expect([[
aaaa
bbbb
cccc]])
feed('u')
expect([[
aaaa
bbbb]])
feed('u')
expect('aaaa')
feed('u')
expect_empty_buffer()
end)
it(':undojoin can join change blocks inside scripts', function()
feed('Goaaaa<esc>')
feed('obbbb<esc>u')
expect_line('aaaa')
source([[
normal obbbb
set ul=100
undojoin
normal occcc
]])
feed('u')
expect_line('aaaa')
end)
it('undoing pastes from the expression register is working', function()
local normal_commands = 'o1\x1ba2\x12=string(123)\n\x1b'
write_file('Xtest.source', normal_commands)
execute('enew!')
feed('oa<esc>')
feed('ob<esc>')
feed([[o1<esc>a2<C-R>=setline('.','1234')<cr><esc>]])
@@ -177,7 +190,6 @@ describe('the undo tree', function()
a
b
12034]])
feed('uu')
expect([[
@@ -202,9 +214,6 @@ describe('the undo tree', function()
c
12]])
feed('od<esc>')
-- The file Xtest.source is written during setup. It contains this text
-- (nvim like escape sequences interpreted):
-- o1<esc>a2<C-R>=string(123)<cr><esc>
execute('so! Xtest.source')
expect([[
@@ -227,7 +236,7 @@ describe('the undo tree', function()
-- The above behaviour was tested in the legacy vim test because the
-- legacy tests were executed with ':so!'. The behavior differs for
-- interactive use (even in vim, where the result was the same):
feed(io.open('Xtest.source'):read('*all'))
feed(normal_commands)
expect([[
a