char_u *cmd = get_tv_string_chk(&argvars[0]);
garray_T ga;
int ret = 0;
+ char_u numbuf[NUMBUFLEN];
+ char_u *tofree;
called_emsg = FALSE;
suppress_errthrow = TRUE;
{
prepare_assert_error(&ga);
ga_concat(&ga, (char_u *)"command did not fail: ");
- ga_concat(&ga, cmd);
+ if (argvars[1].v_type != VAR_UNKNOWN
+ && argvars[2].v_type != VAR_UNKNOWN)
+ {
+ ga_concat(&ga, echo_string(&argvars[2], &tofree, numbuf, 0));
+ vim_free(tofree);
+ }
+ else
+ ga_concat(&ga, cmd);
assert_error(&ga);
ga_clear(&ga);
ret = 1;
{"assert_equal", 2, 3, f_assert_equal},
{"assert_equalfile", 2, 2, f_assert_equalfile},
{"assert_exception", 1, 2, f_assert_exception},
- {"assert_fails", 1, 2, f_assert_fails},
+ {"assert_fails", 1, 3, f_assert_fails},
{"assert_false", 1, 2, f_assert_false},
{"assert_inrange", 3, 4, f_assert_inrange},
{"assert_match", 2, 3, f_assert_match},
}
/*
- * "assert_fails(cmd [, error])" function
+ * "assert_fails(cmd [, error[, msg]])" function
*/
static void
f_assert_fails(typval_T *argvars, typval_T *rettv)
call assert_equal(1, assert_fails('xxx', {}))
call assert_match("Expected {} but got 'E731:", v:errors[0])
call remove(v:errors, 0)
+
+ call assert_equal(1, assert_fails('xxx', {}, 'stupid'))
+ call assert_match("stupid: Expected {} but got 'E731:", v:errors[0])
+ call remove(v:errors, 0)
+
+ call assert_equal(1, assert_fails('echo', '', 'echo command'))
+ call assert_match("command did not fail: echo command", v:errors[0])
+ call remove(v:errors, 0)
endfunc
func Test_assert_beeps()