comparison src/testdir/test_statusline.vim @ 16332:97e15f5b0082 v8.1.1171

patch 8.1.1171: statusline test could fail in large terminal commit https://github.com/vim/vim/commit/316c16797a0baee8f4bced2235b783b21fbbea65 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Apr 14 13:23:40 2019 +0200 patch 8.1.1171: statusline test could fail in large terminal Problem: Statusline test could fail in large terminal. Solution: Make the test work on a huge terminal. (Dominique Pelle, closes #4255)
author Bram Moolenaar <Bram@vim.org>
date Sun, 14 Apr 2019 13:30:04 +0200
parents 185f8dbdcf26
children dc85d49349f7
comparison
equal deleted inserted replaced
16331:371cf4db4a61 16332:97e15f5b0082
60 func Test_statusline() 60 func Test_statusline()
61 new Xstatusline 61 new Xstatusline
62 only 62 only
63 set laststatus=2 63 set laststatus=2
64 set splitbelow 64 set splitbelow
65 call setline(1, range(1, 200)) 65 call setline(1, range(1, 10000))
66 66
67 " %b: Value of character under cursor. 67 " %b: Value of character under cursor.
68 " %B: As above, in hexadecimal. 68 " %B: As above, in hexadecimal.
69 call cursor(180, 2) 69 call cursor(9000, 1)
70 set statusline=%b,%B 70 set statusline=%b,%B
71 call assert_match('^56,38\s*$', s:get_statusline()) 71 call assert_match('^57,39\s*$', s:get_statusline())
72 72
73 " %o: Byte number in file of byte under cursor, first byte is 1. 73 " %o: Byte number in file of byte under cursor, first byte is 1.
74 " %O: As above, in hexadecimal. 74 " %O: As above, in hexadecimal.
75 set statusline=%o,%O 75 set statusline=%o,%O
76 set fileformat=dos 76 set fileformat=dos
77 call assert_match('^789,315\s*$', s:get_statusline()) 77 call assert_match('^52888,CE98\s*$', s:get_statusline())
78 set fileformat=mac 78 set fileformat=mac
79 call assert_match('^610,262\s*$', s:get_statusline()) 79 call assert_match('^43889,AB71\s*$', s:get_statusline())
80 set fileformat=unix 80 set fileformat=unix
81 call assert_match('^610,262\s*$', s:get_statusline()) 81 call assert_match('^43889,AB71\s*$', s:get_statusline())
82 set fileformat& 82 set fileformat&
83 83
84 " %f: Path to the file in the buffer, as typed or relative to current dir. 84 " %f: Path to the file in the buffer, as typed or relative to current dir.
85 set statusline=%f 85 set statusline=%f
86 call assert_match('^Xstatusline\s*$', s:get_statusline()) 86 call assert_match('^Xstatusline\s*$', s:get_statusline())
110 110
111 " %l: Line number. 111 " %l: Line number.
112 " %L: Number of line in buffer. 112 " %L: Number of line in buffer.
113 " %c: Column number. 113 " %c: Column number.
114 set statusline=%l/%L,%c 114 set statusline=%l/%L,%c
115 call assert_match('^180/200,2\s*$', s:get_statusline()) 115 call assert_match('^9000/10000,1\s*$', s:get_statusline())
116 116
117 " %m: Modified flag, text is "[+]", "[-]" if 'modifiable' is off. 117 " %m: Modified flag, text is "[+]", "[-]" if 'modifiable' is off.
118 " %M: Modified flag, text is ",+" or ",-". 118 " %M: Modified flag, text is ",+" or ",-".
119 set statusline=%m%M 119 set statusline=%m%M
120 call assert_match('^\[+\],+\s*$', s:get_statusline()) 120 call assert_match('^\[+\],+\s*$', s:get_statusline())
134 set statusline=%p,%P 134 set statusline=%p,%P
135 0 135 0
136 call assert_match('^0,Top\s*$', s:get_statusline()) 136 call assert_match('^0,Top\s*$', s:get_statusline())
137 norm G 137 norm G
138 call assert_match('^100,Bot\s*$', s:get_statusline()) 138 call assert_match('^100,Bot\s*$', s:get_statusline())
139 180 139 9000
140 " Don't check the exact percentage as it depends on the window size 140 " Don't check the exact percentage as it depends on the window size
141 call assert_match('^90,\(Top\|Bot\|\d\+%\)\s*$', s:get_statusline()) 141 call assert_match('^90,\(Top\|Bot\|\d\+%\)\s*$', s:get_statusline())
142 142
143 " %q: "[Quickfix List]", "[Location List]" or empty. 143 " %q: "[Quickfix List]", "[Location List]" or empty.
144 set statusline=%q 144 set statusline=%q
163 set statusline=%t 163 set statusline=%t
164 call assert_match('^Xstatusline\s*$', s:get_statusline()) 164 call assert_match('^Xstatusline\s*$', s:get_statusline())
165 165
166 " %v: Virtual column number. 166 " %v: Virtual column number.
167 " %V: Virtual column number as -{num}. Not displayed if equal to 'c'. 167 " %V: Virtual column number as -{num}. Not displayed if equal to 'c'.
168 call cursor(180, 2) 168 call cursor(9000, 2)
169 set statusline=%v,%V 169 set statusline=%v,%V
170 call assert_match('^2,\s*$', s:get_statusline()) 170 call assert_match('^2,\s*$', s:get_statusline())
171 set virtualedit=all 171 set virtualedit=all
172 norm 10| 172 norm 10|
173 call assert_match('^10,-10\s*$', s:get_statusline()) 173 call assert_match('^10,-10\s*$', s:get_statusline())
193 set statusline=foo%=bar 193 set statusline=foo%=bar
194 call assert_match('^foo\s\+bar\s*$', s:get_statusline()) 194 call assert_match('^foo\s\+bar\s*$', s:get_statusline())
195 195
196 " Test min/max width, leading zeroes, left/right justify. 196 " Test min/max width, leading zeroes, left/right justify.
197 set statusline=%04B 197 set statusline=%04B
198 call cursor(180, 2) 198 call cursor(9000, 1)
199 call assert_match('^0038\s*$', s:get_statusline()) 199 call assert_match('^0039\s*$', s:get_statusline())
200 set statusline=#%4B# 200 set statusline=#%4B#
201 call assert_match('^# 38#\s*$', s:get_statusline()) 201 call assert_match('^# 39#\s*$', s:get_statusline())
202 set statusline=#%-4B# 202 set statusline=#%-4B#
203 call assert_match('^#38 #\s*$', s:get_statusline()) 203 call assert_match('^#39 #\s*$', s:get_statusline())
204 set statusline=%.6f 204 set statusline=%.6f
205 call assert_match('^<sline\s*$', s:get_statusline()) 205 call assert_match('^<sline\s*$', s:get_statusline())
206 206
207 " %<: Where to truncate. 207 " %<: Where to truncate.
208 exe 'set statusline=a%<b' . repeat('c', 1000) . 'd' 208 " First check with when %< should not truncate with many columns
209 call assert_match('^a<c*d$', s:get_statusline()) 209 exe 'set statusline=a%<b' . repeat('c', &columns - 3) . 'd'
210 exe 'set statusline=a' . repeat('b', 1000) . '%<c' 210 call assert_match('^abc\+d$', s:get_statusline())
211 call assert_match('^ab*>$', s:get_statusline()) 211 exe 'set statusline=a' . repeat('b', &columns - 2) . '%<c'
212 call assert_match('^ab\+c$', s:get_statusline())
213 " Then check when %< should truncate when there with too few columns.
214 exe 'set statusline=a%<b' . repeat('c', &columns - 2) . 'd'
215 call assert_match('^a<c\+d$', s:get_statusline())
216 exe 'set statusline=a' . repeat('b', &columns - 1) . '%<c'
217 call assert_match('^ab\+>$', s:get_statusline())
212 218
213 "%{: Evaluate expression between '%{' and '}' and substitute result. 219 "%{: Evaluate expression between '%{' and '}' and substitute result.
214 syntax on 220 syntax on
215 set statusline=%{SyntaxItem()} 221 set statusline=%{SyntaxItem()}
216 call assert_match('^vimNumber\s*$', s:get_statusline()) 222 call assert_match('^vimNumber\s*$', s:get_statusline())