Skip to content

Commit d5841f2

Browse files
committed
patch 8.0.0414: balloon eval is not tested
Problem: Balloon eval is not tested. Solution: Add a few balloon tests. (Kazunobu Kuriyama)
1 parent a1c8ecf commit d5841f2

File tree

2 files changed

+133
-0
lines changed

2 files changed

+133
-0
lines changed

src/testdir/test_gui.vim

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ func Test_1_set_secure()
2222
call assert_equal(1, has('gui_running'))
2323
endfunc
2424

25+
" As for non-GUI, a balloon_show() test was already added with patch 8.0.0401
26+
func Test_balloon_show()
27+
if has('balloon_eval')
28+
" This won't do anything but must not crash either.
29+
call balloon_show('hi!')
30+
endif
31+
endfunc
32+
2533
func Test_getfontname_with_arg()
2634
let skipped = ''
2735

@@ -117,6 +125,129 @@ func Test_quoteplus()
117125
endif
118126
endfunc
119127

128+
func Test_set_balloondelay()
129+
if !exists('+balloondelay')
130+
return
131+
endif
132+
133+
let balloondelay_saved = &balloondelay
134+
135+
" Check if the default value is identical to that described in the manual.
136+
set balloondelay&
137+
call assert_equal(600, &balloondelay)
138+
139+
" Edge cases
140+
141+
" XXX This fact should be hidden so that people won't be tempted to write
142+
" plugin/TimeMachine.vim. TODO Add reasonable range checks to the source
143+
" code.
144+
set balloondelay=-1
145+
call assert_equal(-1, &balloondelay)
146+
147+
" Though it's possible to interpret the zero delay to be 'as soon as
148+
" possible' or even 'indefinite', its actual meaning depends on the GUI
149+
" toolkit in use after all.
150+
set balloondelay=0
151+
call assert_equal(0, &balloondelay)
152+
153+
set balloondelay=1
154+
call assert_equal(1, &balloondelay)
155+
156+
" Since p_bdelay is of type long currently, the upper bound can be
157+
" impractically huge and machine-dependent. Practically, it's sufficient
158+
" to check if balloondelay works with 0xffffffff (32 bits) for now.
159+
set balloondelay=4294967295
160+
call assert_equal(4294967295, &balloondelay)
161+
162+
let &balloondelay = balloondelay_saved
163+
endfunc
164+
165+
func Test_set_ballooneval()
166+
if !exists('+ballooneval')
167+
return
168+
endif
169+
170+
let ballooneval_saved = &ballooneval
171+
172+
set ballooneval&
173+
call assert_equal(0, &ballooneval)
174+
175+
set ballooneval
176+
call assert_notequal(0, &ballooneval)
177+
178+
set noballooneval
179+
call assert_equal(0, &ballooneval)
180+
181+
let &ballooneval = ballooneval_saved
182+
endfunc
183+
184+
func Test_set_balloonexpr()
185+
if !exists('+balloonexpr')
186+
return
187+
endif
188+
189+
let balloonexpr_saved = &balloonexpr
190+
191+
" Default value
192+
set balloonexpr&
193+
call assert_equal('', &balloonexpr)
194+
195+
" User-defined function
196+
new
197+
func MyBalloonExpr()
198+
return 'Cursor is at line ' . v:beval_lnum .
199+
\', column ' . v:beval_col .
200+
\ ' of file ' . bufname(v:beval_bufnr) .
201+
\ ' on word "' . v:beval_text . '"' .
202+
\ ' in window ' . v:beval_winid . ' (#' . v:beval_winnr . ')'
203+
endfunc
204+
setl balloonexpr=MyBalloonExpr()
205+
setl ballooneval
206+
call assert_equal('MyBalloonExpr()', &balloonexpr)
207+
" TODO Read non-empty text, place the pointer at a character of a word,
208+
" and check if the content of the balloon is the smae as what is expected.
209+
" Also, check if textlock works as expected.
210+
setl balloonexpr&
211+
call assert_equal('', &balloonexpr)
212+
delfunc MyBalloonExpr
213+
bwipe!
214+
215+
" Multiline support
216+
if has('balloon_multiline')
217+
" Multiline balloon using NL
218+
new
219+
func MyBalloonFuncForMultilineUsingNL()
220+
return "Multiline\nSuppported\nBalloon\nusing NL"
221+
endfunc
222+
setl balloonexpr=MyBalloonFuncForMultilineUsingNL()
223+
setl ballooneval
224+
call assert_equal('MyBalloonFuncForMultilineUsingNL()', &balloonexpr)
225+
" TODO Read non-empty text, place the pointer at a character of a word,
226+
" and check if the content of the balloon is the smae as what is
227+
" expected. Also, check if textlock works as expected.
228+
setl balloonexpr&
229+
delfunc MyBalloonFuncForMultilineUsingNL
230+
bwipe!
231+
232+
" Multiline balloon using List
233+
new
234+
func MyBalloonFuncForMultilineUsingList()
235+
return [ 'Multiline', 'Suppported', 'Balloon', 'using List' ]
236+
endfunc
237+
setl balloonexpr=MyBalloonFuncForMultilineUsingList()
238+
setl ballooneval
239+
call assert_equal('MyBalloonFuncForMultilineUsingList()', &balloonexpr)
240+
" TODO Read non-empty text, place the pointer at a character of a word,
241+
" and check if the content of the balloon is the smae as what is
242+
" expected. Also, check if textlock works as expected.
243+
setl balloonexpr&
244+
delfunc MyBalloonFuncForMultilineUsingList
245+
bwipe!
246+
endif
247+
248+
let &balloonexpr = balloonexpr_saved
249+
endfunc
250+
120251
func Test_set_guifont()
121252
let skipped = ''
122253

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
414,
767769
/**/
768770
413,
769771
/**/

0 commit comments

Comments
 (0)