blob: e5b91347364abb8784bdab5074885be7fc59ccab [file] [log] [blame]
Bram Moolenaar6f4754b2022-01-23 12:07:04 +00001*testing.txt* For Vim version 8.2. Last change: 2022 Jan 20
Bram Moolenaared997ad2019-07-21 16:42:00 +02002
3
4 VIM REFERENCE MANUAL by Bram Moolenaar
5
6
7Testing Vim and Vim script *testing-support*
8
9Expression evaluation is explained in |eval.txt|. This file goes into details
10about writing tests in Vim script. This can be used for testing Vim itself
11and for testing plugins.
12
131. Testing Vim |testing|
Bram Moolenaar54775062019-07-31 21:07:14 +0200142. Test functions |test-functions-details|
153. Assert functions |assert-functions-details|
Bram Moolenaared997ad2019-07-21 16:42:00 +020016
17==============================================================================
181. Testing Vim *testing*
19
20Vim can be tested after building it, usually with "make test".
21The tests are located in the directory "src/testdir".
22
Bram Moolenaarb96a32e2020-08-13 18:59:55 +020023There are two types of tests added over time:
24 test20.in oldest, only for tiny and small builds
25 test_something.vim new style tests
26
Bram Moolenaared997ad2019-07-21 16:42:00 +020027 *new-style-testing*
Bram Moolenaarf7c4d832020-08-11 20:42:19 +020028New tests should be added as new style tests. The test scripts are named
29test_<feature>.vim (replace <feature> with the feature under test). These use
30functions such as |assert_equal()| to keep the test commands and the expected
31result in one place.
Bram Moolenaarb96a32e2020-08-13 18:59:55 +020032 *old-style-testing*
33These tests are used only for testing Vim without the |+eval| feature.
Bram Moolenaared997ad2019-07-21 16:42:00 +020034
35Find more information in the file src/testdir/README.txt.
36
37==============================================================================
Bram Moolenaar54775062019-07-31 21:07:14 +0200382. Test functions *test-functions-details*
Bram Moolenaared997ad2019-07-21 16:42:00 +020039
40test_alloc_fail({id}, {countdown}, {repeat}) *test_alloc_fail()*
41 This is for testing: If the memory allocation with {id} is
42 called, then decrement {countdown}, and when it reaches zero
43 let memory allocation fail {repeat} times. When {repeat} is
44 smaller than one it fails one time.
45
Bram Moolenaarce90e362019-09-08 18:58:44 +020046 Can also be used as a |method|: >
47 GetAllocId()->test_alloc_fail()
Bram Moolenaared997ad2019-07-21 16:42:00 +020048
Bram Moolenaar89a9c152021-08-29 21:55:35 +020049
Bram Moolenaared997ad2019-07-21 16:42:00 +020050test_autochdir() *test_autochdir()*
51 Set a flag to enable the effect of 'autochdir' before Vim
52 startup has finished.
53
54
55test_feedinput({string}) *test_feedinput()*
56 Characters in {string} are queued for processing as if they
57 were typed by the user. This uses a low level input buffer.
58 This function works only when with |+unix| or GUI is running.
59
Bram Moolenaarce90e362019-09-08 18:58:44 +020060 Can also be used as a |method|: >
61 GetText()->test_feedinput()
Bram Moolenaared997ad2019-07-21 16:42:00 +020062
Bram Moolenaar89a9c152021-08-29 21:55:35 +020063
Bram Moolenaared997ad2019-07-21 16:42:00 +020064test_garbagecollect_now() *test_garbagecollect_now()*
65 Like garbagecollect(), but executed right away. This must
66 only be called directly to avoid any structure to exist
67 internally, and |v:testing| must have been set before calling
Bram Moolenaar0e6adf82021-12-16 14:41:10 +000068 any function. This will not work when called from a :def
69 function, because variables on the stack will be freed.
Bram Moolenaared997ad2019-07-21 16:42:00 +020070
71
72test_garbagecollect_soon() *test_garbagecollect_soon()*
73 Set the flag to call the garbagecollector as if in the main
74 loop. Only to be used in tests.
75
76
77test_getvalue({name}) *test_getvalue()*
78 Get the value of an internal variable. These values for
79 {name} are supported:
80 need_fileinfo
81
Bram Moolenaarce90e362019-09-08 18:58:44 +020082 Can also be used as a |method|: >
83 GetName()->test_getvalue()
Yegappan Lakshmananf1e74492021-06-21 18:44:26 +020084<
Yegappan Lakshmanan18d46582021-06-23 20:46:52 +020085 *test_gui_drop_files()*
86test_gui_drop_files({list}, {row}, {col}, {mods})
87 Drop one or more files in {list} in the window at {row}, {col}.
Bram Moolenaar90df4b92021-07-07 20:26:08 +020088 This function only works when the GUI is running and the
Bram Moolenaar22863042021-10-16 15:23:36 +010089 |drop_file| feature is present.
90
Yegappan Lakshmanan18d46582021-06-23 20:46:52 +020091 The supported values for {mods} are:
92 0x4 Shift
93 0x8 Alt
94 0x10 Ctrl
Bram Moolenaar22863042021-10-16 15:23:36 +010095 The files are added to the |argument-list| and the first file
96 in {list} is edited in the window. See |drag-n-drop| for more
Yegappan Lakshmanan18d46582021-06-23 20:46:52 +020097 information.
98
Yegappan Lakshmananf1e74492021-06-21 18:44:26 +020099 *test_gui_mouse_event()*
100test_gui_mouse_event({button}, {row}, {col}, {multiclick}, {modifiers})
Yegappan Lakshmanan18d46582021-06-23 20:46:52 +0200101 Inject a mouse button click event. This function only works
102 when the GUI is running.
Yegappan Lakshmananf1e74492021-06-21 18:44:26 +0200103 The supported values for {button} are:
104 0 right mouse button
105 1 middle mouse button
106 2 left mouse button
107 3 mouse button release
108 4 scroll wheel down
109 5 scroll wheel up
110 6 scroll wheel left
111 7 scroll wheel right
Yegappan Lakshmanan18d46582021-06-23 20:46:52 +0200112 {row} and {col} specify the location of the mouse click. The
113 first row of the Vim window is 1 and the last row is 'lines'.
114 The maximum value of {col} is 'columns'.
Yegappan Lakshmananf1e74492021-06-21 18:44:26 +0200115 To inject a multiclick event, set {multiclick} to 1.
116 The supported values for {modifiers} are:
117 4 shift is pressed
118 8 alt is pressed
119 16 ctrl is pressed
120 After injecting the mouse event you probably should call
121 |feedkeys()| to have them processed, e.g.: >
122 call feedkeys("y", 'Lx!')
123
Yegappan Lakshmananb0ad2d92022-01-27 13:16:59 +0000124 *test_gui_tabline_event()*
125test_gui_tabline_event({tabnr})
126 Add an event that simulates a click on the tabline to select
127 tabpage {tabnr} to the input buffer.
128 Returns TRUE if the event is successfully added, FALSE if
129 already in the tabpage {tabnr} or the cmdline window is open.
130 After injecting the event you probably should call
131 |feedkeys()| to have them processed, e.g.: >
132 call feedkeys("y", 'Lx!')
133
134 *test_gui_tabmenu_event()*
135test_gui_tabmenu_event({tabnr}, {event})
136 Add an event that simulates selecting a tabline menu entry for
137 tabpage {tabnr} to the input buffer. {event} is 1 for the
138 first menu entry, 2 for the second entry and so on.
139 After injecting the event you probably should call
140 |feedkeys()| to have them processed, e.g.: >
141 call feedkeys("y", 'Lx!')
Bram Moolenaared997ad2019-07-21 16:42:00 +0200142
143test_ignore_error({expr}) *test_ignore_error()*
144 Ignore any error containing {expr}. A normal message is given
145 instead.
146 This is only meant to be used in tests, where catching the
147 error with try/catch cannot be used (because it skips over
148 following code).
149 {expr} is used literally, not as a pattern.
150 When the {expr} is the string "RESET" then the list of ignored
151 errors is made empty.
152
Bram Moolenaarce90e362019-09-08 18:58:44 +0200153 Can also be used as a |method|: >
154 GetErrorText()->test_ignore_error()
Bram Moolenaared997ad2019-07-21 16:42:00 +0200155
Bram Moolenaar89a9c152021-08-29 21:55:35 +0200156
Bram Moolenaared997ad2019-07-21 16:42:00 +0200157test_null_blob() *test_null_blob()*
158 Return a |Blob| that is null. Only useful for testing.
159
160
161test_null_channel() *test_null_channel()*
162 Return a |Channel| that is null. Only useful for testing.
163 {only available when compiled with the +channel feature}
164
165
166test_null_dict() *test_null_dict()*
167 Return a |Dict| that is null. Only useful for testing.
168
169
Bram Moolenaare69f6d02020-04-01 22:11:01 +0200170test_null_function() *test_null_function()*
Bram Moolenaard1caa942020-04-10 22:10:56 +0200171 Return a |Funcref| that is null. Only useful for testing.
Bram Moolenaare69f6d02020-04-01 22:11:01 +0200172
173
Bram Moolenaared997ad2019-07-21 16:42:00 +0200174test_null_job() *test_null_job()*
175 Return a |Job| that is null. Only useful for testing.
176 {only available when compiled with the +job feature}
177
178
179test_null_list() *test_null_list()*
180 Return a |List| that is null. Only useful for testing.
181
182
183test_null_partial() *test_null_partial()*
184 Return a |Partial| that is null. Only useful for testing.
185
186
187test_null_string() *test_null_string()*
188 Return a |String| that is null. Only useful for testing.
189
190
191test_option_not_set({name}) *test_option_not_set()*
192 Reset the flag that indicates option {name} was set. Thus it
193 looks like it still has the default value. Use like this: >
194 set ambiwidth=double
195 call test_option_not_set('ambiwidth')
196< Now the 'ambiwidth' option behaves like it was never changed,
197 even though the value is "double".
198 Only to be used for testing!
199
Bram Moolenaarce90e362019-09-08 18:58:44 +0200200 Can also be used as a |method|: >
201 GetOptionName()->test_option_not_set()
202
Bram Moolenaared997ad2019-07-21 16:42:00 +0200203
204test_override({name}, {val}) *test_override()*
205 Overrides certain parts of Vim's internal processing to be able
206 to run tests. Only to be used for testing Vim!
207 The override is enabled when {val} is non-zero and removed
208 when {val} is zero.
Bram Moolenaar3e4fa3d2022-01-13 22:05:09 +0000209 Current supported values for {name} are:
Bram Moolenaared997ad2019-07-21 16:42:00 +0200210
Bram Moolenaar3e4fa3d2022-01-13 22:05:09 +0000211 {name} effect when {val} is non-zero ~
212 autoload `import autoload` will load the script right
213 away, not postponed until an item is used
Bram Moolenaared997ad2019-07-21 16:42:00 +0200214 char_avail disable the char_avail() function
Bram Moolenaared997ad2019-07-21 16:42:00 +0200215 nfa_fail makes the NFA regexp engine fail to force a
216 fallback to the old engine
217 no_query_mouse do not query the mouse position for "dec"
218 terminals
219 no_wait_return set the "no_wait_return" flag. Not restored
220 with "ALL".
Bram Moolenaar3e4fa3d2022-01-13 22:05:09 +0000221 redraw disable the redrawing() function
222 redraw_flag ignore the RedrawingDisabled flag
223 starting reset the "starting" variable, see below
Bram Moolenaar0c0eddd2020-06-13 15:47:25 +0200224 term_props reset all terminal properties when the version
225 string is detected
Bram Moolenaar3e4fa3d2022-01-13 22:05:09 +0000226 ui_delay time in msec to use in ui_delay(); overrules a
227 wait time of up to 3 seconds for messages
Bram Moolenaarc8cdf0f2021-03-13 13:28:13 +0100228 uptime overrules sysinfo.uptime
ichizokae1bd872022-01-20 14:57:29 +0000229 vterm_title setting the window title by a job running in a
230 terminal window
Bram Moolenaared997ad2019-07-21 16:42:00 +0200231 ALL clear all overrides ({val} is not used)
232
233 "starting" is to be used when a test should behave like
234 startup was done. Since the tests are run by sourcing a
235 script the "starting" variable is non-zero. This is usually a
236 good thing (tests run faster), but sometimes changes behavior
237 in a way that the test doesn't work properly.
238 When using: >
239 call test_override('starting', 1)
240< The value of "starting" is saved. It is restored by: >
241 call test_override('starting', 0)
242
Bram Moolenaarce90e362019-09-08 18:58:44 +0200243< Can also be used as a |method|: >
244 GetOverrideVal()-> test_override('starting')
Bram Moolenaared997ad2019-07-21 16:42:00 +0200245
Bram Moolenaar89a9c152021-08-29 21:55:35 +0200246
Bram Moolenaared997ad2019-07-21 16:42:00 +0200247test_refcount({expr}) *test_refcount()*
248 Return the reference count of {expr}. When {expr} is of a
249 type that does not have a reference count, returns -1. Only
250 to be used for testing.
251
Bram Moolenaarce90e362019-09-08 18:58:44 +0200252 Can also be used as a |method|: >
253 GetVarname()->test_refcount()
254
Bram Moolenaared997ad2019-07-21 16:42:00 +0200255
256test_scrollbar({which}, {value}, {dragging}) *test_scrollbar()*
257 Pretend using scrollbar {which} to move it to position
258 {value}. {which} can be:
259 left Left scrollbar of the current window
260 right Right scrollbar of the current window
261 hor Horizontal scrollbar
262
263 For the vertical scrollbars {value} can be 1 to the
264 line-count of the buffer. For the horizontal scrollbar the
265 {value} can be between 1 and the maximum line length, assuming
266 'wrap' is not set.
267
268 When {dragging} is non-zero it's like dragging the scrollbar,
269 otherwise it's like clicking in the scrollbar.
270 Only works when the {which} scrollbar actually exists,
271 obviously only when using the GUI.
272
Bram Moolenaarce90e362019-09-08 18:58:44 +0200273 Can also be used as a |method|: >
274 GetValue()->test_scrollbar('right', 0)
Bram Moolenaared997ad2019-07-21 16:42:00 +0200275
Bram Moolenaar89a9c152021-08-29 21:55:35 +0200276
Bram Moolenaared997ad2019-07-21 16:42:00 +0200277test_setmouse({row}, {col}) *test_setmouse()*
278 Set the mouse position to be used for the next mouse action.
279 {row} and {col} are one based.
280 For example: >
281 call test_setmouse(4, 20)
282 call feedkeys("\<LeftMouse>", "xt")
283
Bram Moolenaar89a9c152021-08-29 21:55:35 +0200284
Bram Moolenaared997ad2019-07-21 16:42:00 +0200285test_settime({expr}) *test_settime()*
286 Set the time Vim uses internally. Currently only used for
287 timestamps in the history, as they are used in viminfo, and
288 for undo.
289 Using a value of 1 makes Vim not sleep after a warning or
290 error message.
291 {expr} must evaluate to a number. When the value is zero the
292 normal behavior is restored.
293
Bram Moolenaarce90e362019-09-08 18:58:44 +0200294 Can also be used as a |method|: >
295 GetTime()->test_settime()
296
Bram Moolenaar89a9c152021-08-29 21:55:35 +0200297
Bram Moolenaar4f645c52020-02-08 16:40:39 +0100298test_srand_seed([seed]) *test_srand_seed()*
299 When [seed] is given this sets the seed value used by
300 `srand()`. When omitted the test seed is removed.
301
Bram Moolenaar89a9c152021-08-29 21:55:35 +0200302
303test_unknown() *test_unknown()*
304 Return a value with unknown type. Only useful for testing.
305
306
307test_void() *test_void()*
308 Return a value with void type. Only useful for testing.
309
Bram Moolenaared997ad2019-07-21 16:42:00 +0200310==============================================================================
Bram Moolenaar54775062019-07-31 21:07:14 +02003113. Assert functions *assert-functions-details*
Bram Moolenaared997ad2019-07-21 16:42:00 +0200312
313
314assert_beeps({cmd}) *assert_beeps()*
315 Run {cmd} and add an error message to |v:errors| if it does
316 NOT produce a beep or visual bell.
Bram Moolenaar5b8cabf2021-04-02 18:55:57 +0200317 Also see |assert_fails()|, |assert_nobeep()| and
318 |assert-return|.
Bram Moolenaared997ad2019-07-21 16:42:00 +0200319
Bram Moolenaar24278d22019-08-16 21:49:22 +0200320 Can also be used as a |method|: >
321 GetCmd()->assert_beeps()
322<
Bram Moolenaared997ad2019-07-21 16:42:00 +0200323 *assert_equal()*
324assert_equal({expected}, {actual} [, {msg}])
325 When {expected} and {actual} are not equal an error message is
326 added to |v:errors| and 1 is returned. Otherwise zero is
327 returned |assert-return|.
328 There is no automatic conversion, the String "4" is different
329 from the Number 4. And the number 4 is different from the
330 Float 4.0. The value of 'ignorecase' is not used here, case
331 always matters.
332 When {msg} is omitted an error in the form "Expected
333 {expected} but got {actual}" is produced.
334 Example: >
335 assert_equal('foo', 'bar')
336< Will result in a string to be added to |v:errors|:
337 test.vim line 12: Expected 'foo' but got 'bar' ~
338
Bram Moolenaar7ff78462020-07-10 22:00:53 +0200339 Can also be used as a |method|, the base is passed as the
340 second argument: >
Bram Moolenaar25e42232019-08-04 15:04:10 +0200341 mylist->assert_equal([1, 2, 3])
342
Bram Moolenaar25e42232019-08-04 15:04:10 +0200343< *assert_equalfile()*
Bram Moolenaarfb517ba2020-06-03 19:55:35 +0200344assert_equalfile({fname-one}, {fname-two} [, {msg}])
Bram Moolenaared997ad2019-07-21 16:42:00 +0200345 When the files {fname-one} and {fname-two} do not contain
346 exactly the same text an error message is added to |v:errors|.
347 Also see |assert-return|.
348 When {fname-one} or {fname-two} does not exist the error will
349 mention that.
350 Mainly useful with |terminal-diff|.
351
Bram Moolenaare49fbff2019-08-21 22:50:07 +0200352 Can also be used as a |method|: >
353 GetLog()->assert_equalfile('expected.log')
354
Bram Moolenaared997ad2019-07-21 16:42:00 +0200355assert_exception({error} [, {msg}]) *assert_exception()*
356 When v:exception does not contain the string {error} an error
357 message is added to |v:errors|. Also see |assert-return|.
358 This can be used to assert that a command throws an exception.
359 Using the error number, followed by a colon, avoids problems
360 with translations: >
361 try
362 commandthatfails
363 call assert_false(1, 'command should have failed')
364 catch
365 call assert_exception('E492:')
366 endtry
Bram Moolenaar1d634542020-08-18 13:41:50 +0200367<
368 *assert_fails()*
Bram Moolenaar9bd5d872020-09-06 21:47:48 +0200369assert_fails({cmd} [, {error} [, {msg} [, {lnum} [, {context}]]]])
Bram Moolenaared997ad2019-07-21 16:42:00 +0200370 Run {cmd} and add an error message to |v:errors| if it does
Bram Moolenaar9b7bf9e2020-07-11 22:14:59 +0200371 NOT produce an error or when {error} is not found in the
372 error message. Also see |assert-return|.
Bram Moolenaar6f4754b2022-01-23 12:07:04 +0000373 *E856*
Bram Moolenaar9b7bf9e2020-07-11 22:14:59 +0200374 When {error} is a string it must be found literally in the
375 first reported error. Most often this will be the error code,
376 including the colon, e.g. "E123:". >
377 assert_fails('bad cmd', 'E987:')
378<
379 When {error} is a |List| with one or two strings, these are
380 used as patterns. The first pattern is matched against the
381 first reported error: >
382 assert_fails('cmd', ['E987:.*expected bool'])
383< The second pattern, if present, is matched against the last
Bram Moolenaar4072ba52020-12-23 13:56:35 +0100384 reported error.
385 If there is only one error then both patterns must match. This
386 can be used to check that there is only one error.
387 To only match the last error use an empty string for the first
388 error: >
Bram Moolenaar9b7bf9e2020-07-11 22:14:59 +0200389 assert_fails('cmd', ['', 'E987:'])
390<
Bram Moolenaar1d634542020-08-18 13:41:50 +0200391 If {msg} is empty then it is not used. Do this to get the
392 default message when passing the {lnum} argument.
393
394 When {lnum} is present and not negative, and the {error}
395 argument is present and matches, then this is compared with
396 the line number at which the error was reported. That can be
397 the line number in a function or in a script.
398
Bram Moolenaar9bd5d872020-09-06 21:47:48 +0200399 When {context} is present it is used as a pattern and matched
400 against the context (script name or function name) where
401 {lnum} is located in.
402
Bram Moolenaared997ad2019-07-21 16:42:00 +0200403 Note that beeping is not considered an error, and some failing
404 commands only beep. Use |assert_beeps()| for those.
405
Bram Moolenaar24278d22019-08-16 21:49:22 +0200406 Can also be used as a |method|: >
407 GetCmd()->assert_fails('E99:')
408
Bram Moolenaar1d634542020-08-18 13:41:50 +0200409assert_false({actual} [, {msg}]) *assert_false()*
Bram Moolenaared997ad2019-07-21 16:42:00 +0200410 When {actual} is not false an error message is added to
411 |v:errors|, like with |assert_equal()|.
412 Also see |assert-return|.
413 A value is false when it is zero. When {actual} is not a
414 number the assert fails.
415 When {msg} is omitted an error in the form
416 "Expected False but got {actual}" is produced.
417
Bram Moolenaar24278d22019-08-16 21:49:22 +0200418 Can also be used as a |method|: >
419 GetResult()->assert_false()
420
Bram Moolenaared997ad2019-07-21 16:42:00 +0200421assert_inrange({lower}, {upper}, {actual} [, {msg}]) *assert_inrange()*
422 This asserts number and |Float| values. When {actual} is lower
423 than {lower} or higher than {upper} an error message is added
424 to |v:errors|. Also see |assert-return|.
425 When {msg} is omitted an error in the form
426 "Expected range {lower} - {upper}, but got {actual}" is
427 produced.
428
429 *assert_match()*
430assert_match({pattern}, {actual} [, {msg}])
431 When {pattern} does not match {actual} an error message is
432 added to |v:errors|. Also see |assert-return|.
433
434 {pattern} is used as with |=~|: The matching is always done
435 like 'magic' was set and 'cpoptions' is empty, no matter what
436 the actual value of 'magic' or 'cpoptions' is.
437
438 {actual} is used as a string, automatic conversion applies.
439 Use "^" and "$" to match with the start and end of the text.
440 Use both to match the whole text.
441
442 When {msg} is omitted an error in the form
443 "Pattern {pattern} does not match {actual}" is produced.
444 Example: >
445 assert_match('^f.*o$', 'foobar')
446< Will result in a string to be added to |v:errors|:
447 test.vim line 12: Pattern '^f.*o$' does not match 'foobar' ~
448
Bram Moolenaar24278d22019-08-16 21:49:22 +0200449 Can also be used as a |method|: >
450 getFile()->assert_match('foo.*')
451<
Bram Moolenaar5b8cabf2021-04-02 18:55:57 +0200452assert_nobeep({cmd}) *assert_nobeep()*
453 Run {cmd} and add an error message to |v:errors| if it
454 produces a beep or visual bell.
455 Also see |assert_beeps()|.
456
457 Can also be used as a |method|: >
458 GetCmd()->assert_nobeep()
459<
Bram Moolenaared997ad2019-07-21 16:42:00 +0200460 *assert_notequal()*
461assert_notequal({expected}, {actual} [, {msg}])
462 The opposite of `assert_equal()`: add an error message to
463 |v:errors| when {expected} and {actual} are equal.
464 Also see |assert-return|.
465
Bram Moolenaar25e42232019-08-04 15:04:10 +0200466 Can also be used as a |method|: >
467 mylist->assert_notequal([1, 2, 3])
468
469< *assert_notmatch()*
Bram Moolenaared997ad2019-07-21 16:42:00 +0200470assert_notmatch({pattern}, {actual} [, {msg}])
471 The opposite of `assert_match()`: add an error message to
472 |v:errors| when {pattern} matches {actual}.
473 Also see |assert-return|.
474
Bram Moolenaar24278d22019-08-16 21:49:22 +0200475 Can also be used as a |method|: >
476 getFile()->assert_notmatch('bar.*')
477
Bram Moolenaare49fbff2019-08-21 22:50:07 +0200478
Bram Moolenaared997ad2019-07-21 16:42:00 +0200479assert_report({msg}) *assert_report()*
Bram Moolenaar6aa57292021-08-14 21:25:52 +0200480 Report a test failure directly, using String {msg}.
Bram Moolenaared997ad2019-07-21 16:42:00 +0200481 Always returns one.
482
Bram Moolenaare49fbff2019-08-21 22:50:07 +0200483 Can also be used as a |method|: >
484 GetMessage()->assert_report()
485
486
Bram Moolenaared997ad2019-07-21 16:42:00 +0200487assert_true({actual} [, {msg}]) *assert_true()*
488 When {actual} is not true an error message is added to
489 |v:errors|, like with |assert_equal()|.
490 Also see |assert-return|.
491 A value is TRUE when it is a non-zero number. When {actual}
492 is not a number the assert fails.
493 When {msg} is omitted an error in the form "Expected True but
494 got {actual}" is produced.
495
Bram Moolenaar24278d22019-08-16 21:49:22 +0200496 Can also be used as a |method|: >
497 GetResult()->assert_true()
498<
Bram Moolenaared997ad2019-07-21 16:42:00 +0200499
500 vim:tw=78:ts=8:noet:ft=help:norl: