2015-10-13 13:57:53 +02:00
|
|
|
|
-- Tests for 'fixeol'
|
|
|
|
|
|
|
2016-04-24 02:53:11 +03:00
|
|
|
|
local helpers = require('test.functional.helpers')(after_each)
|
2015-12-20 22:41:40 +01:00
|
|
|
|
local feed = helpers.feed
|
2017-04-09 00:12:26 +03:00
|
|
|
|
local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect
|
2015-10-13 13:57:53 +02:00
|
|
|
|
|
|
|
|
|
|
describe('fixeol', function()
|
2015-12-13 00:21:11 -05:00
|
|
|
|
local function rmtestfiles()
|
2017-11-01 17:40:59 -04:00
|
|
|
|
feed_command('%bwipeout!')
|
|
|
|
|
|
feed_command('call delete("test.out")')
|
|
|
|
|
|
feed_command('call delete("XXEol")')
|
|
|
|
|
|
feed_command('call delete("XXNoEol")')
|
|
|
|
|
|
feed_command('call delete("XXTestEol")')
|
|
|
|
|
|
feed_command('call delete("XXTestNoEol")')
|
2015-12-13 00:21:11 -05:00
|
|
|
|
end
|
|
|
|
|
|
setup(function()
|
|
|
|
|
|
clear()
|
|
|
|
|
|
rmtestfiles()
|
|
|
|
|
|
end)
|
|
|
|
|
|
teardown(function()
|
|
|
|
|
|
rmtestfiles()
|
|
|
|
|
|
end)
|
2015-10-13 13:57:53 +02:00
|
|
|
|
|
|
|
|
|
|
it('is working', function()
|
|
|
|
|
|
-- First write two test files – with and without trailing EOL.
|
|
|
|
|
|
-- Use Unix fileformat for consistency.
|
2017-04-09 00:12:26 +03:00
|
|
|
|
feed_command('set ff=unix')
|
|
|
|
|
|
feed_command('enew!')
|
2015-10-13 13:57:53 +02:00
|
|
|
|
feed('awith eol<esc>:w! XXEol<cr>')
|
2017-04-09 00:12:26 +03:00
|
|
|
|
feed_command('enew!')
|
|
|
|
|
|
feed_command('set noeol nofixeol')
|
2015-10-13 13:57:53 +02:00
|
|
|
|
feed('awithout eol<esc>:w! XXNoEol<cr>')
|
2017-04-09 00:12:26 +03:00
|
|
|
|
feed_command('set eol fixeol')
|
|
|
|
|
|
feed_command('bwipe XXEol XXNoEol')
|
2015-10-13 13:57:53 +02:00
|
|
|
|
|
|
|
|
|
|
-- Try editing files with 'fixeol' disabled.
|
2017-04-09 00:12:26 +03:00
|
|
|
|
feed_command('e! XXEol')
|
2015-10-13 13:57:53 +02:00
|
|
|
|
feed('ostays eol<esc>:set nofixeol<cr>')
|
2017-04-09 00:12:26 +03:00
|
|
|
|
feed_command('w! XXTestEol')
|
|
|
|
|
|
feed_command('e! XXNoEol')
|
2015-10-13 13:57:53 +02:00
|
|
|
|
feed('ostays without<esc>:set nofixeol<cr>')
|
2017-04-09 00:12:26 +03:00
|
|
|
|
feed_command('w! XXTestNoEol')
|
|
|
|
|
|
feed_command('bwipe XXEol XXNoEol XXTestEol XXTestNoEol')
|
|
|
|
|
|
feed_command('set fixeol')
|
2015-10-13 13:57:53 +02:00
|
|
|
|
|
|
|
|
|
|
-- Append "END" to each file so that we can see what the last written char was.
|
|
|
|
|
|
feed('ggdGaEND<esc>:w >>XXEol<cr>')
|
2017-04-09 00:12:26 +03:00
|
|
|
|
feed_command('w >>XXNoEol')
|
|
|
|
|
|
feed_command('w >>XXTestEol')
|
|
|
|
|
|
feed_command('w >>XXTestNoEol')
|
2015-10-13 13:57:53 +02:00
|
|
|
|
|
|
|
|
|
|
-- Concatenate the results.
|
2017-04-09 00:12:26 +03:00
|
|
|
|
feed_command('e! test.out')
|
2015-10-13 13:57:53 +02:00
|
|
|
|
feed('a0<esc>:$r XXEol<cr>')
|
2017-04-09 00:12:26 +03:00
|
|
|
|
feed_command('$r XXNoEol')
|
2015-10-13 13:57:53 +02:00
|
|
|
|
feed('Go1<esc>:$r XXTestEol<cr>')
|
2017-04-09 00:12:26 +03:00
|
|
|
|
feed_command('$r XXTestNoEol')
|
|
|
|
|
|
feed_command('w')
|
2015-10-13 13:57:53 +02:00
|
|
|
|
|
|
|
|
|
|
-- Assert buffer contents.
|
|
|
|
|
|
expect([=[
|
|
|
|
|
|
0
|
|
|
|
|
|
with eol
|
|
|
|
|
|
END
|
|
|
|
|
|
without eolEND
|
|
|
|
|
|
1
|
|
|
|
|
|
with eol
|
|
|
|
|
|
stays eol
|
|
|
|
|
|
END
|
|
|
|
|
|
without eol
|
|
|
|
|
|
stays withoutEND]=])
|
|
|
|
|
|
end)
|
|
|
|
|
|
end)
|