diff src/testing.c @ 18949:5c405689da3e v8.2.0035

patch 8.2.0035: saving and restoring called_emsg is clumsy Commit: https://github.com/vim/vim/commit/53989554a44caca0964376d60297f08ec257c53c Author: Bram Moolenaar <Bram@vim.org> Date: Mon Dec 23 22:59:18 2019 +0100 patch 8.2.0035: saving and restoring called_emsg is clumsy Problem: Saving and restoring called_emsg is clumsy. Solution: Count the number of error messages.
author Bram Moolenaar <Bram@vim.org>
date Mon, 23 Dec 2019 23:00:03 +0100
parents 7e7ec935e7c8
children 847cc7932c42
line wrap: on
line diff
--- a/src/testing.c
+++ b/src/testing.c
@@ -424,15 +424,15 @@ f_assert_fails(typval_T *argvars, typval
     char_u	*cmd = tv_get_string_chk(&argvars[0]);
     garray_T	ga;
     int		save_trylevel = trylevel;
+    int		called_emsg_before = called_emsg;
 
     // trylevel must be zero for a ":throw" command to be considered failed
     trylevel = 0;
-    called_emsg = FALSE;
     suppress_errthrow = TRUE;
     emsg_silent = TRUE;
 
     do_cmdline_cmd(cmd);
-    if (!called_emsg)
+    if (called_emsg == called_emsg_before)
     {
 	prepare_assert_error(&ga);
 	ga_concat(&ga, (char_u *)"command did not fail: ");
@@ -461,7 +461,6 @@ f_assert_fails(typval_T *argvars, typval
     }
 
     trylevel = save_trylevel;
-    called_emsg = FALSE;
     suppress_errthrow = FALSE;
     emsg_silent = FALSE;
     emsg_on_display = FALSE;