mirror of
https://github.com/vim/vim
synced 2025-07-16 01:01:58 +00:00
runtime(doc): fix more inconsistencies in assert function docs
related: https://github.com/vim/vim/pull/15280#issuecomment-2233771449 closes: #15285 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
b5d6b5caac
commit
eb6d733bef
@ -1,4 +1,4 @@
|
||||
*testing.txt* For Vim version 9.1. Last change: 2024 Jul 17
|
||||
*testing.txt* For Vim version 9.1. Last change: 2024 Jul 18
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@ -506,8 +506,8 @@ assert_equal({expected}, {actual} [, {msg}])
|
||||
added to |v:errors| and 1 is returned. Otherwise zero is
|
||||
returned. |assert-return|
|
||||
The error is in the form "Expected {expected} but got
|
||||
{actual}". When {msg} is present it is prefixed to that, along
|
||||
with the location of the assert when run from a script.
|
||||
{actual}". When {msg} is present it is prefixed to that,
|
||||
along with the location of the assert when run from a script.
|
||||
|
||||
There is no automatic conversion, the String "4" is different
|
||||
from the Number 4. And the number 4 is different from the
|
||||
@ -562,19 +562,19 @@ assert_fails({cmd} [, {error} [, {msg} [, {lnum} [, {context}]]]])
|
||||
When {error} is a string it must be found literally in the
|
||||
first reported error. Most often this will be the error code,
|
||||
including the colon, e.g. "E123:". >
|
||||
assert_fails('bad cmd', 'E987:')
|
||||
call assert_fails('bad cmd', 'E987:')
|
||||
<
|
||||
When {error} is a |List| with one or two strings, these are
|
||||
used as patterns. The first pattern is matched against the
|
||||
first reported error: >
|
||||
assert_fails('cmd', ['E987:.*expected bool'])
|
||||
call assert_fails('cmd', ['E987:.*expected bool'])
|
||||
< The second pattern, if present, is matched against the last
|
||||
reported error.
|
||||
If there is only one error then both patterns must match. This
|
||||
can be used to check that there is only one error.
|
||||
To only match the last error use an empty string for the first
|
||||
error: >
|
||||
assert_fails('cmd', ['', 'E987:'])
|
||||
call assert_fails('cmd', ['', 'E987:'])
|
||||
<
|
||||
If {msg} is empty then it is not used. Do this to get the
|
||||
default message when passing the {lnum} argument.
|
||||
@ -600,8 +600,8 @@ assert_false({actual} [, {msg}]) *assert_false()*
|
||||
When {actual} is not false an error message is added to
|
||||
|v:errors|, like with |assert_equal()|.
|
||||
The error is in the form "Expected False but got {actual}".
|
||||
When {msg} is present it is prepended to that, along
|
||||
with the location of the assert when run from a script.
|
||||
When {msg} is present it is prefixed to that, along with the
|
||||
location of the assert when run from a script.
|
||||
Also see |assert-return|.
|
||||
|
||||
A value is false when it is zero. When {actual} is not a
|
||||
@ -639,9 +639,9 @@ assert_match({pattern}, {actual} [, {msg}])
|
||||
Use both to match the whole text.
|
||||
|
||||
Example: >
|
||||
assert_match('^f.*o$', 'foobar')
|
||||
call assert_match('^f.*o$', 'foobar')
|
||||
< Will result in a string to be added to |v:errors|:
|
||||
test.vim line 12: Pattern '^f.*o$' does not match 'foobar' ~
|
||||
test.vim line 12: Pattern '^f.*o$' does not match 'foobar' ~
|
||||
|
||||
Can also be used as a |method|: >
|
||||
getFile()->assert_match('foo.*')
|
||||
@ -696,8 +696,8 @@ assert_true({actual} [, {msg}]) *assert_true()*
|
||||
Also see |assert-return|.
|
||||
A value is TRUE when it is a non-zero number. When {actual}
|
||||
is not a number the assert fails.
|
||||
When {msg} is given it precedes the default message, along
|
||||
with the location of the assert when run from a script.
|
||||
When {msg} is given it is prefixed to the default message,
|
||||
along with the location of the assert when run from a script.
|
||||
|
||||
Can also be used as a |method|: >
|
||||
GetResult()->assert_true()
|
||||
|
Reference in New Issue
Block a user