comparison src/testdir/test_prompt_buffer.vim @ 17976:6d11a0d5751d v8.1.1984

patch 8.1.1984: more functions can be used as methods Commit: https://github.com/vim/vim/commit/3f4f3d8e7e6fc0494d00cfb75669a554c8e67c8b Author: Bram Moolenaar <Bram@vim.org> Date: Wed Sep 4 20:05:59 2019 +0200 patch 8.1.1984: more functions can be used as methods Problem: More functions can be used as methods. Solution: Make various functions usable as a method.
author Bram Moolenaar <Bram@vim.org>
date Wed, 04 Sep 2019 20:15:04 +0200
parents ebe9aab81898
children 9c15be376631
comparison
equal deleted inserted replaced
17975:3e5a4604ea96 17976:6d11a0d5751d
46 \ 'call setline(1, "other buffer")', 46 \ 'call setline(1, "other buffer")',
47 \ 'set nomodified', 47 \ 'set nomodified',
48 \ 'new', 48 \ 'new',
49 \ 'set buftype=prompt', 49 \ 'set buftype=prompt',
50 \ 'call prompt_setcallback(bufnr(""), function("TextEntered"))', 50 \ 'call prompt_setcallback(bufnr(""), function("TextEntered"))',
51 \ 'eval bufnr("")->prompt_setprompt("cmd: ")',
51 \ 'startinsert', 52 \ 'startinsert',
52 \ ], a:name) 53 \ ], a:name)
53 endfunc 54 endfunc
54 55
55 func Test_prompt_basic() 56 func Test_prompt_basic()
58 endif 59 endif
59 let scriptName = 'XpromptscriptBasic' 60 let scriptName = 'XpromptscriptBasic'
60 call WriteScript(scriptName) 61 call WriteScript(scriptName)
61 62
62 let buf = RunVimInTerminal('-S ' . scriptName, {}) 63 let buf = RunVimInTerminal('-S ' . scriptName, {})
63 call WaitForAssert({-> assert_equal('%', term_getline(buf, 1))}) 64 call WaitForAssert({-> assert_equal('cmd:', term_getline(buf, 1))})
64 65
65 call term_sendkeys(buf, "hello\<CR>") 66 call term_sendkeys(buf, "hello\<CR>")
66 call WaitForAssert({-> assert_equal('% hello', term_getline(buf, 1))}) 67 call WaitForAssert({-> assert_equal('cmd: hello', term_getline(buf, 1))})
67 call WaitForAssert({-> assert_equal('Command: "hello"', term_getline(buf, 2))}) 68 call WaitForAssert({-> assert_equal('Command: "hello"', term_getline(buf, 2))})
68 call WaitForAssert({-> assert_equal('Result: "hello"', term_getline(buf, 3))}) 69 call WaitForAssert({-> assert_equal('Result: "hello"', term_getline(buf, 3))})
69 70
70 call term_sendkeys(buf, "exit\<CR>") 71 call term_sendkeys(buf, "exit\<CR>")
71 call WaitForAssert({-> assert_equal('other buffer', term_getline(buf, 1))}) 72 call WaitForAssert({-> assert_equal('other buffer', term_getline(buf, 1))})
80 endif 81 endif
81 let scriptName = 'XpromptscriptEditing' 82 let scriptName = 'XpromptscriptEditing'
82 call WriteScript(scriptName) 83 call WriteScript(scriptName)
83 84
84 let buf = RunVimInTerminal('-S ' . scriptName, {}) 85 let buf = RunVimInTerminal('-S ' . scriptName, {})
85 call WaitForAssert({-> assert_equal('%', term_getline(buf, 1))}) 86 call WaitForAssert({-> assert_equal('cmd:', term_getline(buf, 1))})
86 87
87 let bs = "\<BS>" 88 let bs = "\<BS>"
88 call term_sendkeys(buf, "hello" . bs . bs) 89 call term_sendkeys(buf, "hello" . bs . bs)
89 call WaitForAssert({-> assert_equal('% hel', term_getline(buf, 1))}) 90 call WaitForAssert({-> assert_equal('cmd: hel', term_getline(buf, 1))})
90 91
91 let left = "\<Left>" 92 let left = "\<Left>"
92 call term_sendkeys(buf, left . left . left . bs . '-') 93 call term_sendkeys(buf, left . left . left . bs . '-')
93 call WaitForAssert({-> assert_equal('% -hel', term_getline(buf, 1))}) 94 call WaitForAssert({-> assert_equal('cmd: -hel', term_getline(buf, 1))})
94 95
95 let end = "\<End>" 96 let end = "\<End>"
96 call term_sendkeys(buf, end . "x") 97 call term_sendkeys(buf, end . "x")
97 call WaitForAssert({-> assert_equal('% -helx', term_getline(buf, 1))}) 98 call WaitForAssert({-> assert_equal('cmd: -helx', term_getline(buf, 1))})
98 99
99 call term_sendkeys(buf, "\<C-U>exit\<CR>") 100 call term_sendkeys(buf, "\<C-U>exit\<CR>")
100 call WaitForAssert({-> assert_equal('other buffer', term_getline(buf, 1))}) 101 call WaitForAssert({-> assert_equal('other buffer', term_getline(buf, 1))})
101 102
102 call StopVimInTerminal(buf) 103 call StopVimInTerminal(buf)
111 " NOP 112 " NOP
112 endfunc 113 endfunc
113 114
114 new 115 new
115 set buftype=prompt 116 set buftype=prompt
116 call prompt_setcallback(bufnr(''), function('MyPromptCallback', [{}])) 117 eval bufnr('')->prompt_setcallback(function('MyPromptCallback', [{}]))
117 call prompt_setinterrupt(bufnr(''), function('MyPromptInterrupt', [{}])) 118 eval bufnr('')->prompt_setinterrupt(function('MyPromptInterrupt', [{}]))
118 call test_garbagecollect_now() 119 call test_garbagecollect_now()
119 " Must not crash 120 " Must not crash
120 call feedkeys("\<CR>\<C-C>", 'xt') 121 call feedkeys("\<CR>\<C-C>", 'xt')
121 call assert_true(v:true) 122 call assert_true(v:true)
122 123