blob: 8bd3cc919d30578fbfcfd8a357c99e2a79cb644b [file] [log] [blame]
Bram Moolenaarf10911e2022-01-29 22:20:48 +00001*testing.txt* For Vim version 8.2. Last change: 2022 Jan 23
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 Lakshmanan06011e12022-01-30 12:37:29 +000085 *test_gui_event()*
86test_gui_event({event}, {args})
87 Generate a GUI {event} with arguments {args} for testing Vim
Yegappan Lakshmananec3637c2022-01-30 18:01:24 +000088 functionality. This function works only when the GUI is
89 running.
Bram Moolenaar22863042021-10-16 15:23:36 +010090
Yegappan Lakshmanan06011e12022-01-30 12:37:29 +000091 {event} is a String and the supported values are:
92 "dropfiles" drop one or more files in a window.
Yegappan Lakshmananec3637c2022-01-30 18:01:24 +000093 "findrepl" search and replace text
Yegappan Lakshmanan06011e12022-01-30 12:37:29 +000094 "mouse" mouse button click event.
95 "tabline" select a tab page by mouse click.
96 "tabmenu" select a tabline menu entry.
Yegappan Lakshmanan18d46582021-06-23 20:46:52 +020097
Yegappan Lakshmanan06011e12022-01-30 12:37:29 +000098 {args} is a Dict and contains the arguments for the event.
99
100 "dropfiles":
101 Drop one or more files in a specified window. The supported
102 items in {args} are:
103 files: List of file names
104 row: window row number
105 col: window column number
106 modifiers: key modifiers. The supported values are:
107 0x4 Shift
108 0x8 Alt
109 0x10 Ctrl
110 The files are added to the |argument-list| and the first
111 file in {files} is edited in the window. See |drag-n-drop|
Yegappan Lakshmananec3637c2022-01-30 18:01:24 +0000112 for more information. This event works only when the
113 |drop_file| feature is present.
114
115 "findrepl":
116 Perform a search and replace of text. The supported items
117 in {args} are:
118 find_text: string to find.
119 repl_text: replacement string
120 flags: flags controlling the find/replace. Supported
121 values are:
122 1 search next string (find dialog)
123 2 search next string (replace dialog)
124 3 replace string once
125 4 replace all matches
126 8 match whole words only
127 16 match case
128 forward: set to 1 for forward search.
Yegappan Lakshmanan06011e12022-01-30 12:37:29 +0000129
130 "mouse":
Yegappan Lakshmananec3637c2022-01-30 18:01:24 +0000131 Inject a mouse button click event. The supported items in
132 {args} are:
Yegappan Lakshmanan06011e12022-01-30 12:37:29 +0000133 button: mouse button. The supported values are:
134 0 right mouse button
135 1 middle mouse button
136 2 left mouse button
137 3 mouse button release
138 4 scroll wheel down
139 5 scroll wheel up
140 6 scroll wheel left
141 7 scroll wheel right
142 row: mouse click row number. The first row of the
143 Vim window is 1 and the last row is 'lines'.
144 col: mouse click column number. The maximum value
145 of {col} is 'columns'.
146 multiclick: set to 1 to inject a multiclick mouse event.
147 modifiers: key modifiers. The supported values are:
148 4 shift is pressed
149 8 alt is pressed
150 16 ctrl is pressed
151
152 "tabline":
153 Inject a mouse click event on the tabline to select a
154 tabpage. The supported items in {args} are:
155 tabnr: tab page number
156
157 "tabmenu":
158 Inject an event to select a tabline menu entry. The
159 supported items in {args} are:
160 tabnr: tab page number
161 item: tab page menu item number. 1 for the first
162 menu item, 2 for the second item and so on.
163
164 After injecting the GUI events you probably should call
Yegappan Lakshmananf1e74492021-06-21 18:44:26 +0200165 |feedkeys()| to have them processed, e.g.: >
166 call feedkeys("y", 'Lx!')
Yegappan Lakshmanan06011e12022-01-30 12:37:29 +0000167<
Yegappan Lakshmananb0ad2d92022-01-27 13:16:59 +0000168 Returns TRUE if the event is successfully added, FALSE if
Yegappan Lakshmanan06011e12022-01-30 12:37:29 +0000169 there is a failure.
Yegappan Lakshmananb0ad2d92022-01-27 13:16:59 +0000170
Yegappan Lakshmanan06011e12022-01-30 12:37:29 +0000171 Can also be used as a |method|: >
172 GetEvent()->test_gui_event({args})
173<
Bram Moolenaared997ad2019-07-21 16:42:00 +0200174test_ignore_error({expr}) *test_ignore_error()*
175 Ignore any error containing {expr}. A normal message is given
176 instead.
177 This is only meant to be used in tests, where catching the
178 error with try/catch cannot be used (because it skips over
179 following code).
180 {expr} is used literally, not as a pattern.
181 When the {expr} is the string "RESET" then the list of ignored
182 errors is made empty.
183
Bram Moolenaarce90e362019-09-08 18:58:44 +0200184 Can also be used as a |method|: >
185 GetErrorText()->test_ignore_error()
Bram Moolenaared997ad2019-07-21 16:42:00 +0200186
Bram Moolenaar89a9c152021-08-29 21:55:35 +0200187
Bram Moolenaared997ad2019-07-21 16:42:00 +0200188test_null_blob() *test_null_blob()*
189 Return a |Blob| that is null. Only useful for testing.
190
191
192test_null_channel() *test_null_channel()*
193 Return a |Channel| that is null. Only useful for testing.
194 {only available when compiled with the +channel feature}
195
196
197test_null_dict() *test_null_dict()*
198 Return a |Dict| that is null. Only useful for testing.
199
200
Bram Moolenaare69f6d02020-04-01 22:11:01 +0200201test_null_function() *test_null_function()*
Bram Moolenaard1caa942020-04-10 22:10:56 +0200202 Return a |Funcref| that is null. Only useful for testing.
Bram Moolenaare69f6d02020-04-01 22:11:01 +0200203
204
Bram Moolenaared997ad2019-07-21 16:42:00 +0200205test_null_job() *test_null_job()*
206 Return a |Job| that is null. Only useful for testing.
207 {only available when compiled with the +job feature}
208
209
210test_null_list() *test_null_list()*
211 Return a |List| that is null. Only useful for testing.
212
213
214test_null_partial() *test_null_partial()*
215 Return a |Partial| that is null. Only useful for testing.
216
217
218test_null_string() *test_null_string()*
219 Return a |String| that is null. Only useful for testing.
220
221
222test_option_not_set({name}) *test_option_not_set()*
223 Reset the flag that indicates option {name} was set. Thus it
224 looks like it still has the default value. Use like this: >
225 set ambiwidth=double
226 call test_option_not_set('ambiwidth')
227< Now the 'ambiwidth' option behaves like it was never changed,
228 even though the value is "double".
229 Only to be used for testing!
230
Bram Moolenaarce90e362019-09-08 18:58:44 +0200231 Can also be used as a |method|: >
232 GetOptionName()->test_option_not_set()
233
Bram Moolenaared997ad2019-07-21 16:42:00 +0200234
235test_override({name}, {val}) *test_override()*
236 Overrides certain parts of Vim's internal processing to be able
237 to run tests. Only to be used for testing Vim!
238 The override is enabled when {val} is non-zero and removed
239 when {val} is zero.
Bram Moolenaar3e4fa3d2022-01-13 22:05:09 +0000240 Current supported values for {name} are:
Bram Moolenaared997ad2019-07-21 16:42:00 +0200241
Bram Moolenaar3e4fa3d2022-01-13 22:05:09 +0000242 {name} effect when {val} is non-zero ~
243 autoload `import autoload` will load the script right
244 away, not postponed until an item is used
Bram Moolenaared997ad2019-07-21 16:42:00 +0200245 char_avail disable the char_avail() function
Bram Moolenaared997ad2019-07-21 16:42:00 +0200246 nfa_fail makes the NFA regexp engine fail to force a
247 fallback to the old engine
248 no_query_mouse do not query the mouse position for "dec"
249 terminals
250 no_wait_return set the "no_wait_return" flag. Not restored
251 with "ALL".
Bram Moolenaar3e4fa3d2022-01-13 22:05:09 +0000252 redraw disable the redrawing() function
253 redraw_flag ignore the RedrawingDisabled flag
254 starting reset the "starting" variable, see below
Bram Moolenaar0c0eddd2020-06-13 15:47:25 +0200255 term_props reset all terminal properties when the version
256 string is detected
Bram Moolenaar3e4fa3d2022-01-13 22:05:09 +0000257 ui_delay time in msec to use in ui_delay(); overrules a
258 wait time of up to 3 seconds for messages
Bram Moolenaarc8cdf0f2021-03-13 13:28:13 +0100259 uptime overrules sysinfo.uptime
ichizokae1bd872022-01-20 14:57:29 +0000260 vterm_title setting the window title by a job running in a
261 terminal window
Bram Moolenaared997ad2019-07-21 16:42:00 +0200262 ALL clear all overrides ({val} is not used)
263
264 "starting" is to be used when a test should behave like
265 startup was done. Since the tests are run by sourcing a
266 script the "starting" variable is non-zero. This is usually a
267 good thing (tests run faster), but sometimes changes behavior
268 in a way that the test doesn't work properly.
269 When using: >
270 call test_override('starting', 1)
271< The value of "starting" is saved. It is restored by: >
272 call test_override('starting', 0)
273
Bram Moolenaarce90e362019-09-08 18:58:44 +0200274< Can also be used as a |method|: >
275 GetOverrideVal()-> test_override('starting')
Bram Moolenaared997ad2019-07-21 16:42:00 +0200276
Bram Moolenaar89a9c152021-08-29 21:55:35 +0200277
Bram Moolenaared997ad2019-07-21 16:42:00 +0200278test_refcount({expr}) *test_refcount()*
279 Return the reference count of {expr}. When {expr} is of a
280 type that does not have a reference count, returns -1. Only
281 to be used for testing.
282
Bram Moolenaarce90e362019-09-08 18:58:44 +0200283 Can also be used as a |method|: >
284 GetVarname()->test_refcount()
285
Bram Moolenaared997ad2019-07-21 16:42:00 +0200286
287test_scrollbar({which}, {value}, {dragging}) *test_scrollbar()*
288 Pretend using scrollbar {which} to move it to position
289 {value}. {which} can be:
290 left Left scrollbar of the current window
291 right Right scrollbar of the current window
292 hor Horizontal scrollbar
293
294 For the vertical scrollbars {value} can be 1 to the
295 line-count of the buffer. For the horizontal scrollbar the
296 {value} can be between 1 and the maximum line length, assuming
297 'wrap' is not set.
298
299 When {dragging} is non-zero it's like dragging the scrollbar,
300 otherwise it's like clicking in the scrollbar.
301 Only works when the {which} scrollbar actually exists,
302 obviously only when using the GUI.
303
Bram Moolenaarce90e362019-09-08 18:58:44 +0200304 Can also be used as a |method|: >
305 GetValue()->test_scrollbar('right', 0)
Bram Moolenaared997ad2019-07-21 16:42:00 +0200306
Bram Moolenaar89a9c152021-08-29 21:55:35 +0200307
Bram Moolenaared997ad2019-07-21 16:42:00 +0200308test_setmouse({row}, {col}) *test_setmouse()*
309 Set the mouse position to be used for the next mouse action.
310 {row} and {col} are one based.
311 For example: >
312 call test_setmouse(4, 20)
313 call feedkeys("\<LeftMouse>", "xt")
314
Bram Moolenaar89a9c152021-08-29 21:55:35 +0200315
Bram Moolenaared997ad2019-07-21 16:42:00 +0200316test_settime({expr}) *test_settime()*
317 Set the time Vim uses internally. Currently only used for
318 timestamps in the history, as they are used in viminfo, and
319 for undo.
320 Using a value of 1 makes Vim not sleep after a warning or
321 error message.
322 {expr} must evaluate to a number. When the value is zero the
323 normal behavior is restored.
324
Bram Moolenaarce90e362019-09-08 18:58:44 +0200325 Can also be used as a |method|: >
326 GetTime()->test_settime()
327
Bram Moolenaar89a9c152021-08-29 21:55:35 +0200328
Bram Moolenaar4f645c52020-02-08 16:40:39 +0100329test_srand_seed([seed]) *test_srand_seed()*
330 When [seed] is given this sets the seed value used by
331 `srand()`. When omitted the test seed is removed.
332
Bram Moolenaar89a9c152021-08-29 21:55:35 +0200333
334test_unknown() *test_unknown()*
335 Return a value with unknown type. Only useful for testing.
336
337
338test_void() *test_void()*
339 Return a value with void type. Only useful for testing.
340
Bram Moolenaared997ad2019-07-21 16:42:00 +0200341==============================================================================
Bram Moolenaar54775062019-07-31 21:07:14 +02003423. Assert functions *assert-functions-details*
Bram Moolenaared997ad2019-07-21 16:42:00 +0200343
344
345assert_beeps({cmd}) *assert_beeps()*
346 Run {cmd} and add an error message to |v:errors| if it does
347 NOT produce a beep or visual bell.
Bram Moolenaar5b8cabf2021-04-02 18:55:57 +0200348 Also see |assert_fails()|, |assert_nobeep()| and
349 |assert-return|.
Bram Moolenaared997ad2019-07-21 16:42:00 +0200350
Bram Moolenaar24278d22019-08-16 21:49:22 +0200351 Can also be used as a |method|: >
352 GetCmd()->assert_beeps()
353<
Bram Moolenaared997ad2019-07-21 16:42:00 +0200354 *assert_equal()*
355assert_equal({expected}, {actual} [, {msg}])
356 When {expected} and {actual} are not equal an error message is
357 added to |v:errors| and 1 is returned. Otherwise zero is
358 returned |assert-return|.
359 There is no automatic conversion, the String "4" is different
360 from the Number 4. And the number 4 is different from the
361 Float 4.0. The value of 'ignorecase' is not used here, case
362 always matters.
363 When {msg} is omitted an error in the form "Expected
364 {expected} but got {actual}" is produced.
365 Example: >
366 assert_equal('foo', 'bar')
367< Will result in a string to be added to |v:errors|:
368 test.vim line 12: Expected 'foo' but got 'bar' ~
369
Bram Moolenaar7ff78462020-07-10 22:00:53 +0200370 Can also be used as a |method|, the base is passed as the
371 second argument: >
Bram Moolenaar25e42232019-08-04 15:04:10 +0200372 mylist->assert_equal([1, 2, 3])
373
Bram Moolenaar25e42232019-08-04 15:04:10 +0200374< *assert_equalfile()*
Bram Moolenaarfb517ba2020-06-03 19:55:35 +0200375assert_equalfile({fname-one}, {fname-two} [, {msg}])
Bram Moolenaared997ad2019-07-21 16:42:00 +0200376 When the files {fname-one} and {fname-two} do not contain
377 exactly the same text an error message is added to |v:errors|.
378 Also see |assert-return|.
379 When {fname-one} or {fname-two} does not exist the error will
380 mention that.
381 Mainly useful with |terminal-diff|.
382
Bram Moolenaare49fbff2019-08-21 22:50:07 +0200383 Can also be used as a |method|: >
384 GetLog()->assert_equalfile('expected.log')
385
Bram Moolenaared997ad2019-07-21 16:42:00 +0200386assert_exception({error} [, {msg}]) *assert_exception()*
387 When v:exception does not contain the string {error} an error
388 message is added to |v:errors|. Also see |assert-return|.
389 This can be used to assert that a command throws an exception.
390 Using the error number, followed by a colon, avoids problems
391 with translations: >
392 try
393 commandthatfails
394 call assert_false(1, 'command should have failed')
395 catch
396 call assert_exception('E492:')
397 endtry
Bram Moolenaar1d634542020-08-18 13:41:50 +0200398<
399 *assert_fails()*
Bram Moolenaar9bd5d872020-09-06 21:47:48 +0200400assert_fails({cmd} [, {error} [, {msg} [, {lnum} [, {context}]]]])
Bram Moolenaared997ad2019-07-21 16:42:00 +0200401 Run {cmd} and add an error message to |v:errors| if it does
Bram Moolenaar9b7bf9e2020-07-11 22:14:59 +0200402 NOT produce an error or when {error} is not found in the
403 error message. Also see |assert-return|.
Bram Moolenaar6f4754b2022-01-23 12:07:04 +0000404 *E856*
Bram Moolenaar9b7bf9e2020-07-11 22:14:59 +0200405 When {error} is a string it must be found literally in the
406 first reported error. Most often this will be the error code,
407 including the colon, e.g. "E123:". >
408 assert_fails('bad cmd', 'E987:')
409<
410 When {error} is a |List| with one or two strings, these are
411 used as patterns. The first pattern is matched against the
412 first reported error: >
413 assert_fails('cmd', ['E987:.*expected bool'])
414< The second pattern, if present, is matched against the last
Bram Moolenaar4072ba52020-12-23 13:56:35 +0100415 reported error.
416 If there is only one error then both patterns must match. This
417 can be used to check that there is only one error.
418 To only match the last error use an empty string for the first
419 error: >
Bram Moolenaar9b7bf9e2020-07-11 22:14:59 +0200420 assert_fails('cmd', ['', 'E987:'])
421<
Bram Moolenaar1d634542020-08-18 13:41:50 +0200422 If {msg} is empty then it is not used. Do this to get the
423 default message when passing the {lnum} argument.
Bram Moolenaarf10911e2022-01-29 22:20:48 +0000424 *E1115*
Bram Moolenaar1d634542020-08-18 13:41:50 +0200425 When {lnum} is present and not negative, and the {error}
426 argument is present and matches, then this is compared with
427 the line number at which the error was reported. That can be
428 the line number in a function or in a script.
Bram Moolenaarf10911e2022-01-29 22:20:48 +0000429 *E1116*
Bram Moolenaar9bd5d872020-09-06 21:47:48 +0200430 When {context} is present it is used as a pattern and matched
431 against the context (script name or function name) where
432 {lnum} is located in.
433
Bram Moolenaared997ad2019-07-21 16:42:00 +0200434 Note that beeping is not considered an error, and some failing
435 commands only beep. Use |assert_beeps()| for those.
436
Bram Moolenaar24278d22019-08-16 21:49:22 +0200437 Can also be used as a |method|: >
438 GetCmd()->assert_fails('E99:')
439
Bram Moolenaar1d634542020-08-18 13:41:50 +0200440assert_false({actual} [, {msg}]) *assert_false()*
Bram Moolenaared997ad2019-07-21 16:42:00 +0200441 When {actual} is not false an error message is added to
442 |v:errors|, like with |assert_equal()|.
443 Also see |assert-return|.
444 A value is false when it is zero. When {actual} is not a
445 number the assert fails.
446 When {msg} is omitted an error in the form
447 "Expected False but got {actual}" is produced.
448
Bram Moolenaar24278d22019-08-16 21:49:22 +0200449 Can also be used as a |method|: >
450 GetResult()->assert_false()
451
Bram Moolenaared997ad2019-07-21 16:42:00 +0200452assert_inrange({lower}, {upper}, {actual} [, {msg}]) *assert_inrange()*
453 This asserts number and |Float| values. When {actual} is lower
454 than {lower} or higher than {upper} an error message is added
455 to |v:errors|. Also see |assert-return|.
456 When {msg} is omitted an error in the form
457 "Expected range {lower} - {upper}, but got {actual}" is
458 produced.
459
460 *assert_match()*
461assert_match({pattern}, {actual} [, {msg}])
462 When {pattern} does not match {actual} an error message is
463 added to |v:errors|. Also see |assert-return|.
464
465 {pattern} is used as with |=~|: The matching is always done
466 like 'magic' was set and 'cpoptions' is empty, no matter what
467 the actual value of 'magic' or 'cpoptions' is.
468
469 {actual} is used as a string, automatic conversion applies.
470 Use "^" and "$" to match with the start and end of the text.
471 Use both to match the whole text.
472
473 When {msg} is omitted an error in the form
474 "Pattern {pattern} does not match {actual}" is produced.
475 Example: >
476 assert_match('^f.*o$', 'foobar')
477< Will result in a string to be added to |v:errors|:
478 test.vim line 12: Pattern '^f.*o$' does not match 'foobar' ~
479
Bram Moolenaar24278d22019-08-16 21:49:22 +0200480 Can also be used as a |method|: >
481 getFile()->assert_match('foo.*')
482<
Bram Moolenaar5b8cabf2021-04-02 18:55:57 +0200483assert_nobeep({cmd}) *assert_nobeep()*
484 Run {cmd} and add an error message to |v:errors| if it
485 produces a beep or visual bell.
486 Also see |assert_beeps()|.
487
488 Can also be used as a |method|: >
489 GetCmd()->assert_nobeep()
490<
Bram Moolenaared997ad2019-07-21 16:42:00 +0200491 *assert_notequal()*
492assert_notequal({expected}, {actual} [, {msg}])
493 The opposite of `assert_equal()`: add an error message to
494 |v:errors| when {expected} and {actual} are equal.
495 Also see |assert-return|.
496
Bram Moolenaar25e42232019-08-04 15:04:10 +0200497 Can also be used as a |method|: >
498 mylist->assert_notequal([1, 2, 3])
499
500< *assert_notmatch()*
Bram Moolenaared997ad2019-07-21 16:42:00 +0200501assert_notmatch({pattern}, {actual} [, {msg}])
502 The opposite of `assert_match()`: add an error message to
503 |v:errors| when {pattern} matches {actual}.
504 Also see |assert-return|.
505
Bram Moolenaar24278d22019-08-16 21:49:22 +0200506 Can also be used as a |method|: >
507 getFile()->assert_notmatch('bar.*')
508
Bram Moolenaare49fbff2019-08-21 22:50:07 +0200509
Bram Moolenaared997ad2019-07-21 16:42:00 +0200510assert_report({msg}) *assert_report()*
Bram Moolenaar6aa57292021-08-14 21:25:52 +0200511 Report a test failure directly, using String {msg}.
Bram Moolenaared997ad2019-07-21 16:42:00 +0200512 Always returns one.
513
Bram Moolenaare49fbff2019-08-21 22:50:07 +0200514 Can also be used as a |method|: >
515 GetMessage()->assert_report()
516
517
Bram Moolenaared997ad2019-07-21 16:42:00 +0200518assert_true({actual} [, {msg}]) *assert_true()*
519 When {actual} is not true an error message is added to
520 |v:errors|, like with |assert_equal()|.
521 Also see |assert-return|.
522 A value is TRUE when it is a non-zero number. When {actual}
523 is not a number the assert fails.
524 When {msg} is omitted an error in the form "Expected True but
525 got {actual}" is produced.
526
Bram Moolenaar24278d22019-08-16 21:49:22 +0200527 Can also be used as a |method|: >
528 GetResult()->assert_true()
529<
Bram Moolenaared997ad2019-07-21 16:42:00 +0200530
531 vim:tw=78:ts=8:noet:ft=help:norl: