0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

patch 7.4.1844

Problem:    Using old function name in comment.  More functions should start
            with test_.
Solution:   Rename function in comment. (Higashi Higashi) Rename
            disable_char_avail_for_testing() to test_disable_char_avail().
            And alloc_fail() to test_alloc_fail().
This commit is contained in:
Bram Moolenaar 2016-05-25 21:23:21 +02:00
parent 2177f9fe18
commit 8e8df251bf
7 changed files with 68 additions and 67 deletions

View File

@ -1,4 +1,4 @@
*eval.txt* For Vim version 7.4. Last change: 2016 May 24
*eval.txt* For Vim version 7.4. Last change: 2016 May 25
VIM REFERENCE MANUAL by Bram Moolenaar
@ -1765,7 +1765,7 @@ v:termresponse The escape sequence returned by the terminal for the |t_RV|
{only when compiled with |+termresponse| feature}
*v:testing* *testing-variable*
v:testing Must be set before using `garbagecollect_for_testing()`.
v:testing Must be set before using `test_garbagecollect_now()`.
*v:this_session* *this_session-variable*
v:this_session Full filename of the last loaded or saved session file. See
@ -1835,8 +1835,6 @@ USAGE RESULT DESCRIPTION ~
abs({expr}) Float or Number absolute value of {expr}
acos({expr}) Float arc cosine of {expr}
add({list}, {item}) List append {item} to |List| {list}
alloc_fail({id}, {countdown}, {repeat})
none make memory allocation fail
and({expr}, {expr}) Number bitwise AND
append({lnum}, {string}) Number append {string} below line {lnum}
append({lnum}, {list}) Number append lines {list} below line {lnum}
@ -1918,8 +1916,6 @@ delete({fname} [, {flags}]) Number delete the file or directory {fname}
did_filetype() Number TRUE if FileType autocommand event used
diff_filler({lnum}) Number diff filler lines about {lnum}
diff_hlID({lnum}, {col}) Number diff highlighting at {lnum}/{col}
disable_char_avail_for_testing({expr})
none test without typeahead
empty({expr}) Number TRUE if {expr} is empty
escape({string}, {chars}) String escape {chars} in {string} with '\'
eval({string}) any evaluate {string} into its value
@ -2203,6 +2199,9 @@ tagfiles() List tags files used
tan({expr}) Float tangent of {expr}
tanh({expr}) Float hyperbolic tangent of {expr}
tempname() String name for a temporary file
test_alloc_fail({id}, {countdown}, {repeat})
none make memory allocation fail
test_disable_char_avail({expr}) none test without typeahead
test_garbagecollect_now() none free memory right now for testing
test_null_channel() Channel null value for testing
test_null_dict() Dict null value for testing
@ -2285,13 +2284,6 @@ add({list}, {expr}) *add()*
Use |insert()| to add an item at another position.
alloc_fail({id}, {countdown}, {repeat}) *alloc_fail()*
This is for testing: If the memory allocation with {id} is
called, then decrement {countdown}, and when it reaches zero
let memory allocation fail {repeat} times. When {repeat} is
smaller than one it fails one time.
and({expr}, {expr}) *and()*
Bitwise AND on the two arguments. The arguments are converted
to a number. A List, Dict or Float argument causes an error.
@ -3158,14 +3150,6 @@ diff_hlID({lnum}, {col}) *diff_hlID()*
The highlight ID can be used with |synIDattr()| to obtain
syntax information about the highlighting.
*disable_char_avail_for_testing()*
disable_char_avail_for_testing({expr})
When {expr} is 1 the internal char_avail() function will
return FALSE. When {expr} is 0 the char_avail() function will
function normally.
Only use this for a test where typeahead causes the test not
to work. E.g., to trigger the CursorMovedI autocommand event.
empty({expr}) *empty()*
Return the Number 1 if {expr} is empty, zero otherwise.
- A |List| or |Dictionary| is empty when it does not have any
@ -7213,6 +7197,21 @@ tempname() *tempname()* *temp-file-name*
option is set or when 'shellcmdflag' starts with '-'.
test_alloc_fail({id}, {countdown}, {repeat}) *test_alloc_fail()*
This is for testing: If the memory allocation with {id} is
called, then decrement {countdown}, and when it reaches zero
let memory allocation fail {repeat} times. When {repeat} is
smaller than one it fails one time.
*test_disable_char_avail()*
test_disable_char_avail({expr})
When {expr} is 1 the internal char_avail() function will
return FALSE. When {expr} is 0 the char_avail() function will
function normally.
Only use this for a test where typeahead causes the test not
to work. E.g., to trigger the CursorMovedI autocommand event.
test_garbagecollect_now() *test_garbagecollect_now()*
Like garbagecollect(), but executed right away. This must
only be called directly to avoid any structure to exist

View File

@ -472,7 +472,6 @@ static void f_abs(typval_T *argvars, typval_T *rettv);
static void f_acos(typval_T *argvars, typval_T *rettv);
#endif
static void f_add(typval_T *argvars, typval_T *rettv);
static void f_alloc_fail(typval_T *argvars, typval_T *rettv);
static void f_and(typval_T *argvars, typval_T *rettv);
static void f_append(typval_T *argvars, typval_T *rettv);
static void f_argc(typval_T *argvars, typval_T *rettv);
@ -549,7 +548,6 @@ static void f_delete(typval_T *argvars, typval_T *rettv);
static void f_did_filetype(typval_T *argvars, typval_T *rettv);
static void f_diff_filler(typval_T *argvars, typval_T *rettv);
static void f_diff_hlID(typval_T *argvars, typval_T *rettv);
static void f_disable_char_avail_for_testing(typval_T *argvars, typval_T *rettv);
static void f_empty(typval_T *argvars, typval_T *rettv);
static void f_escape(typval_T *argvars, typval_T *rettv);
static void f_eval(typval_T *argvars, typval_T *rettv);
@ -805,6 +803,8 @@ static void f_tabpagewinnr(typval_T *argvars, typval_T *rettv);
static void f_taglist(typval_T *argvars, typval_T *rettv);
static void f_tagfiles(typval_T *argvars, typval_T *rettv);
static void f_tempname(typval_T *argvars, typval_T *rettv);
static void f_test_alloc_fail(typval_T *argvars, typval_T *rettv);
static void f_test_disable_char_avail(typval_T *argvars, typval_T *rettv);
static void f_test_garbagecollect_now(typval_T *argvars, typval_T *rettv);
#ifdef FEAT_JOB_CHANNEL
static void f_test_null_channel(typval_T *argvars, typval_T *rettv);
@ -8344,7 +8344,6 @@ static struct fst
{"acos", 1, 1, f_acos}, /* WJMc */
#endif
{"add", 2, 2, f_add},
{"alloc_fail", 3, 3, f_alloc_fail},
{"and", 2, 2, f_and},
{"append", 2, 2, f_append},
{"argc", 0, 0, f_argc},
@ -8425,7 +8424,6 @@ static struct fst
{"did_filetype", 0, 0, f_did_filetype},
{"diff_filler", 1, 1, f_diff_filler},
{"diff_hlID", 2, 2, f_diff_hlID},
{"disable_char_avail_for_testing", 1, 1, f_disable_char_avail_for_testing},
{"empty", 1, 1, f_empty},
{"escape", 2, 2, f_escape},
{"eval", 1, 1, f_eval},
@ -8689,6 +8687,8 @@ static struct fst
{"tanh", 1, 1, f_tanh},
#endif
{"tempname", 0, 0, f_tempname},
{"test_alloc_fail", 3, 3, f_test_alloc_fail},
{"test_disable_char_avail", 1, 1, f_test_disable_char_avail},
{"test_garbagecollect_now", 0, 0, f_test_garbagecollect_now},
#ifdef FEAT_JOB_CHANNEL
{"test_null_channel", 0, 0, f_test_null_channel},
@ -8949,7 +8949,7 @@ get_func_tv(
if (get_vim_var_nr(VV_TESTING))
{
/* Prepare for calling garbagecollect_for_testing(), need to know
/* Prepare for calling test_garbagecollect_now(), need to know
* what variables are used on the call stack. */
if (funcargs.ga_itemsize == 0)
ga_init2(&funcargs, (int)sizeof(typval_T *), 50);
@ -9380,29 +9380,6 @@ f_add(typval_T *argvars, typval_T *rettv)
EMSG(_(e_listreq));
}
/*
* "alloc_fail(id, countdown, repeat)" function
*/
static void
f_alloc_fail(typval_T *argvars, typval_T *rettv UNUSED)
{
if (argvars[0].v_type != VAR_NUMBER
|| argvars[0].vval.v_number <= 0
|| argvars[1].v_type != VAR_NUMBER
|| argvars[1].vval.v_number < 0
|| argvars[2].v_type != VAR_NUMBER)
EMSG(_(e_invarg));
else
{
alloc_fail_id = argvars[0].vval.v_number;
if (alloc_fail_id >= aid_last)
EMSG(_(e_invarg));
alloc_fail_countdown = argvars[1].vval.v_number;
alloc_fail_repeat = argvars[2].vval.v_number;
did_outofmem_msg = FALSE;
}
}
/*
* "and(expr, expr)" function
*/
@ -11114,15 +11091,6 @@ f_diff_hlID(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
#endif
}
/*
* "disable_char_avail_for_testing({expr})" function
*/
static void
f_disable_char_avail_for_testing(typval_T *argvars, typval_T *rettv UNUSED)
{
disable_char_avail_for_testing = get_tv_number(&argvars[0]);
}
/*
* "empty({expr})" function
*/
@ -20690,6 +20658,38 @@ f_tanh(typval_T *argvars, typval_T *rettv)
}
#endif
/*
* "test_alloc_fail(id, countdown, repeat)" function
*/
static void
f_test_alloc_fail(typval_T *argvars, typval_T *rettv UNUSED)
{
if (argvars[0].v_type != VAR_NUMBER
|| argvars[0].vval.v_number <= 0
|| argvars[1].v_type != VAR_NUMBER
|| argvars[1].vval.v_number < 0
|| argvars[2].v_type != VAR_NUMBER)
EMSG(_(e_invarg));
else
{
alloc_fail_id = argvars[0].vval.v_number;
if (alloc_fail_id >= aid_last)
EMSG(_(e_invarg));
alloc_fail_countdown = argvars[1].vval.v_number;
alloc_fail_repeat = argvars[2].vval.v_number;
did_outofmem_msg = FALSE;
}
}
/*
* "test_disable_char_avail({expr})" function
*/
static void
f_test_disable_char_avail(typval_T *argvars, typval_T *rettv UNUSED)
{
disable_char_avail_for_testing = get_tv_number(&argvars[0]);
}
/*
* "test_garbagecollect_now()" function
*/

View File

@ -1880,7 +1880,7 @@ char_avail(void)
int retval;
#ifdef FEAT_EVAL
/* When disable_char_avail_for_testing(1) was called pretend there is no
/* When test_disable_char_avail(1) was called pretend there is no
* typeahead. */
if (disable_char_avail_for_testing)
return FALSE;

View File

@ -60,7 +60,7 @@ let $HOME = '/does/not/exist'
let s:srcdir = expand('%:p:h:h')
" Prepare for calling garbagecollect_for_testing().
" Prepare for calling test_garbagecollect_now().
let v:testing = 1
" Support function: get the alloc ID by name.

View File

@ -44,9 +44,9 @@ func Test_curswant_with_autocommand()
new
call setline(1, ['func()', '{', '}', '----'])
autocmd! CursorMovedI * call s:Highlight_Matching_Pair()
call disable_char_avail_for_testing(1)
call test_disable_char_avail(1)
exe "normal! 3Ga\<Down>X\<Esc>"
call disable_char_avail_for_testing(0)
call test_disable_char_avail(0)
call assert_equal('-X---', getline(4))
autocmd! CursorMovedI *
quit!

View File

@ -280,19 +280,19 @@ function Test_cbuffer()
endfunction
function Test_nomem()
call alloc_fail(GetAllocId('qf_dirname_start'), 0, 0)
call test_alloc_fail(GetAllocId('qf_dirname_start'), 0, 0)
call assert_fails('vimgrep vim runtest.vim', 'E342:')
call alloc_fail(GetAllocId('qf_dirname_now'), 0, 0)
call test_alloc_fail(GetAllocId('qf_dirname_now'), 0, 0)
call assert_fails('vimgrep vim runtest.vim', 'E342:')
call alloc_fail(GetAllocId('qf_namebuf'), 0, 0)
call test_alloc_fail(GetAllocId('qf_namebuf'), 0, 0)
call assert_fails('cfile runtest.vim', 'E342:')
call alloc_fail(GetAllocId('qf_errmsg'), 0, 0)
call test_alloc_fail(GetAllocId('qf_errmsg'), 0, 0)
call assert_fails('cfile runtest.vim', 'E342:')
call alloc_fail(GetAllocId('qf_pattern'), 0, 0)
call test_alloc_fail(GetAllocId('qf_pattern'), 0, 0)
call assert_fails('cfile runtest.vim', 'E342:')
endfunc

View File

@ -753,6 +753,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1844,
/**/
1843,
/**/