diff options
| -rw-r--r-- | runtime/doc/eval.txt | 8 | ||||
| -rw-r--r-- | src/nvim/eval.c | 6 | ||||
| -rw-r--r-- | src/nvim/eval.lua | 2 | ||||
| -rw-r--r-- | src/nvim/eval/funcs.c | 2 | ||||
| -rw-r--r-- | src/nvim/testdir/test_assert.vim | 4 | 
5 files changed, 16 insertions, 6 deletions
| diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 1c1baa943a..f9a5d36205 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -2019,11 +2019,12 @@ argidx()			Number	current index in the argument list  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}) -				Number	assert file contents is equal +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}])	Number	assert {cmd} fails @@ -2039,7 +2040,6 @@ assert_notmatch({pat}, {text} [, {msg}])  				Number	assert {pat} not matches {text}  assert_report({msg})		Number	report a test failure  assert_true({actual} [, {msg}])	Number	assert {actual} is true -asin({expr})			Float	arc sine of {expr}  atan({expr})			Float	arc tangent of {expr}  atan2({expr}, {expr})		Float   arc tangent of {expr1} / {expr2}  browse({save}, {title}, {initdir}, {default}) @@ -2630,7 +2630,7 @@ assert_equal({expected}, {actual}, [, {msg}])  	test.vim line 12: Expected 'foo' but got 'bar' ~  							*assert_equalfile()* -assert_equalfile({fname-one}, {fname-two}) +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|. diff --git a/src/nvim/eval.c b/src/nvim/eval.c index db9d0d987c..12c904bc1b 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -5739,6 +5739,12 @@ int assert_equalfile(typval_T *argvars)    }    if (IObuff[0] != NUL) {      prepare_assert_error(&ga); +    if (argvars[2].v_type != VAR_UNKNOWN) { +      char *const tofree = encode_tv2echo(&argvars[2], NULL); +      ga_concat(&ga, (char_u *)tofree); +      xfree(tofree); +      ga_concat(&ga, (char_u *)": "); +    }      ga_concat(&ga, IObuff);      assert_error(&ga);      ga_clear(&ga); diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 51872a7ba8..d20e381481 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -28,7 +28,7 @@ return {      asin={args=1, func="float_op_wrapper", data="&asin"},  -- WJMc      assert_beeps={args={1, 2}},      assert_equal={args={2, 3}}, -    assert_equalfile={args=2}, +    assert_equalfile={args={2, 3}},      assert_exception={args={1, 2}},      assert_fails={args={1, 3}},      assert_false={args={1, 2}}, diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 99014d1a09..831167a489 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -415,7 +415,7 @@ static void f_assert_equal(typval_T *argvars, typval_T *rettv, FunPtr fptr)    rettv->vval.v_number = assert_equal_common(argvars, ASSERT_EQUAL);  } -// "assert_equalfile(fname-one, fname-two)" function +// "assert_equalfile(fname-one, fname-two[, msg])" function  static void f_assert_equalfile(typval_T *argvars, typval_T *rettv, FunPtr fptr)  {    rettv->vval.v_number = assert_equalfile(argvars); diff --git a/src/nvim/testdir/test_assert.vim b/src/nvim/testdir/test_assert.vim index 4cc90eca7a..86993e0acc 100644 --- a/src/nvim/testdir/test_assert.vim +++ b/src/nvim/testdir/test_assert.vim @@ -31,6 +31,10 @@ func Test_assert_equalfile()    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 | 
