xref: /vim-8.2.3635/src/testdir/test_fixeol.vim (revision 577fadfc)
1" Tests for 'fixeol' and 'eol'
2func Test_fixeol()
3  " first write two test files – with and without trailing EOL
4  " use Unix fileformat for consistency
5  set ff=unix
6  enew!
7  call setline('.', 'with eol')
8  w! XXEol
9  enew!
10  set noeol nofixeol
11  call setline('.', 'without eol')
12  w! XXNoEol
13  set eol fixeol
14  bwipe XXEol XXNoEol
15
16  " try editing files with 'fixeol' disabled
17  e! XXEol
18  normal ostays eol
19  set nofixeol
20  w! XXTestEol
21  e! XXNoEol
22  normal ostays without
23  set nofixeol
24  w! XXTestNoEol
25  bwipe! XXEol XXNoEol XXTestEol XXTestNoEol
26  set fixeol
27
28  " Append "END" to each file so that we can see what the last written char
29  " was.
30  normal ggdGaEND
31  w >>XXEol
32  w >>XXNoEol
33  w >>XXTestEol
34  w >>XXTestNoEol
35
36  call assert_equal(['with eol', 'END'], readfile('XXEol'))
37  call assert_equal(['without eolEND'], readfile('XXNoEol'))
38  call assert_equal(['with eol', 'stays eol', 'END'], readfile('XXTestEol'))
39  call assert_equal(['without eol', 'stays withoutEND'],
40	      \ readfile('XXTestNoEol'))
41
42  call delete('XXEol')
43  call delete('XXNoEol')
44  call delete('XXTestEol')
45  call delete('XXTestNoEol')
46  set ff& fixeol& eol&
47  enew!
48endfunc
49