summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-07-11 22:14:59 +0200
committerBram Moolenaar <Bram@vim.org>2020-07-11 22:14:59 +0200
commit9b7bf9e98f06ece595fed7a3ff53ecce89797a53 (patch)
tree4a9b2cd5ac2f18f3c2c017530ab95f6878f1e757 /runtime
parent914e7eaa67f8d816e15fb4a1180e6bece88d9742 (diff)
patch 8.2.1183: assert_fails() checks the last error messagev8.2.1183
Problem: assert_fails() checks the last error message. Solution: Check the first error, it is more relevant. Fix all the tests that rely on the old behavior.
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/testing.txt19
1 files changed, 17 insertions, 2 deletions
diff --git a/runtime/doc/testing.txt b/runtime/doc/testing.txt
index b7825b90f9..53ed0818e4 100644
--- a/runtime/doc/testing.txt
+++ b/runtime/doc/testing.txt
@@ -295,8 +295,23 @@ assert_exception({error} [, {msg}]) *assert_exception()*
assert_fails({cmd} [, {error} [, {msg}]]) *assert_fails()*
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:'])
+<
Note that beeping is not considered an error, and some failing
commands only beep. Use |assert_beeps()| for those.