vim-patch:8.0.0186 (#7154)

Problem:    The error message from assert_notequal() is confusing.
Solution:   Only mention the expected value.

5869cf060e
This commit is contained in:
KunMing Xie 2017-09-10 18:52:43 +08:00 committed by Justin M. Keyes
parent 713a957e9c
commit ceade2fe53
3 changed files with 15 additions and 13 deletions

View File

@ -6747,6 +6747,8 @@ static void fill_assert_error(garray_T *gap, typval_T *opt_msg_tv,
} else { } else {
if (atype == ASSERT_MATCH || atype == ASSERT_NOTMATCH) { if (atype == ASSERT_MATCH || atype == ASSERT_NOTMATCH) {
ga_concat(gap, (char_u *)"Pattern "); ga_concat(gap, (char_u *)"Pattern ");
} else if (atype == ASSERT_NOTEQUAL) {
ga_concat(gap, (char_u *)"Expected not equal to ");
} else { } else {
ga_concat(gap, (char_u *)"Expected "); ga_concat(gap, (char_u *)"Expected ");
} }
@ -6757,18 +6759,18 @@ static void fill_assert_error(garray_T *gap, typval_T *opt_msg_tv,
} else { } else {
ga_concat(gap, exp_str); ga_concat(gap, exp_str);
} }
tofree = (char_u *)encode_tv2string(got_tv, NULL); if (atype != ASSERT_NOTEQUAL) {
if (atype == ASSERT_MATCH) { if (atype == ASSERT_MATCH) {
ga_concat(gap, (char_u *)" does not match "); ga_concat(gap, (char_u *)" does not match ");
} else if (atype == ASSERT_NOTMATCH) { } else if (atype == ASSERT_NOTMATCH) {
ga_concat(gap, (char_u *)" does match "); ga_concat(gap, (char_u *)" does match ");
} else if (atype == ASSERT_NOTEQUAL) { } else {
ga_concat(gap, (char_u *)" differs from "); ga_concat(gap, (char_u *)" but got ");
} else { }
ga_concat(gap, (char_u *)" but got "); tofree = (char_u *)encode_tv2string(got_tv, NULL);
ga_concat(gap, tofree);
xfree(tofree);
} }
ga_concat(gap, tofree);
xfree(tofree);
} }
} }

View File

@ -766,7 +766,7 @@ static const int included_patches[] = {
// 189, // 189,
188, 188,
// 187 NA // 187 NA
// 186, 186,
// 185, // 185,
// 184, // 184,
// 183, // 183,

View File

@ -89,7 +89,7 @@ describe('assert function:', function()
it('should change v:errors when expected is equal to actual', function() it('should change v:errors when expected is equal to actual', function()
call('assert_notequal', 'foo', 'foo') call('assert_notequal', 'foo', 'foo')
expected_errors({"Expected 'foo' differs from 'foo'"}) expected_errors({"Expected not equal to 'foo'"})
end) end)
end) end)