annotate src/testdir/test_fixeol.vim @ 33940:f60c0fe7cae4 v9.0.2166

patch 9.0.2166: Memory leak in Configure Script when checking GTK Commit: https://github.com/vim/vim/commit/549f8c0b4ebe47168c98f46c8b62b1eb33da7c9c Author: Zdenek Dohnal <zdohnal@redhat.com> Date: Thu Dec 14 20:22:49 2023 +0100 patch 9.0.2166: Memory leak in Configure Script when checking GTK Problem: Memory leak in Configure Script when checking GTK Solution: Free the allocated memory If the memory is not freed, GTK GUI VIM cannot be build with address sanitizer for debugging purposes - configure script will report missing GTK, because the testing file compilation fails due reported memory leak. closes: #13672 Signed-off-by: Zdenek Dohnal <zdohnal@redhat.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Thu, 14 Dec 2023 20:30:05 +0100
parents 92b1338023ee
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30962
3a01529f17f5 patch 9.0.0817
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
1 " Tests for 'fixeol', 'eof' and 'eol'
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 12851
diff changeset
2
12851
90aaa974594e patch 8.0.1302: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 func Test_fixeol()
90aaa974594e patch 8.0.1302: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 " first write two test files – with and without trailing EOL
90aaa974594e patch 8.0.1302: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 " use Unix fileformat for consistency
90aaa974594e patch 8.0.1302: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 set ff=unix
90aaa974594e patch 8.0.1302: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 enew!
30962
3a01529f17f5 patch 9.0.0817
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
8 call setline('.', 'with eol or eof')
12851
90aaa974594e patch 8.0.1302: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 w! XXEol
90aaa974594e patch 8.0.1302: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 enew!
30962
3a01529f17f5 patch 9.0.0817
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
11 set noeof noeol nofixeol
3a01529f17f5 patch 9.0.0817
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
12 call setline('.', 'without eol or eof')
12851
90aaa974594e patch 8.0.1302: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 w! XXNoEol
30962
3a01529f17f5 patch 9.0.0817
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
14 set eol eof fixeol
12851
90aaa974594e patch 8.0.1302: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 bwipe XXEol XXNoEol
90aaa974594e patch 8.0.1302: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16
90aaa974594e patch 8.0.1302: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 " try editing files with 'fixeol' disabled
90aaa974594e patch 8.0.1302: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 e! XXEol
90aaa974594e patch 8.0.1302: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 normal ostays eol
90aaa974594e patch 8.0.1302: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 set nofixeol
90aaa974594e patch 8.0.1302: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 w! XXTestEol
90aaa974594e patch 8.0.1302: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 e! XXNoEol
90aaa974594e patch 8.0.1302: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 normal ostays without
90aaa974594e patch 8.0.1302: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 set nofixeol
90aaa974594e patch 8.0.1302: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 w! XXTestNoEol
90aaa974594e patch 8.0.1302: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 bwipe! XXEol XXNoEol XXTestEol XXTestNoEol
90aaa974594e patch 8.0.1302: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 set fixeol
90aaa974594e patch 8.0.1302: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28
90aaa974594e patch 8.0.1302: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 " Append "END" to each file so that we can see what the last written char
90aaa974594e patch 8.0.1302: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 " was.
90aaa974594e patch 8.0.1302: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 normal ggdGaEND
90aaa974594e patch 8.0.1302: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 w >>XXEol
90aaa974594e patch 8.0.1302: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 w >>XXNoEol
90aaa974594e patch 8.0.1302: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 w >>XXTestEol
90aaa974594e patch 8.0.1302: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 w >>XXTestNoEol
90aaa974594e patch 8.0.1302: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36
30968
35265d9d24df patch 9.0.0819
Bram Moolenaar <Bram@vim.org>
parents: 30962
diff changeset
37 call assert_equal(['with eol or eof', 'END'], readfile('XXEol'))
35265d9d24df patch 9.0.0819
Bram Moolenaar <Bram@vim.org>
parents: 30962
diff changeset
38 call assert_equal(['without eol or eofEND'], readfile('XXNoEol'))
35265d9d24df patch 9.0.0819
Bram Moolenaar <Bram@vim.org>
parents: 30962
diff changeset
39 call assert_equal(['with eol or eof', 'stays eol', 'END'], readfile('XXTestEol'))
35265d9d24df patch 9.0.0819
Bram Moolenaar <Bram@vim.org>
parents: 30962
diff changeset
40 call assert_equal(['without eol or eof', 'stays withoutEND'],
12851
90aaa974594e patch 8.0.1302: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 \ readfile('XXTestNoEol'))
90aaa974594e patch 8.0.1302: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42
90aaa974594e patch 8.0.1302: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 call delete('XXEol')
90aaa974594e patch 8.0.1302: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 call delete('XXNoEol')
90aaa974594e patch 8.0.1302: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 call delete('XXTestEol')
90aaa974594e patch 8.0.1302: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 call delete('XXTestNoEol')
30962
3a01529f17f5 patch 9.0.0817
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
47 set ff& fixeol& eof& eol&
12851
90aaa974594e patch 8.0.1302: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 enew!
90aaa974594e patch 8.0.1302: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 endfunc
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 12851
diff changeset
50
30982
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
51 func Test_eof()
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
52 let data = 0z68656c6c6f.0d0a.776f726c64 " "hello\r\nworld"
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
53
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
54 " 1. Eol, Eof
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
55 " read
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
56 call writefile(data + 0z0d0a.1a, 'XXEolEof')
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
57 e! XXEolEof
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
58 call assert_equal(['hello', 'world'], getline(1, 2))
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
59 call assert_equal([1, 1], [&eol, &eof])
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
60 " write
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
61 set fixeol
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
62 w!
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
63 call assert_equal(data + 0z0d0a, readblob('XXEolEof'))
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
64 set nofixeol
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
65 w!
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
66 call assert_equal(data + 0z0d0a.1a, readblob('XXEolEof'))
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
67
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
68 " 2. NoEol, Eof
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
69 " read
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
70 call writefile(data + 0z1a, 'XXNoEolEof')
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
71 e! XXNoEolEof
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
72 call assert_equal(['hello', 'world'], getline(1, 2))
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
73 call assert_equal([0, 1], [&eol, &eof])
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
74 " write
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
75 set fixeol
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
76 w!
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
77 call assert_equal(data + 0z0d0a, readblob('XXNoEolEof'))
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
78 set nofixeol
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
79 w!
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
80 call assert_equal(data + 0z1a, readblob('XXNoEolEof'))
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
81
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
82 " 3. Eol, NoEof
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
83 " read
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
84 call writefile(data + 0z0d0a, 'XXEolNoEof')
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
85 e! XXEolNoEof
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
86 call assert_equal(['hello', 'world'], getline(1, 2))
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
87 call assert_equal([1, 0], [&eol, &eof])
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
88 " write
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
89 set fixeol
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
90 w!
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
91 call assert_equal(data + 0z0d0a, readblob('XXEolNoEof'))
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
92 set nofixeol
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
93 w!
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
94 call assert_equal(data + 0z0d0a, readblob('XXEolNoEof'))
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
95
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
96 " 4. NoEol, NoEof
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
97 " read
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
98 call writefile(data, 'XXNoEolNoEof')
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
99 e! XXNoEolNoEof
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
100 call assert_equal(['hello', 'world'], getline(1, 2))
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
101 call assert_equal([0, 0], [&eol, &eof])
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
102 " write
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
103 set fixeol
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
104 w!
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
105 call assert_equal(data + 0z0d0a, readblob('XXNoEolNoEof'))
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
106 set nofixeol
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
107 w!
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
108 call assert_equal(data, readblob('XXNoEolNoEof'))
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
109
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
110 call delete('XXEolEof')
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
111 call delete('XXNoEolEof')
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
112 call delete('XXEolNoEof')
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
113 call delete('XXNoEolNoEof')
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
114 set ff& fixeol& eof& eol&
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
115 enew!
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
116 endfunc
92b1338023ee patch 9.0.0826: if 'endofline' is set CTRL-Z may be written in a wrong place
Bram Moolenaar <Bram@vim.org>
parents: 30968
diff changeset
117
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 12851
diff changeset
118 " vim: shiftwidth=2 sts=2 expandtab