the following to |v:errors|:
test.vim line 12: baz: Expected 'foo' but got 'bar' ~
Parameters: ~
• {expected} (`any`)
• {actual} (`any`)
• {msg} (`any?`)
Return: ~
(`0|1`)
assert_equalfile({fname_one}, {fname_two}) *assert_equalfile()*
When the files {fname_one} and {fname_two} do not contain
exactly the same text an error message is added to |v:errors|.
Also see |assert-return|.
When {fname_one} or {fname_two} does not exist the error will
mention that.
Parameters: ~
• {fname_one} (`string`)
• {fname_two} (`string`)
Return: ~
(`0|1`)
assert_exception({error} [, {msg}]) *assert_exception()*
When v:exception does not contain the string {error} an error
message is added to |v:errors|. Also see |assert-return|.
This can be used to assert that a command throws an exception.
Using the error number, followed by a colon, avoids problems
with translations: >vim
try
commandthatfails
call assert_false(1, 'command should have failed')
catch
call assert_exception('E492:')
endtry
<
Parameters: ~
• {error} (`any`)
• {msg} (`any?`)
Return: ~
(`0|1`)
*assert_fails()*
assert_fails({cmd} [, {error} [, {msg} [, {lnum} [, {context}]]]])
Run {cmd} and add an error message to |v:errors| if it does
NOT produce an error or when {error} is not found in the
error message. Also see |assert-return|.
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:". >vim
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: >vim
call assert_fails('cmd', ['E987:.*expected bool'])
< The second pattern, if present, is matched against the last
reported error. To only match the last error use an empty
string for the first error: >vim
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.
*E1115*
When {lnum} is present and not negative, and the {error}
argument is present and matches, then this is compared with
the line number at which the error was reported. That can be
the line number in a function or in a script.
*E1116*
When {context} is present it is used as a pattern and matched
against the context (script name or function name) where
{lnum} is located in.
Note that beeping is not considered an error, and some failing
commands only beep. Use |assert_beeps()| for those.
Parameters: ~
• {cmd} (`string`)
• {error} (`any?`)
• {msg} (`any?`)
• {lnum} (`integer?`)
• {context} (`any?`)
Return: ~
(`0|1`)
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 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
number the assert fails.
Parameters: ~
• {actual} (`any`)
• {msg} (`any?`)
Return: ~
(`0|1`)
assert_inrange({lower}, {upper}, {actual} [, {msg}]) *assert_inrange()*
This asserts number