summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/eval.c47
-rw-r--r--src/testdir/test_assert.vim6
-rw-r--r--src/version.c2
3 files changed, 31 insertions, 24 deletions
diff --git a/src/eval.c b/src/eval.c
index 5846936cc..a5ae4f815 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -9240,35 +9240,34 @@ 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 *)": ");
}
+
+ if (atype == ASSERT_MATCH || atype == ASSERT_NOTMATCH)
+ ga_concat(gap, (char_u *)"Pattern ");
+ else if (atype == ASSERT_NOTEQUAL)
+ ga_concat(gap, (char_u *)"Expected not equal to ");
else
+ ga_concat(gap, (char_u *)"Expected ");
+ if (exp_str == NULL)
{
- if (atype == ASSERT_MATCH || atype == ASSERT_NOTMATCH)
- ga_concat(gap, (char_u *)"Pattern ");
- else if (atype == ASSERT_NOTEQUAL)
- ga_concat(gap, (char_u *)"Expected not equal to ");
- else
- ga_concat(gap, (char_u *)"Expected ");
- if (exp_str == NULL)
- {
- ga_concat_esc(gap, tv2string(exp_tv, &tofree, numbuf, 0));
- vim_free(tofree);
- }
+ ga_concat_esc(gap, tv2string(exp_tv, &tofree, numbuf, 0));
+ vim_free(tofree);
+ }
+ else
+ ga_concat_esc(gap, exp_str);
+ if (atype != ASSERT_NOTEQUAL)
+ {
+ if (atype == ASSERT_MATCH)
+ ga_concat(gap, (char_u *)" does not match ");
+ else if (atype == ASSERT_NOTMATCH)
+ ga_concat(gap, (char_u *)" does match ");
else
- ga_concat_esc(gap, exp_str);
- if (atype != ASSERT_NOTEQUAL)
- {
- if (atype == ASSERT_MATCH)
- ga_concat(gap, (char_u *)" does not match ");
- else if (atype == ASSERT_NOTMATCH)
- ga_concat(gap, (char_u *)" does match ");
- else
- ga_concat(gap, (char_u *)" but got ");
- ga_concat_esc(gap, tv2string(got_tv, &tofree, numbuf, 0));
- vim_free(tofree);
- }
+ ga_concat(gap, (char_u *)" but got ");
+ ga_concat_esc(gap, tv2string(got_tv, &tofree, numbuf, 0));
+ vim_free(tofree);
}
}
diff --git a/src/testdir/test_assert.vim b/src/testdir/test_assert.vim
index 8c54bddb8..986f0d9a7 100644
--- a/src/testdir/test_assert.vim
+++ b/src/testdir/test_assert.vim
@@ -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
diff --git a/src/version.c b/src/version.c
index 19ba72e15..e66e1b97c 100644
--- a/src/version.c
+++ b/src/version.c
@@ -765,6 +765,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 254,
+/**/
253,
/**/
252,