0
0
mirror of https://github.com/vim/vim.git synced 2025-09-29 04:34:16 -04:00

patch 8.0.0254: error message of assert functions is sometimes incomplete

Problem:    When using an assert function one can either specify a message or
            get a message about what failed, not both.
Solution:   Concatenate the error with the message.
This commit is contained in:
Bram Moolenaar
2017-01-28 18:08:12 +01:00
parent 36ae89c550
commit c7b831ca15
3 changed files with 31 additions and 24 deletions

View File

@@ -9240,11 +9240,11 @@ fill_assert_error(
if (opt_msg_tv->v_type != VAR_UNKNOWN)
{
ga_concat(gap, tv2string(opt_msg_tv, &tofree, numbuf, 0));
ga_concat(gap, echo_string(opt_msg_tv, &tofree, numbuf, 0));
vim_free(tofree);
ga_concat(gap, (char_u *)": ");
}
else
{
if (atype == ASSERT_MATCH || atype == ASSERT_NOTMATCH)
ga_concat(gap, (char_u *)"Pattern ");
else if (atype == ASSERT_NOTEQUAL)
@@ -9269,7 +9269,6 @@ fill_assert_error(
ga_concat_esc(gap, tv2string(got_tv, &tofree, numbuf, 0));
vim_free(tofree);
}
}
}

View File

@@ -121,6 +121,12 @@ func Test_assert_inrange()
call assert_fails('call assert_inrange(1, 1)', 'E119:')
endfunc
func Test_assert_with_msg()
call assert_equal('foo', 'bar', 'testing')
call assert_match("testing: Expected 'foo' but got 'bar'", v:errors[0])
call remove(v:errors, 0)
endfunc
func Test_user_is_happy()
smile
sleep 300m

View File

@@ -764,6 +764,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
254,
/**/
253,
/**/