diff --git a/src/nvim/testing.c b/src/nvim/testing.c index 92747822b4..d9c376dd6a 100644 --- a/src/nvim/testing.c +++ b/src/nvim/testing.c @@ -522,14 +522,13 @@ void f_assert_fails(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) return; } - const char *const cmd = tv_get_string_chk(&argvars[0]); - // trylevel must be zero for a ":throw" command to be considered failed trylevel = 0; suppress_errthrow = true; in_assert_fails = true; no_wait_return++; + const char *const cmd = tv_get_string_chk(&argvars[0]); do_cmdline_cmd(cmd); // reset here for any errors reported below diff --git a/test/old/testdir/test_assert.vim b/test/old/testdir/test_assert.vim index 9b65e36e16..e20084515e 100644 --- a/test/old/testdir/test_assert.vim +++ b/test/old/testdir/test_assert.vim @@ -327,6 +327,12 @@ func Test_assert_fails_in_try_block() endtry endfunc +func Test_assert_fails_in_timer() + " should not cause a hit-enter prompt, which isn't actually checked here + call timer_start(0, {-> assert_fails('call', 'E471:')}) + sleep 10m +endfunc + func Test_assert_beeps() new call assert_equal(0, assert_beeps('normal h'))