From b48e96f61c87a64e38e3ac50732c92a84a4833b8 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 13 Feb 2018 12:26:14 +0100 Subject: 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(). --- src/eval.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/eval.c') diff --git a/src/eval.c b/src/eval.c index 2c93e4ec4b..b1f7a86061 100644 --- a/src/eval.c +++ b/src/eval.c @@ -8941,6 +8941,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) { -- cgit v1.2.3