@@ -22,6 +22,14 @@ func Test_1_set_secure()
2222 call assert_equal (1 , has (' gui_running' ))
2323endfunc
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+
2533func Test_getfontname_with_arg ()
2634 let skipped = ' '
2735
@@ -117,6 +125,129 @@ func Test_quoteplus()
117125 endif
118126endfunc
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\n Suppported\n Balloon\n using 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+
120251func Test_set_guifont ()
121252 let skipped = ' '
122253
0 commit comments