comparison runtime/doc/testing.txt @ 17728:68ea27d26d5b v8.1.1861

patch 8.1.1861: only some assert functions can be used as a method commit https://github.com/vim/vim/commit/24278d2407dfbc8d93eb36593cdd006ff5d86f94 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Aug 16 21:49:22 2019 +0200 patch 8.1.1861: only some assert functions can be used as a method Problem: Only some assert functions can be used as a method. Solution: Allow using most assert functions as a method.
author Bram Moolenaar <Bram@vim.org>
date Fri, 16 Aug 2019 22:00:04 +0200
parents 072efa9ca875
children f2c2f9126a82
comparison
equal deleted inserted replaced
17727:145b465ffd33 17728:68ea27d26d5b
204 assert_beeps({cmd}) *assert_beeps()* 204 assert_beeps({cmd}) *assert_beeps()*
205 Run {cmd} and add an error message to |v:errors| if it does 205 Run {cmd} and add an error message to |v:errors| if it does
206 NOT produce a beep or visual bell. 206 NOT produce a beep or visual bell.
207 Also see |assert_fails()| and |assert-return|. 207 Also see |assert_fails()| and |assert-return|.
208 208
209 Can also be used as a |method|: >
210 GetCmd()->assert_beeps()
211 <
209 *assert_equal()* 212 *assert_equal()*
210 assert_equal({expected}, {actual} [, {msg}]) 213 assert_equal({expected}, {actual} [, {msg}])
211 When {expected} and {actual} are not equal an error message is 214 When {expected} and {actual} are not equal an error message is
212 added to |v:errors| and 1 is returned. Otherwise zero is 215 added to |v:errors| and 1 is returned. Otherwise zero is
213 returned |assert-return|. 216 returned |assert-return|.
253 NOT produce an error. Also see |assert-return|. 256 NOT produce an error. Also see |assert-return|.
254 When {error} is given it must match in |v:errmsg|. 257 When {error} is given it must match in |v:errmsg|.
255 Note that beeping is not considered an error, and some failing 258 Note that beeping is not considered an error, and some failing
256 commands only beep. Use |assert_beeps()| for those. 259 commands only beep. Use |assert_beeps()| for those.
257 260
261 Can also be used as a |method|: >
262 GetCmd()->assert_fails('E99:')
263
258 assert_false({actual} [, {msg}]) *assert_false()* 264 assert_false({actual} [, {msg}]) *assert_false()*
259 When {actual} is not false an error message is added to 265 When {actual} is not false an error message is added to
260 |v:errors|, like with |assert_equal()|. 266 |v:errors|, like with |assert_equal()|.
261 Also see |assert-return|. 267 Also see |assert-return|.
262 A value is false when it is zero. When {actual} is not a 268 A value is false when it is zero. When {actual} is not a
263 number the assert fails. 269 number the assert fails.
264 When {msg} is omitted an error in the form 270 When {msg} is omitted an error in the form
265 "Expected False but got {actual}" is produced. 271 "Expected False but got {actual}" is produced.
272
273 Can also be used as a |method|: >
274 GetResult()->assert_false()
266 275
267 assert_inrange({lower}, {upper}, {actual} [, {msg}]) *assert_inrange()* 276 assert_inrange({lower}, {upper}, {actual} [, {msg}]) *assert_inrange()*
268 This asserts number and |Float| values. When {actual} is lower 277 This asserts number and |Float| values. When {actual} is lower
269 than {lower} or higher than {upper} an error message is added 278 than {lower} or higher than {upper} an error message is added
270 to |v:errors|. Also see |assert-return|. 279 to |v:errors|. Also see |assert-return|.
290 Example: > 299 Example: >
291 assert_match('^f.*o$', 'foobar') 300 assert_match('^f.*o$', 'foobar')
292 < Will result in a string to be added to |v:errors|: 301 < Will result in a string to be added to |v:errors|:
293 test.vim line 12: Pattern '^f.*o$' does not match 'foobar' ~ 302 test.vim line 12: Pattern '^f.*o$' does not match 'foobar' ~
294 303
304 Can also be used as a |method|: >
305 getFile()->assert_match('foo.*')
306 <
295 *assert_notequal()* 307 *assert_notequal()*
296 assert_notequal({expected}, {actual} [, {msg}]) 308 assert_notequal({expected}, {actual} [, {msg}])
297 The opposite of `assert_equal()`: add an error message to 309 The opposite of `assert_equal()`: add an error message to
298 |v:errors| when {expected} and {actual} are equal. 310 |v:errors| when {expected} and {actual} are equal.
299 Also see |assert-return|. 311 Also see |assert-return|.
305 assert_notmatch({pattern}, {actual} [, {msg}]) 317 assert_notmatch({pattern}, {actual} [, {msg}])
306 The opposite of `assert_match()`: add an error message to 318 The opposite of `assert_match()`: add an error message to
307 |v:errors| when {pattern} matches {actual}. 319 |v:errors| when {pattern} matches {actual}.
308 Also see |assert-return|. 320 Also see |assert-return|.
309 321
322 Can also be used as a |method|: >
323 getFile()->assert_notmatch('bar.*')
324
310 assert_report({msg}) *assert_report()* 325 assert_report({msg}) *assert_report()*
311 Report a test failure directly, using {msg}. 326 Report a test failure directly, using {msg}.
312 Always returns one. 327 Always returns one.
313 328
314 assert_true({actual} [, {msg}]) *assert_true()* 329 assert_true({actual} [, {msg}]) *assert_true()*
318 A value is TRUE when it is a non-zero number. When {actual} 333 A value is TRUE when it is a non-zero number. When {actual}
319 is not a number the assert fails. 334 is not a number the assert fails.
320 When {msg} is omitted an error in the form "Expected True but 335 When {msg} is omitted an error in the form "Expected True but
321 got {actual}" is produced. 336 got {actual}" is produced.
322 337
338 Can also be used as a |method|: >
339 GetResult()->assert_true()
340 <
323 341
324 vim:tw=78:ts=8:noet:ft=help:norl: 342 vim:tw=78:ts=8:noet:ft=help:norl: