To: vim_dev@googlegroups.com Subject: Patch 8.0.0254 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.0254 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. Files: src/eval.c, src/testdir/test_assert.vim *** ../vim-8.0.0253/src/eval.c 2017-01-22 18:34:53.680030808 +0100 --- src/eval.c 2017-01-28 18:07:02.491425259 +0100 *************** *** 9240,9274 **** if (opt_msg_tv->v_type != VAR_UNKNOWN) { ! ga_concat(gap, tv2string(opt_msg_tv, &tofree, numbuf, 0)); vim_free(tofree); } else { ! 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); ! } 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); ! } } } --- 9240,9273 ---- if (opt_msg_tv->v_type != VAR_UNKNOWN) { ! 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) { ! 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(gap, (char_u *)" but got "); ! ga_concat_esc(gap, tv2string(got_tv, &tofree, numbuf, 0)); ! vim_free(tofree); } } *** ../vim-8.0.0253/src/testdir/test_assert.vim 2017-01-14 20:06:11.123087733 +0100 --- src/testdir/test_assert.vim 2017-01-28 18:05:40.799941919 +0100 *************** *** 121,126 **** --- 121,132 ---- 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 *** ../vim-8.0.0253/src/version.c 2017-01-28 17:11:09.724620245 +0100 --- src/version.c 2017-01-28 17:20:32.673057834 +0100 *************** *** 766,767 **** --- 766,769 ---- { /* Add new patch number below this line */ + /**/ + 254, /**/ -- FATHER: You only killed the bride's father - that's all - LAUNCELOT: Oh dear, I didn't really mean to... FATHER: Didn't mean to? You put your sword right through his head! LAUNCELOT: Gosh - Is he all right? "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///