Skip to content

Commit 5869cf0

Browse files
committed
patch 8.0.0186: confusing error message from assert_notequal()
Problem: The error message from assert_notequal() is confusing. Solution: Only mention the expected value.
1 parent fad609d commit 5869cf0

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

src/eval.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9256,6 +9256,8 @@ fill_assert_error(
92569256
{
92579257
if (atype == ASSERT_MATCH || atype == ASSERT_NOTMATCH)
92589258
ga_concat(gap, (char_u *)"Pattern ");
9259+
else if (atype == ASSERT_NOTEQUAL)
9260+
ga_concat(gap, (char_u *)"Expected not equal to ");
92599261
else
92609262
ga_concat(gap, (char_u *)"Expected ");
92619263
if (exp_str == NULL)
@@ -9265,16 +9267,17 @@ fill_assert_error(
92659267
}
92669268
else
92679269
ga_concat_esc(gap, exp_str);
9268-
if (atype == ASSERT_MATCH)
9269-
ga_concat(gap, (char_u *)" does not match ");
9270-
else if (atype == ASSERT_NOTMATCH)
9271-
ga_concat(gap, (char_u *)" does match ");
9272-
else if (atype == ASSERT_NOTEQUAL)
9273-
ga_concat(gap, (char_u *)" differs from ");
9274-
else
9275-
ga_concat(gap, (char_u *)" but got ");
9276-
ga_concat_esc(gap, tv2string(got_tv, &tofree, numbuf, 0));
9277-
vim_free(tofree);
9270+
if (atype != ASSERT_NOTEQUAL)
9271+
{
9272+
if (atype == ASSERT_MATCH)
9273+
ga_concat(gap, (char_u *)" does not match ");
9274+
else if (atype == ASSERT_NOTMATCH)
9275+
ga_concat(gap, (char_u *)" does match ");
9276+
else
9277+
ga_concat(gap, (char_u *)" but got ");
9278+
ga_concat_esc(gap, tv2string(got_tv, &tofree, numbuf, 0));
9279+
vim_free(tofree);
9280+
}
92789281
}
92799282
}
92809283

src/testdir/test_assert.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func Test_assert_notequal()
3232
call assert_notequal([1, 2, 3], s)
3333

3434
call assert_notequal('foo', s)
35-
call assert_match("Expected 'foo' differs from 'foo'", v:errors[0])
35+
call assert_match("Expected not equal to 'foo'", v:errors[0])
3636
call remove(v:errors, 0)
3737
endfunc
3838

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
186,
767769
/**/
768770
185,
769771
/**/

0 commit comments

Comments
 (0)