mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #4821 from jamessan/vim-7.4.1096
vim-patch:7.4.1096,7.4.1567
This commit is contained in:
commit
1d63672c77
@ -1789,6 +1789,7 @@ argv({nr}) String {nr} entry of the argument list
|
|||||||
argv() List the argument list
|
argv() List the argument list
|
||||||
assert_equal({exp}, {act} [, {msg}]) none assert {exp} equals {act}
|
assert_equal({exp}, {act} [, {msg}]) none assert {exp} equals {act}
|
||||||
assert_exception({error} [, {msg}]) none assert {error} is in v:exception
|
assert_exception({error} [, {msg}]) none assert {error} is in v:exception
|
||||||
|
assert_fails( {cmd} [, {error}]) none assert {cmd} fails
|
||||||
assert_false({actual} [, {msg}]) none assert {actual} is false
|
assert_false({actual} [, {msg}]) none assert {actual} is false
|
||||||
assert_true({actual} [, {msg}]) none assert {actual} is true
|
assert_true({actual} [, {msg}]) none assert {actual} is true
|
||||||
asin({expr}) Float arc sine of {expr}
|
asin({expr}) Float arc sine of {expr}
|
||||||
@ -2263,6 +2264,11 @@ assert_exception({error} [, {msg}]) *assert_exception()*
|
|||||||
call assert_exception('E492:')
|
call assert_exception('E492:')
|
||||||
endtry
|
endtry
|
||||||
|
|
||||||
|
assert_fails({cmd} [, {error}]) *assert_fails()*
|
||||||
|
Run {cmd} and add an error message to |v:errors| if it does
|
||||||
|
NOT produce an error.
|
||||||
|
When {error} is given it must match |v:errmsg|.
|
||||||
|
|
||||||
assert_false({actual} [, {msg}]) *assert_false()*
|
assert_false({actual} [, {msg}]) *assert_false()*
|
||||||
When {actual} is not false an error message is added to
|
When {actual} is not false an error message is added to
|
||||||
|v:errors|, like with |assert_equal()|.
|
|v:errors|, like with |assert_equal()|.
|
||||||
|
@ -6680,6 +6680,7 @@ static struct fst {
|
|||||||
{ "asin", 1, 1, f_asin }, // WJMc
|
{ "asin", 1, 1, f_asin }, // WJMc
|
||||||
{ "assert_equal", 2, 3, f_assert_equal },
|
{ "assert_equal", 2, 3, f_assert_equal },
|
||||||
{ "assert_exception", 1, 2, f_assert_exception },
|
{ "assert_exception", 1, 2, f_assert_exception },
|
||||||
|
{ "assert_fails", 1, 2, f_assert_fails },
|
||||||
{ "assert_false", 1, 2, f_assert_false },
|
{ "assert_false", 1, 2, f_assert_false },
|
||||||
{ "assert_true", 1, 2, f_assert_true },
|
{ "assert_true", 1, 2, f_assert_true },
|
||||||
{ "atan", 1, 1, f_atan },
|
{ "atan", 1, 1, f_atan },
|
||||||
@ -7667,6 +7668,43 @@ static void f_assert_exception(typval_T *argvars, typval_T *rettv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// "assert_fails(cmd [, error])" function
|
||||||
|
static void f_assert_fails(typval_T *argvars, typval_T *rettv)
|
||||||
|
{
|
||||||
|
char_u *cmd = get_tv_string_chk(&argvars[0]);
|
||||||
|
garray_T ga;
|
||||||
|
|
||||||
|
called_emsg = false;
|
||||||
|
suppress_errthrow = true;
|
||||||
|
emsg_silent = true;
|
||||||
|
do_cmdline_cmd((char *)cmd);
|
||||||
|
if (!called_emsg) {
|
||||||
|
prepare_assert_error(&ga);
|
||||||
|
ga_concat(&ga, (char_u *)"command did not fail: ");
|
||||||
|
ga_concat(&ga, cmd);
|
||||||
|
assert_error(&ga);
|
||||||
|
ga_clear(&ga);
|
||||||
|
} else if (argvars[1].v_type != VAR_UNKNOWN) {
|
||||||
|
char_u buf[NUMBUFLEN];
|
||||||
|
char *error = (char *)get_tv_string_buf_chk(&argvars[1], buf);
|
||||||
|
|
||||||
|
if (error == NULL
|
||||||
|
|| strstr((char *)vimvars[VV_ERRMSG].vv_str, error) == NULL) {
|
||||||
|
prepare_assert_error(&ga);
|
||||||
|
fill_assert_error(&ga, &argvars[2], NULL, &argvars[1],
|
||||||
|
&vimvars[VV_ERRMSG].vv_tv);
|
||||||
|
assert_error(&ga);
|
||||||
|
ga_clear(&ga);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
called_emsg = false;
|
||||||
|
suppress_errthrow = false;
|
||||||
|
emsg_silent = false;
|
||||||
|
emsg_on_display = false;
|
||||||
|
set_vim_var_string(VV_ERRMSG, NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
// Common for assert_true() and assert_false().
|
// Common for assert_true() and assert_false().
|
||||||
static void assert_bool(typval_T *argvars, bool is_true)
|
static void assert_bool(typval_T *argvars, bool is_true)
|
||||||
{
|
{
|
||||||
|
@ -119,7 +119,7 @@ static int included_patches[] = {
|
|||||||
1570,
|
1570,
|
||||||
1569,
|
1569,
|
||||||
1568,
|
1568,
|
||||||
// 1567,
|
1567,
|
||||||
// 1566 NA
|
// 1566 NA
|
||||||
// 1565,
|
// 1565,
|
||||||
// 1564,
|
// 1564,
|
||||||
@ -590,7 +590,7 @@ static int included_patches[] = {
|
|||||||
// 1099 NA
|
// 1099 NA
|
||||||
// 1098 NA
|
// 1098 NA
|
||||||
// 1097,
|
// 1097,
|
||||||
// 1096,
|
1096,
|
||||||
// 1095 NA
|
// 1095 NA
|
||||||
// 1094,
|
// 1094,
|
||||||
1093,
|
1093,
|
||||||
|
@ -142,4 +142,22 @@ describe('assert function:', function()
|
|||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
-- assert_fails({cmd}, [, {error}])
|
||||||
|
describe('assert_fails', function()
|
||||||
|
it('should change v:errors when error does not match v:errmsg', function()
|
||||||
|
execute([[call assert_fails('xxx', {})]])
|
||||||
|
expected_errors({"Expected {} but got 'E731: using Dictionary as a String'"})
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('should not change v:errors when cmd errors', function()
|
||||||
|
call('assert_fails', 'NonexistentCmd')
|
||||||
|
expected_empty()
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('should change v:errors when cmd succeeds', function()
|
||||||
|
call('assert_fails', 'call empty("")')
|
||||||
|
expected_errors({'command did not fail: call empty("")'})
|
||||||
|
end)
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user