blob: 1e9e832536face9bc849d0cec024866f2d35e9ed (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
-- Tests for 'fixeol'
local helpers = require('test.functional.helpers')(after_each)
local feed = helpers.feed
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
if helpers.pending_win32(pending) then return end
describe('fixeol', function()
local function rmtestfiles()
os.remove('test.out')
os.remove('XXEol')
os.remove('XXNoEol')
os.remove('XXTestEol')
os.remove('XXTestNoEol')
end
setup(function()
clear()
rmtestfiles()
end)
teardown(function()
rmtestfiles()
end)
it('is working', function()
-- First write two test files – with and without trailing EOL.
-- Use Unix fileformat for consistency.
execute('set ff=unix')
execute('enew!')
feed('awith eol<esc>:w! XXEol<cr>')
execute('enew!')
execute('set noeol nofixeol')
feed('awithout eol<esc>:w! XXNoEol<cr>')
execute('set eol fixeol')
execute('bwipe XXEol XXNoEol')
-- Try editing files with 'fixeol' disabled.
execute('e! XXEol')
feed('ostays eol<esc>:set nofixeol<cr>')
execute('w! XXTestEol')
execute('e! XXNoEol')
feed('ostays without<esc>:set nofixeol<cr>')
execute('w! XXTestNoEol')
execute('bwipe XXEol XXNoEol XXTestEol XXTestNoEol')
execute('set fixeol')
-- Append "END" to each file so that we can see what the last written char was.
feed('ggdGaEND<esc>:w >>XXEol<cr>')
execute('w >>XXNoEol')
execute('w >>XXTestEol')
execute('w >>XXTestNoEol')
-- Concatenate the results.
execute('e! test.out')
feed('a0<esc>:$r XXEol<cr>')
execute('$r XXNoEol')
feed('Go1<esc>:$r XXTestEol<cr>')
execute('$r XXTestNoEol')
execute('w')
-- Assert buffer contents.
expect([=[
0
with eol
END
without eolEND
1
with eol
stays eol
END
without eol
stays withoutEND]=])
end)
end)
|