diff src/eval.c @ 13272:abaebba89fd4 v8.0.1510

patch 8.0.1510: cannot test if a command causes a beep commit https://github.com/vim/vim/commit/b48e96f61c87a64e38e3ac50732c92a84a4833b8 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Feb 13 12:26:14 2018 +0100 patch 8.0.1510: cannot test if a command causes a beep Problem: Cannot test if a command causes a beep. Solution: Add assert_beeps().
author Christian Brabandt <cb@256bit.org>
date Tue, 13 Feb 2018 12:30:07 +0100
parents 69278c25429d
children f4b4162264b1
line wrap: on
line diff
--- a/src/eval.c
+++ b/src/eval.c
@@ -8942,6 +8942,29 @@ assert_exception(typval_T *argvars)
 }
 
     void
+assert_beeps(typval_T *argvars)
+{
+    char_u	*cmd = get_tv_string_chk(&argvars[0]);
+    garray_T	ga;
+
+    called_vim_beep = FALSE;
+    suppress_errthrow = TRUE;
+    emsg_silent = FALSE;
+    do_cmdline_cmd(cmd);
+    if (!called_vim_beep)
+    {
+	prepare_assert_error(&ga);
+	ga_concat(&ga, (char_u *)"command did not beep: ");
+	ga_concat(&ga, cmd);
+	assert_error(&ga);
+	ga_clear(&ga);
+    }
+
+    suppress_errthrow = FALSE;
+    emsg_on_display = FALSE;
+}
+
+    void
 assert_fails(typval_T *argvars)
 {
     char_u	*cmd = get_tv_string_chk(&argvars[0]);