blob: 2a74883a94655ba135715b52f35698b2d15d255c [file] [log] [blame]
Bram Moolenaar92f645b2022-02-11 13:29:40 +00001*testing.txt* For Vim version 8.2. Last change: 2022 Feb 10
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 Moolenaara2baa732022-02-04 16:09:54 +000068 any function. *E1142*
69 This will not work when called from a :def function, because
70 variables on the stack will be freed.
Bram Moolenaared997ad2019-07-21 16:42:00 +020071
72
73test_garbagecollect_soon() *test_garbagecollect_soon()*
74 Set the flag to call the garbagecollector as if in the main
75 loop. Only to be used in tests.
76
77
78test_getvalue({name}) *test_getvalue()*
79 Get the value of an internal variable. These values for
80 {name} are supported:
81 need_fileinfo
82
Bram Moolenaarce90e362019-09-08 18:58:44 +020083 Can also be used as a |method|: >
84 GetName()->test_getvalue()
Yegappan Lakshmananf1e74492021-06-21 18:44:26 +020085<
Yegappan Lakshmanan06011e12022-01-30 12:37:29 +000086 *test_gui_event()*
87test_gui_event({event}, {args})
88 Generate a GUI {event} with arguments {args} for testing Vim
Yegappan Lakshmananec3637c2022-01-30 18:01:24 +000089 functionality. This function works only when the GUI is
90 running.
Bram Moolenaar22863042021-10-16 15:23:36 +010091
Yegappan Lakshmanan06011e12022-01-30 12:37:29 +000092 {event} is a String and the supported values are:
93 "dropfiles" drop one or more files in a window.
Yegappan Lakshmananec3637c2022-01-30 18:01:24 +000094 "findrepl" search and replace text
Yegappan Lakshmanan06011e12022-01-30 12:37:29 +000095 "mouse" mouse button click event.
Bram Moolenaara2baa732022-02-04 16:09:54 +000096 "scrollbar" move or drag the scrollbar
Yegappan Lakshmanan06011e12022-01-30 12:37:29 +000097 "tabline" select a tab page by mouse click.
98 "tabmenu" select a tabline menu entry.
Yegappan Lakshmanan18d46582021-06-23 20:46:52 +020099
Yegappan Lakshmanan06011e12022-01-30 12:37:29 +0000100 {args} is a Dict and contains the arguments for the event.
101
102 "dropfiles":
103 Drop one or more files in a specified window. The supported
104 items in {args} are:
105 files: List of file names
106 row: window row number
107 col: window column number
108 modifiers: key modifiers. The supported values are:
109 0x4 Shift
110 0x8 Alt
111 0x10 Ctrl
112 The files are added to the |argument-list| and the first
113 file in {files} is edited in the window. See |drag-n-drop|
Yegappan Lakshmananec3637c2022-01-30 18:01:24 +0000114 for more information. This event works only when the
115 |drop_file| feature is present.
116
117 "findrepl":
Bram Moolenaara2baa732022-02-04 16:09:54 +0000118 {only available when the GUI has a find/replace dialog}
Yegappan Lakshmananec3637c2022-01-30 18:01:24 +0000119 Perform a search and replace of text. The supported items
120 in {args} are:
121 find_text: string to find.
122 repl_text: replacement string
123 flags: flags controlling the find/replace. Supported
124 values are:
125 1 search next string (find dialog)
126 2 search next string (replace dialog)
127 3 replace string once
128 4 replace all matches
129 8 match whole words only
130 16 match case
131 forward: set to 1 for forward search.
Yegappan Lakshmanan06011e12022-01-30 12:37:29 +0000132
133 "mouse":
Yegappan Lakshmananec3637c2022-01-30 18:01:24 +0000134 Inject a mouse button click event. The supported items in
135 {args} are:
Yegappan Lakshmanan06011e12022-01-30 12:37:29 +0000136 button: mouse button. The supported values are:
137 0 right mouse button
138 1 middle mouse button
139 2 left mouse button
140 3 mouse button release
141 4 scroll wheel down
142 5 scroll wheel up
143 6 scroll wheel left
144 7 scroll wheel right
145 row: mouse click row number. The first row of the
146 Vim window is 1 and the last row is 'lines'.
147 col: mouse click column number. The maximum value
148 of {col} is 'columns'.
149 multiclick: set to 1 to inject a multiclick mouse event.
150 modifiers: key modifiers. The supported values are:
151 4 shift is pressed
152 8 alt is pressed
153 16 ctrl is pressed
154
Bram Moolenaara2baa732022-02-04 16:09:54 +0000155 "scrollbar":
156 Set or drag the left, right or horizontal scrollbar. Only
157 works when the scrollbar actually exists. The supported
158 items in {args} are:
159 which: scrollbar. The supported values are:
160 left Left scrollbar of the current window
161 right Right scrollbar of the current window
162 hor Horizontal scrollbar
163 value: amount to scroll. For the vertical scrollbars
164 the value can be 1 to the line-count of the
165 buffer. For the horizontal scrollbar the
166 value can be between 1 and the maximum line
167 length, assuming 'wrap' is not set.
168 dragging: 1 to drag the scrollbar and 0 to click in the
169 scrollbar.
170
Yegappan Lakshmanan06011e12022-01-30 12:37:29 +0000171 "tabline":
172 Inject a mouse click event on the tabline to select a
173 tabpage. The supported items in {args} are:
174 tabnr: tab page number
175
176 "tabmenu":
177 Inject an event to select a tabline menu entry. The
178 supported items in {args} are:
179 tabnr: tab page number
180 item: tab page menu item number. 1 for the first
181 menu item, 2 for the second item and so on.
182
183 After injecting the GUI events you probably should call
Yegappan Lakshmananf1e74492021-06-21 18:44:26 +0200184 |feedkeys()| to have them processed, e.g.: >
185 call feedkeys("y", 'Lx!')
Yegappan Lakshmanan06011e12022-01-30 12:37:29 +0000186<
Yegappan Lakshmananb0ad2d92022-01-27 13:16:59 +0000187 Returns TRUE if the event is successfully added, FALSE if
Yegappan Lakshmanan06011e12022-01-30 12:37:29 +0000188 there is a failure.
Yegappan Lakshmananb0ad2d92022-01-27 13:16:59 +0000189
Yegappan Lakshmanan06011e12022-01-30 12:37:29 +0000190 Can also be used as a |method|: >
191 GetEvent()->test_gui_event({args})
192<
Bram Moolenaared997ad2019-07-21 16:42:00 +0200193test_ignore_error({expr}) *test_ignore_error()*
194 Ignore any error containing {expr}. A normal message is given
195 instead.
196 This is only meant to be used in tests, where catching the
197 error with try/catch cannot be used (because it skips over
198 following code).
199 {expr} is used literally, not as a pattern.
200 When the {expr} is the string "RESET" then the list of ignored
201 errors is made empty.
202
Bram Moolenaarce90e362019-09-08 18:58:44 +0200203 Can also be used as a |method|: >
204 GetErrorText()->test_ignore_error()
Bram Moolenaared997ad2019-07-21 16:42:00 +0200205
Bram Moolenaar89a9c152021-08-29 21:55:35 +0200206
Bram Moolenaared997ad2019-07-21 16:42:00 +0200207test_null_blob() *test_null_blob()*
208 Return a |Blob| that is null. Only useful for testing.
209
210
211test_null_channel() *test_null_channel()*
212 Return a |Channel| that is null. Only useful for testing.
213 {only available when compiled with the +channel feature}
214
215
216test_null_dict() *test_null_dict()*
217 Return a |Dict| that is null. Only useful for testing.
218
219
Bram Moolenaare69f6d02020-04-01 22:11:01 +0200220test_null_function() *test_null_function()*
Bram Moolenaard1caa942020-04-10 22:10:56 +0200221 Return a |Funcref| that is null. Only useful for testing.
Bram Moolenaare69f6d02020-04-01 22:11:01 +0200222
223
Bram Moolenaared997ad2019-07-21 16:42:00 +0200224test_null_job() *test_null_job()*
225 Return a |Job| that is null. Only useful for testing.
226 {only available when compiled with the +job feature}
227
228
229test_null_list() *test_null_list()*
230 Return a |List| that is null. Only useful for testing.
231
232
233test_null_partial() *test_null_partial()*
234 Return a |Partial| that is null. Only useful for testing.
235
236
237test_null_string() *test_null_string()*
238 Return a |String| that is null. Only useful for testing.
239
240
241test_option_not_set({name}) *test_option_not_set()*
242 Reset the flag that indicates option {name} was set. Thus it
243 looks like it still has the default value. Use like this: >
244 set ambiwidth=double
245 call test_option_not_set('ambiwidth')
246< Now the 'ambiwidth' option behaves like it was never changed,
247 even though the value is "double".
248 Only to be used for testing!
249
Bram Moolenaarce90e362019-09-08 18:58:44 +0200250 Can also be used as a |method|: >
251 GetOptionName()->test_option_not_set()
252
Bram Moolenaared997ad2019-07-21 16:42:00 +0200253
254test_override({name}, {val}) *test_override()*
255 Overrides certain parts of Vim's internal processing to be able
256 to run tests. Only to be used for testing Vim!
257 The override is enabled when {val} is non-zero and removed
258 when {val} is zero.
Bram Moolenaar3e4fa3d2022-01-13 22:05:09 +0000259 Current supported values for {name} are:
Bram Moolenaared997ad2019-07-21 16:42:00 +0200260
Bram Moolenaar3e4fa3d2022-01-13 22:05:09 +0000261 {name} effect when {val} is non-zero ~
262 autoload `import autoload` will load the script right
263 away, not postponed until an item is used
Bram Moolenaared997ad2019-07-21 16:42:00 +0200264 char_avail disable the char_avail() function
Bram Moolenaared997ad2019-07-21 16:42:00 +0200265 nfa_fail makes the NFA regexp engine fail to force a
266 fallback to the old engine
267 no_query_mouse do not query the mouse position for "dec"
268 terminals
269 no_wait_return set the "no_wait_return" flag. Not restored
270 with "ALL".
Bram Moolenaar3e4fa3d2022-01-13 22:05:09 +0000271 redraw disable the redrawing() function
272 redraw_flag ignore the RedrawingDisabled flag
273 starting reset the "starting" variable, see below
Bram Moolenaar0c0eddd2020-06-13 15:47:25 +0200274 term_props reset all terminal properties when the version
275 string is detected
Bram Moolenaar3e4fa3d2022-01-13 22:05:09 +0000276 ui_delay time in msec to use in ui_delay(); overrules a
277 wait time of up to 3 seconds for messages
Bram Moolenaarc8cdf0f2021-03-13 13:28:13 +0100278 uptime overrules sysinfo.uptime
ichizokae1bd872022-01-20 14:57:29 +0000279 vterm_title setting the window title by a job running in a
280 terminal window
Bram Moolenaared997ad2019-07-21 16:42:00 +0200281 ALL clear all overrides ({val} is not used)
282
283 "starting" is to be used when a test should behave like
284 startup was done. Since the tests are run by sourcing a
285 script the "starting" variable is non-zero. This is usually a
286 good thing (tests run faster), but sometimes changes behavior
287 in a way that the test doesn't work properly.
288 When using: >
289 call test_override('starting', 1)
290< The value of "starting" is saved. It is restored by: >
291 call test_override('starting', 0)
292
Bram Moolenaarce90e362019-09-08 18:58:44 +0200293< Can also be used as a |method|: >
294 GetOverrideVal()-> test_override('starting')
Bram Moolenaared997ad2019-07-21 16:42:00 +0200295
Bram Moolenaar89a9c152021-08-29 21:55:35 +0200296
Bram Moolenaared997ad2019-07-21 16:42:00 +0200297test_refcount({expr}) *test_refcount()*
298 Return the reference count of {expr}. When {expr} is of a
299 type that does not have a reference count, returns -1. Only
300 to be used for testing.
301
Bram Moolenaarce90e362019-09-08 18:58:44 +0200302 Can also be used as a |method|: >
303 GetVarname()->test_refcount()
304
Bram Moolenaared997ad2019-07-21 16:42:00 +0200305
Bram Moolenaared997ad2019-07-21 16:42:00 +0200306test_setmouse({row}, {col}) *test_setmouse()*
307 Set the mouse position to be used for the next mouse action.
308 {row} and {col} are one based.
309 For example: >
310 call test_setmouse(4, 20)
311 call feedkeys("\<LeftMouse>", "xt")
312
Bram Moolenaar89a9c152021-08-29 21:55:35 +0200313
Bram Moolenaared997ad2019-07-21 16:42:00 +0200314test_settime({expr}) *test_settime()*
315 Set the time Vim uses internally. Currently only used for
316 timestamps in the history, as they are used in viminfo, and
317 for undo.
318 Using a value of 1 makes Vim not sleep after a warning or
319 error message.
320 {expr} must evaluate to a number. When the value is zero the
321 normal behavior is restored.
322
Bram Moolenaarce90e362019-09-08 18:58:44 +0200323 Can also be used as a |method|: >
324 GetTime()->test_settime()
325
Bram Moolenaar89a9c152021-08-29 21:55:35 +0200326
Bram Moolenaar4f645c52020-02-08 16:40:39 +0100327test_srand_seed([seed]) *test_srand_seed()*
328 When [seed] is given this sets the seed value used by
329 `srand()`. When omitted the test seed is removed.
330
Bram Moolenaar89a9c152021-08-29 21:55:35 +0200331
332test_unknown() *test_unknown()*
333 Return a value with unknown type. Only useful for testing.
334
335
336test_void() *test_void()*
337 Return a value with void type. Only useful for testing.
338
Bram Moolenaared997ad2019-07-21 16:42:00 +0200339==============================================================================
Bram Moolenaar54775062019-07-31 21:07:14 +02003403. Assert functions *assert-functions-details*
Bram Moolenaared997ad2019-07-21 16:42:00 +0200341
342
343assert_beeps({cmd}) *assert_beeps()*
344 Run {cmd} and add an error message to |v:errors| if it does
345 NOT produce a beep or visual bell.
Bram Moolenaar5b8cabf2021-04-02 18:55:57 +0200346 Also see |assert_fails()|, |assert_nobeep()| and
347 |assert-return|.
Bram Moolenaared997ad2019-07-21 16:42:00 +0200348
Bram Moolenaar24278d22019-08-16 21:49:22 +0200349 Can also be used as a |method|: >
350 GetCmd()->assert_beeps()
351<
Bram Moolenaared997ad2019-07-21 16:42:00 +0200352 *assert_equal()*
353assert_equal({expected}, {actual} [, {msg}])
354 When {expected} and {actual} are not equal an error message is
355 added to |v:errors| and 1 is returned. Otherwise zero is
356 returned |assert-return|.
357 There is no automatic conversion, the String "4" is different
358 from the Number 4. And the number 4 is different from the
359 Float 4.0. The value of 'ignorecase' is not used here, case
360 always matters.
361 When {msg} is omitted an error in the form "Expected
362 {expected} but got {actual}" is produced.
363 Example: >
364 assert_equal('foo', 'bar')
365< Will result in a string to be added to |v:errors|:
366 test.vim line 12: Expected 'foo' but got 'bar' ~
367
Bram Moolenaar7ff78462020-07-10 22:00:53 +0200368 Can also be used as a |method|, the base is passed as the
369 second argument: >
Bram Moolenaar25e42232019-08-04 15:04:10 +0200370 mylist->assert_equal([1, 2, 3])
371
Bram Moolenaar25e42232019-08-04 15:04:10 +0200372< *assert_equalfile()*
Bram Moolenaarfb517ba2020-06-03 19:55:35 +0200373assert_equalfile({fname-one}, {fname-two} [, {msg}])
Bram Moolenaared997ad2019-07-21 16:42:00 +0200374 When the files {fname-one} and {fname-two} do not contain
375 exactly the same text an error message is added to |v:errors|.
376 Also see |assert-return|.
377 When {fname-one} or {fname-two} does not exist the error will
378 mention that.
379 Mainly useful with |terminal-diff|.
380
Bram Moolenaare49fbff2019-08-21 22:50:07 +0200381 Can also be used as a |method|: >
382 GetLog()->assert_equalfile('expected.log')
383
Bram Moolenaared997ad2019-07-21 16:42:00 +0200384assert_exception({error} [, {msg}]) *assert_exception()*
385 When v:exception does not contain the string {error} an error
386 message is added to |v:errors|. Also see |assert-return|.
387 This can be used to assert that a command throws an exception.
388 Using the error number, followed by a colon, avoids problems
389 with translations: >
390 try
391 commandthatfails
392 call assert_false(1, 'command should have failed')
393 catch
394 call assert_exception('E492:')
395 endtry
Bram Moolenaar1d634542020-08-18 13:41:50 +0200396<
397 *assert_fails()*
Bram Moolenaar9bd5d872020-09-06 21:47:48 +0200398assert_fails({cmd} [, {error} [, {msg} [, {lnum} [, {context}]]]])
Bram Moolenaared997ad2019-07-21 16:42:00 +0200399 Run {cmd} and add an error message to |v:errors| if it does
Bram Moolenaar9b7bf9e2020-07-11 22:14:59 +0200400 NOT produce an error or when {error} is not found in the
401 error message. Also see |assert-return|.
Bram Moolenaar6f4754b2022-01-23 12:07:04 +0000402 *E856*
Bram Moolenaar9b7bf9e2020-07-11 22:14:59 +0200403 When {error} is a string it must be found literally in the
404 first reported error. Most often this will be the error code,
405 including the colon, e.g. "E123:". >
406 assert_fails('bad cmd', 'E987:')
407<
408 When {error} is a |List| with one or two strings, these are
409 used as patterns. The first pattern is matched against the
410 first reported error: >
411 assert_fails('cmd', ['E987:.*expected bool'])
412< The second pattern, if present, is matched against the last
Bram Moolenaar4072ba52020-12-23 13:56:35 +0100413 reported error.
414 If there is only one error then both patterns must match. This
415 can be used to check that there is only one error.
416 To only match the last error use an empty string for the first
417 error: >
Bram Moolenaar9b7bf9e2020-07-11 22:14:59 +0200418 assert_fails('cmd', ['', 'E987:'])
419<
Bram Moolenaar1d634542020-08-18 13:41:50 +0200420 If {msg} is empty then it is not used. Do this to get the
421 default message when passing the {lnum} argument.
Bram Moolenaarf10911e2022-01-29 22:20:48 +0000422 *E1115*
Bram Moolenaar1d634542020-08-18 13:41:50 +0200423 When {lnum} is present and not negative, and the {error}
424 argument is present and matches, then this is compared with
425 the line number at which the error was reported. That can be
426 the line number in a function or in a script.
Bram Moolenaarf10911e2022-01-29 22:20:48 +0000427 *E1116*
Bram Moolenaar9bd5d872020-09-06 21:47:48 +0200428 When {context} is present it is used as a pattern and matched
429 against the context (script name or function name) where
430 {lnum} is located in.
431
Bram Moolenaared997ad2019-07-21 16:42:00 +0200432 Note that beeping is not considered an error, and some failing
433 commands only beep. Use |assert_beeps()| for those.
434
Bram Moolenaar24278d22019-08-16 21:49:22 +0200435 Can also be used as a |method|: >
436 GetCmd()->assert_fails('E99:')
437
Bram Moolenaar1d634542020-08-18 13:41:50 +0200438assert_false({actual} [, {msg}]) *assert_false()*
Bram Moolenaared997ad2019-07-21 16:42:00 +0200439 When {actual} is not false an error message is added to
440 |v:errors|, like with |assert_equal()|.
441 Also see |assert-return|.
442 A value is false when it is zero. When {actual} is not a
443 number the assert fails.
444 When {msg} is omitted an error in the form
445 "Expected False but got {actual}" is produced.
446
Bram Moolenaar24278d22019-08-16 21:49:22 +0200447 Can also be used as a |method|: >
448 GetResult()->assert_false()
449
Bram Moolenaared997ad2019-07-21 16:42:00 +0200450assert_inrange({lower}, {upper}, {actual} [, {msg}]) *assert_inrange()*
451 This asserts number and |Float| values. When {actual} is lower
452 than {lower} or higher than {upper} an error message is added
453 to |v:errors|. Also see |assert-return|.
454 When {msg} is omitted an error in the form
455 "Expected range {lower} - {upper}, but got {actual}" is
456 produced.
457
458 *assert_match()*
459assert_match({pattern}, {actual} [, {msg}])
460 When {pattern} does not match {actual} an error message is
461 added to |v:errors|. Also see |assert-return|.
462
463 {pattern} is used as with |=~|: The matching is always done
464 like 'magic' was set and 'cpoptions' is empty, no matter what
465 the actual value of 'magic' or 'cpoptions' is.
466
467 {actual} is used as a string, automatic conversion applies.
468 Use "^" and "$" to match with the start and end of the text.
469 Use both to match the whole text.
470
471 When {msg} is omitted an error in the form
472 "Pattern {pattern} does not match {actual}" is produced.
473 Example: >
474 assert_match('^f.*o$', 'foobar')
475< Will result in a string to be added to |v:errors|:
476 test.vim line 12: Pattern '^f.*o$' does not match 'foobar' ~
477
Bram Moolenaar24278d22019-08-16 21:49:22 +0200478 Can also be used as a |method|: >
479 getFile()->assert_match('foo.*')
480<
Bram Moolenaar5b8cabf2021-04-02 18:55:57 +0200481assert_nobeep({cmd}) *assert_nobeep()*
482 Run {cmd} and add an error message to |v:errors| if it
483 produces a beep or visual bell.
484 Also see |assert_beeps()|.
485
486 Can also be used as a |method|: >
487 GetCmd()->assert_nobeep()
488<
Bram Moolenaared997ad2019-07-21 16:42:00 +0200489 *assert_notequal()*
490assert_notequal({expected}, {actual} [, {msg}])
491 The opposite of `assert_equal()`: add an error message to
492 |v:errors| when {expected} and {actual} are equal.
493 Also see |assert-return|.
494
Bram Moolenaar25e42232019-08-04 15:04:10 +0200495 Can also be used as a |method|: >
496 mylist->assert_notequal([1, 2, 3])
497
498< *assert_notmatch()*
Bram Moolenaared997ad2019-07-21 16:42:00 +0200499assert_notmatch({pattern}, {actual} [, {msg}])
500 The opposite of `assert_match()`: add an error message to
501 |v:errors| when {pattern} matches {actual}.
502 Also see |assert-return|.
503
Bram Moolenaar24278d22019-08-16 21:49:22 +0200504 Can also be used as a |method|: >
505 getFile()->assert_notmatch('bar.*')
506
Bram Moolenaare49fbff2019-08-21 22:50:07 +0200507
Bram Moolenaared997ad2019-07-21 16:42:00 +0200508assert_report({msg}) *assert_report()*
Bram Moolenaar6aa57292021-08-14 21:25:52 +0200509 Report a test failure directly, using String {msg}.
Bram Moolenaared997ad2019-07-21 16:42:00 +0200510 Always returns one.
511
Bram Moolenaare49fbff2019-08-21 22:50:07 +0200512 Can also be used as a |method|: >
513 GetMessage()->assert_report()
514
515
Bram Moolenaared997ad2019-07-21 16:42:00 +0200516assert_true({actual} [, {msg}]) *assert_true()*
517 When {actual} is not true an error message is added to
518 |v:errors|, like with |assert_equal()|.
519 Also see |assert-return|.
520 A value is TRUE when it is a non-zero number. When {actual}
521 is not a number the assert fails.
522 When {msg} is omitted an error in the form "Expected True but
523 got {actual}" is produced.
524
Bram Moolenaar24278d22019-08-16 21:49:22 +0200525 Can also be used as a |method|: >
526 GetResult()->assert_true()
527<
Bram Moolenaared997ad2019-07-21 16:42:00 +0200528
529 vim:tw=78:ts=8:noet:ft=help:norl: