To: vim_dev@googlegroups.com Subject: Patch 8.2.0893 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0893 Problem: Assert_equalfile() does not take a third argument. Solution: Implement the third argument. (Gary Johnson) Files: runtime/doc/eval.txt, runtime/doc/testing.txt, src/evalfunc.c, src/testdir/test_assert.vim, src/testing.c *** ../vim-8.2.0892/runtime/doc/eval.txt 2020-06-02 21:38:18.719856309 +0200 --- runtime/doc/eval.txt 2020-06-03 19:49:34.916602986 +0200 *************** *** 2318,2328 **** arglistid([{winnr} [, {tabnr}]]) Number argument list id argv({nr} [, {winid}]) String {nr} entry of the argument list argv([-1, {winid}]) List the argument list assert_beeps({cmd}) Number assert {cmd} causes a beep assert_equal({exp}, {act} [, {msg}]) Number assert {exp} is equal to {act} ! assert_equalfile({fname-one}, {fname-two}) ! Number assert file contents is equal assert_exception({error} [, {msg}]) Number assert {error} is in v:exception assert_fails({cmd} [, {error} [, {msg}]]) --- 2324,2335 ---- arglistid([{winnr} [, {tabnr}]]) Number argument list id argv({nr} [, {winid}]) String {nr} entry of the argument list argv([-1, {winid}]) List the argument list + asin({expr}) Float arc sine of {expr} assert_beeps({cmd}) Number assert {cmd} causes a beep assert_equal({exp}, {act} [, {msg}]) Number assert {exp} is equal to {act} ! assert_equalfile({fname-one}, {fname-two} [, {msg}]) ! Number assert file contents are equal assert_exception({error} [, {msg}]) Number assert {error} is in v:exception assert_fails({cmd} [, {error} [, {msg}]]) *** ../vim-8.2.0892/runtime/doc/testing.txt 2020-04-01 22:10:56.432201238 +0200 --- runtime/doc/testing.txt 2020-06-03 19:54:10.403425839 +0200 *************** *** 263,271 **** Can also be used as a |method|: > mylist->assert_equal([1, 2, 3]) - < *assert_equalfile()* ! assert_equalfile({fname-one}, {fname-two}) When the files {fname-one} and {fname-two} do not contain exactly the same text an error message is added to |v:errors|. Also see |assert-return|. --- 263,270 ---- Can also be used as a |method|: > mylist->assert_equal([1, 2, 3]) < *assert_equalfile()* ! assert_equalfile({fname-one}, {fname-two} [, {msg}]) When the files {fname-one} and {fname-two} do not contain exactly the same text an error message is added to |v:errors|. Also see |assert-return|. *************** *** 276,282 **** Can also be used as a |method|: > GetLog()->assert_equalfile('expected.log') - assert_exception({error} [, {msg}]) *assert_exception()* When v:exception does not contain the string {error} an error message is added to |v:errors|. Also see |assert-return|. --- 275,280 ---- *** ../vim-8.2.0892/src/evalfunc.c 2020-06-02 21:38:18.719856309 +0200 --- src/evalfunc.c 2020-06-03 19:49:34.916602986 +0200 *************** *** 419,425 **** {"asin", 1, 1, FEARG_1, ret_float, FLOAT_FUNC(f_asin)}, {"assert_beeps", 1, 2, FEARG_1, ret_number, f_assert_beeps}, {"assert_equal", 2, 3, FEARG_2, ret_number, f_assert_equal}, ! {"assert_equalfile", 2, 2, FEARG_1, ret_number, f_assert_equalfile}, {"assert_exception", 1, 2, 0, ret_number, f_assert_exception}, {"assert_fails", 1, 3, FEARG_1, ret_number, f_assert_fails}, {"assert_false", 1, 2, FEARG_1, ret_number, f_assert_false}, --- 419,425 ---- {"asin", 1, 1, FEARG_1, ret_float, FLOAT_FUNC(f_asin)}, {"assert_beeps", 1, 2, FEARG_1, ret_number, f_assert_beeps}, {"assert_equal", 2, 3, FEARG_2, ret_number, f_assert_equal}, ! {"assert_equalfile", 2, 3, FEARG_1, ret_number, f_assert_equalfile}, {"assert_exception", 1, 2, 0, ret_number, f_assert_exception}, {"assert_fails", 1, 3, FEARG_1, ret_number, f_assert_fails}, {"assert_false", 1, 2, FEARG_1, ret_number, f_assert_false}, *** ../vim-8.2.0892/src/testdir/test_assert.vim 2020-04-09 21:33:19.166717351 +0200 --- src/testdir/test_assert.vim 2020-06-03 19:49:34.920602968 +0200 *************** *** 81,86 **** --- 81,90 ---- call assert_match("difference at byte 4", v:errors[0]) call remove(v:errors, 0) + call assert_equal(1, assert_equalfile('Xone', 'Xtwo', 'a message')) + call assert_match("a message: difference at byte 4", v:errors[0]) + call remove(v:errors, 0) + call delete('Xone') call delete('Xtwo') endfunc *** ../vim-8.2.0892/src/testing.c 2020-04-27 22:47:45.186176148 +0200 --- src/testing.c 2020-06-03 19:49:34.920602968 +0200 *************** *** 362,367 **** --- 362,376 ---- if (IObuff[0] != NUL) { prepare_assert_error(&ga); + if (argvars[2].v_type != VAR_UNKNOWN) + { + char_u numbuf[NUMBUFLEN]; + char_u *tofree; + + ga_concat(&ga, echo_string(&argvars[2], &tofree, numbuf, 0)); + vim_free(tofree); + ga_concat(&ga, (char_u *)": "); + } ga_concat(&ga, IObuff); assert_error(&ga); ga_clear(&ga); *************** *** 371,377 **** } /* ! * "assert_equalfile(fname-one, fname-two)" function */ void f_assert_equalfile(typval_T *argvars, typval_T *rettv) --- 380,386 ---- } /* ! * "assert_equalfile(fname-one, fname-two[, msg])" function */ void f_assert_equalfile(typval_T *argvars, typval_T *rettv) *** ../vim-8.2.0892/src/version.c 2020-06-03 18:55:35.961570633 +0200 --- src/version.c 2020-06-03 19:50:44.488299083 +0200 *************** *** 748,749 **** --- 748,751 ---- { /* Add new patch number below this line */ + /**/ + 893, /**/ -- hundred-and-one symptoms of being an internet addict: 269. You wonder how you can make your dustbin produce Sesame Street's Oscar's the Garbage Monster song when you empty it. /// 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 ///