Mercurial > vim
comparison src/testdir/test_messages.vim @ 18983:54baf548bff9 v8.2.0052
patch 8.2.0052: more-prompt not properly tested
Commit: https://github.com/vim/vim/commit/c6d539b67181ad573452e919e58ecbfa362f4c49
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Dec 28 17:10:46 2019 +0100
patch 8.2.0052: more-prompt not properly tested
Problem: More-prompt not properly tested.
Solution: Add a test case. (Dominique Pelle, closes https://github.com/vim/vim/issues/5404)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 28 Dec 2019 17:15:04 +0100 |
parents | 8a2fb21c23c0 |
children | 3b1f83fdaabc |
comparison
equal
deleted
inserted
replaced
18982:26a583bf16df | 18983:54baf548bff9 |
---|---|
1 " Tests for :messages, :echomsg, :echoerr | 1 " Tests for :messages, :echomsg, :echoerr |
2 | 2 |
3 source shared.vim | 3 source shared.vim |
4 source term_util.vim | |
4 | 5 |
5 function Test_messages() | 6 function Test_messages() |
6 let oldmore = &more | 7 let oldmore = &more |
7 try | 8 try |
8 set nomore | 9 set nomore |
170 set showcmd ruler | 171 set showcmd ruler |
171 call assert_equal(&columns - 29, v:echospace) | 172 call assert_equal(&columns - 29, v:echospace) |
172 | 173 |
173 set ruler& showcmd& | 174 set ruler& showcmd& |
174 endfunc | 175 endfunc |
176 | |
177 " Test more-prompt (see :help more-prompt). | |
178 func Test_message_more() | |
179 if !CanRunVimInTerminal() | |
180 throw 'Skipped: cannot run vim in terminal' | |
181 endif | |
182 let buf = RunVimInTerminal('', {'rows': 6}) | |
183 call term_sendkeys(buf, ":call setline(1, range(1, 100))\n") | |
184 | |
185 call term_sendkeys(buf, ":%p#\n") | |
186 call WaitForAssert({-> assert_equal(' 5 5', term_getline(buf, 5))}) | |
187 call WaitForAssert({-> assert_equal('-- More --', term_getline(buf, 6))}) | |
188 | |
189 call term_sendkeys(buf, '?') | |
190 call WaitForAssert({-> assert_equal(' 5 5', term_getline(buf, 5))}) | |
191 call WaitForAssert({-> assert_equal('-- More -- SPACE/d/j: screen/page/line down, b/u/k: up, q: quit ', term_getline(buf, 6))}) | |
192 | |
193 " Down a line with j, <CR>, <NL> or <Down>. | |
194 call term_sendkeys(buf, "j") | |
195 call WaitForAssert({-> assert_equal(' 6 6', term_getline(buf, 5))}) | |
196 call WaitForAssert({-> assert_equal('-- More --', term_getline(buf, 6))}) | |
197 call term_sendkeys(buf, "\<NL>") | |
198 call WaitForAssert({-> assert_equal(' 7 7', term_getline(buf, 5))}) | |
199 call term_sendkeys(buf, "\<CR>") | |
200 call WaitForAssert({-> assert_equal(' 8 8', term_getline(buf, 5))}) | |
201 call term_sendkeys(buf, "\<Down>") | |
202 call WaitForAssert({-> assert_equal(' 9 9', term_getline(buf, 5))}) | |
203 | |
204 " Down a screen with <Space>, f, or <PageDown>. | |
205 call term_sendkeys(buf, 'f') | |
206 call WaitForAssert({-> assert_equal(' 14 14', term_getline(buf, 5))}) | |
207 call WaitForAssert({-> assert_equal('-- More --', term_getline(buf, 6))}) | |
208 call term_sendkeys(buf, ' ') | |
209 call WaitForAssert({-> assert_equal(' 19 19', term_getline(buf, 5))}) | |
210 call term_sendkeys(buf, "\<PageDown>") | |
211 call WaitForAssert({-> assert_equal(' 24 24', term_getline(buf, 5))}) | |
212 | |
213 " Down a page (half a screen) with d. | |
214 call term_sendkeys(buf, 'd') | |
215 call WaitForAssert({-> assert_equal(' 27 27', term_getline(buf, 5))}) | |
216 | |
217 " Down all the way with 'G'. | |
218 call term_sendkeys(buf, 'G') | |
219 call WaitForAssert({-> assert_equal('100 100', term_getline(buf, 5))}) | |
220 call WaitForAssert({-> assert_equal('Press ENTER or type command to continue', term_getline(buf, 6))}) | |
221 | |
222 " Up a line k, <BS> or <Up>. | |
223 call term_sendkeys(buf, 'k') | |
224 call WaitForAssert({-> assert_equal(' 99 99', term_getline(buf, 5))}) | |
225 call term_sendkeys(buf, "\<BS>") | |
226 call WaitForAssert({-> assert_equal(' 98 98', term_getline(buf, 5))}) | |
227 call term_sendkeys(buf, "\<Up>") | |
228 call WaitForAssert({-> assert_equal(' 97 97', term_getline(buf, 5))}) | |
229 | |
230 " Up a screen with b or <PageUp>. | |
231 call term_sendkeys(buf, 'b') | |
232 call WaitForAssert({-> assert_equal(' 92 92', term_getline(buf, 5))}) | |
233 call term_sendkeys(buf, "\<PageUp>") | |
234 call WaitForAssert({-> assert_equal(' 87 87', term_getline(buf, 5))}) | |
235 | |
236 " Up a page (half a screen) with u. | |
237 call term_sendkeys(buf, 'u') | |
238 call WaitForAssert({-> assert_equal(' 84 84', term_getline(buf, 5))}) | |
239 | |
240 " Up all the way with 'g'. | |
241 call term_sendkeys(buf, 'g') | |
242 call WaitForAssert({-> assert_equal(' 5 5', term_getline(buf, 5))}) | |
243 call WaitForAssert({-> assert_equal('-- More --', term_getline(buf, 6))}) | |
244 | |
245 " All the way down. Pressing f should do nothing but pressing | |
246 " space should end the more prompt. | |
247 call term_sendkeys(buf, 'G') | |
248 call WaitForAssert({-> assert_equal('100 100', term_getline(buf, 5))}) | |
249 call WaitForAssert({-> assert_equal('Press ENTER or type command to continue', term_getline(buf, 6))}) | |
250 call term_sendkeys(buf, 'f') | |
251 call WaitForAssert({-> assert_equal('100 100', term_getline(buf, 5))}) | |
252 call term_sendkeys(buf, ' ') | |
253 call WaitForAssert({-> assert_equal('100', term_getline(buf, 5))}) | |
254 | |
255 " Pressing g< shows the previous command output. | |
256 call term_sendkeys(buf, 'g<') | |
257 call WaitForAssert({-> assert_equal('100 100', term_getline(buf, 5))}) | |
258 call WaitForAssert({-> assert_equal('Press ENTER or type command to continue', term_getline(buf, 6))}) | |
259 | |
260 call term_sendkeys(buf, ":%p#\n") | |
261 call WaitForAssert({-> assert_equal(' 5 5', term_getline(buf, 5))}) | |
262 call WaitForAssert({-> assert_equal('-- More --', term_getline(buf, 6))}) | |
263 | |
264 " Stop command output with q, <Esc> or CTRL-C. | |
265 call term_sendkeys(buf, 'q') | |
266 call WaitForAssert({-> assert_equal('100', term_getline(buf, 5))}) | |
267 | |
268 call term_sendkeys(buf, ':q!') | |
269 call StopVimInTerminal(buf) | |
270 endfunc |