2015-10-13 04:57:53 -07:00
|
|
|
|
-- Tests for 'fixeol'
|
|
|
|
|
|
2016-04-23 16:53:11 -07:00
|
|
|
|
local helpers = require('test.functional.helpers')(after_each)
|
2015-12-20 14:41:40 -07:00
|
|
|
|
local feed = helpers.feed
|
2017-04-08 14:12:26 -07:00
|
|
|
|
local clear, feed_command, expect = helpers.clear, helpers.feed_command, helpers.expect
|
2015-10-13 04:57:53 -07:00
|
|
|
|
|
|
|
|
|
describe('fixeol', function()
|
2015-12-12 22:21:11 -07:00
|
|
|
|
local function rmtestfiles()
|
2022-05-28 10:34:18 -07:00
|
|
|
|
os.remove("test.out")
|
|
|
|
|
os.remove("XXEol")
|
|
|
|
|
os.remove("XXNoEol")
|
|
|
|
|
os.remove("XXTestEol")
|
|
|
|
|
os.remove("XXTestNoEol")
|
2015-12-12 22:21:11 -07:00
|
|
|
|
end
|
|
|
|
|
setup(function()
|
|
|
|
|
clear()
|
|
|
|
|
rmtestfiles()
|
|
|
|
|
end)
|
|
|
|
|
teardown(function()
|
|
|
|
|
rmtestfiles()
|
|
|
|
|
end)
|
2015-10-13 04:57:53 -07:00
|
|
|
|
|
|
|
|
|
it('is working', function()
|
|
|
|
|
-- First write two test files – with and without trailing EOL.
|
2017-04-08 14:12:26 -07:00
|
|
|
|
feed_command('enew!')
|
2015-10-13 04:57:53 -07:00
|
|
|
|
feed('awith eol<esc>:w! XXEol<cr>')
|
2017-04-08 14:12:26 -07:00
|
|
|
|
feed_command('enew!')
|
|
|
|
|
feed_command('set noeol nofixeol')
|
2015-10-13 04:57:53 -07:00
|
|
|
|
feed('awithout eol<esc>:w! XXNoEol<cr>')
|
2017-04-08 14:12:26 -07:00
|
|
|
|
feed_command('set eol fixeol')
|
|
|
|
|
feed_command('bwipe XXEol XXNoEol')
|
2015-10-13 04:57:53 -07:00
|
|
|
|
|
|
|
|
|
-- Try editing files with 'fixeol' disabled.
|
2017-04-08 14:12:26 -07:00
|
|
|
|
feed_command('e! XXEol')
|
2015-10-13 04:57:53 -07:00
|
|
|
|
feed('ostays eol<esc>:set nofixeol<cr>')
|
2017-04-08 14:12:26 -07:00
|
|
|
|
feed_command('w! XXTestEol')
|
|
|
|
|
feed_command('e! XXNoEol')
|
2015-10-13 04:57:53 -07:00
|
|
|
|
feed('ostays without<esc>:set nofixeol<cr>')
|
2017-04-08 14:12:26 -07:00
|
|
|
|
feed_command('w! XXTestNoEol')
|
2021-08-17 20:30:58 -07:00
|
|
|
|
feed_command('bwipe! XXEol XXNoEol XXTestEol XXTestNoEol')
|
2017-04-08 14:12:26 -07:00
|
|
|
|
feed_command('set fixeol')
|
2015-10-13 04:57:53 -07: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-08 14:12:26 -07:00
|
|
|
|
feed_command('w >>XXNoEol')
|
|
|
|
|
feed_command('w >>XXTestEol')
|
|
|
|
|
feed_command('w >>XXTestNoEol')
|
2015-10-13 04:57:53 -07:00
|
|
|
|
|
|
|
|
|
-- Concatenate the results.
|
2017-04-08 14:12:26 -07:00
|
|
|
|
feed_command('e! test.out')
|
2015-10-13 04:57:53 -07:00
|
|
|
|
feed('a0<esc>:$r XXEol<cr>')
|
2017-04-08 14:12:26 -07:00
|
|
|
|
feed_command('$r XXNoEol')
|
2015-10-13 04:57:53 -07:00
|
|
|
|
feed('Go1<esc>:$r XXTestEol<cr>')
|
2017-04-08 14:12:26 -07:00
|
|
|
|
feed_command('$r XXTestNoEol')
|
|
|
|
|
feed_command('w')
|
2015-10-13 04:57:53 -07:00
|
|
|
|
|
|
|
|
|
-- Assert buffer contents.
|
|
|
|
|
expect([=[
|
|
|
|
|
0
|
|
|
|
|
with eol
|
|
|
|
|
END
|
|
|
|
|
without eolEND
|
|
|
|
|
1
|
|
|
|
|
with eol
|
|
|
|
|
stays eol
|
|
|
|
|
END
|
|
|
|
|
without eol
|
|
|
|
|
stays withoutEND]=])
|
|
|
|
|
end)
|
|
|
|
|
end)
|