aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-11-05 14:17:06 +0800
committerGitHub <noreply@github.com>2022-11-05 14:17:06 +0800
commit86fe2c8d94d212af098002ce04c87fb73fdf9c52 (patch)
treef48445ed4f2cb998a56ef56709ef4a87c8411e0d /runtime
parenta86295cd5c2bf15a11eb05e226fd8e226154f6a6 (diff)
parent6956971ec790e636b16eeaec798c826515da9834 (diff)
downloadrneovim-86fe2c8d94d212af098002ce04c87fb73fdf9c52.tar.gz
rneovim-86fe2c8d94d212af098002ce04c87fb73fdf9c52.tar.bz2
rneovim-86fe2c8d94d212af098002ce04c87fb73fdf9c52.zip
Merge pull request #20941 from zeertzjq/vim-8.2.1183
vim-patch:8.2.{partial:1183,1184,1199,1479,1484,1631,1632}: assert_fails() patches
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/testing.txt38
1 files changed, 33 insertions, 5 deletions
diff --git a/runtime/doc/testing.txt b/runtime/doc/testing.txt
index f4375c3363..56e0dad656 100644
--- a/runtime/doc/testing.txt
+++ b/runtime/doc/testing.txt
@@ -98,18 +98,46 @@ assert_exception({error} [, {msg}]) *assert_exception()*
catch
call assert_exception('E492:')
endtry
-
-assert_fails({cmd} [, {error} [, {msg}]]) *assert_fails()*
+<
+ *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. Also see |assert-return|.
- When {error} is given it must match in |v:errmsg|.
+ 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:". >
+ 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'])
+< 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: >
+ 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.
+
+ 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.
+
+ 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.
Can also be used as a |method|: >
GetCmd()->assert_fails('E99:')
-assert_false({actual} [, {msg}]) *assert_false()*
+assert_false({actual} [, {msg}]) *assert_false()*
When {actual} is not false an error message is added to
|v:errors|, like with |assert_equal()|.
Also see |assert-return|.