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

patch 8.1.0386: cannot test with non-default option value

Problem:    Cannot test with non-default option value.
Solution:   Add test_option_not_set().
This commit is contained in:
Bram Moolenaar 2018-09-13 20:31:54 +02:00
parent c91c500348
commit fe8ef98dd1
5 changed files with 39 additions and 3 deletions

View File

@ -2473,6 +2473,7 @@ test_null_job() Job null value for testing
test_null_list() List null value for testing test_null_list() List null value for testing
test_null_partial() Funcref null value for testing test_null_partial() Funcref null value for testing
test_null_string() String null value for testing test_null_string() String null value for testing
test_option_not_set({name}) none reset flag indicating option was set
test_override({expr}, {val}) none test with Vim internal overrides test_override({expr}, {val}) none test with Vim internal overrides
test_settime({expr}) none set current time for testing test_settime({expr}) none set current time for testing
timer_info([{id}]) List information about timers timer_info([{id}]) List information about timers
@ -8737,6 +8738,15 @@ test_null_partial() *test_null_partial()*
test_null_string() *test_null_string()* test_null_string() *test_null_string()*
Return a String that is null. Only useful for testing. Return a String that is null. Only useful for testing.
test_option_not_set({name}) *test_option_not_set()*
Reset the flag that indicates option {name} was set. Thus it
looks like it still has the default value. Use like this: >
set ambiwidth=double
call test_option_not_set('ambiwidth')
< Now the 'ambiwidth' option behaves like it was never changed,
even though the value is "double".
Only to be used for testing!
test_override({name}, {val}) *test_override()* test_override({name}, {val}) *test_override()*
Overrides certain parts of Vims internal processing to be able Overrides certain parts of Vims internal processing to be able
to run tests. Only to be used for testing Vim! to run tests. Only to be used for testing Vim!

View File

@ -415,6 +415,7 @@ 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_alloc_fail(typval_T *argvars, typval_T *rettv);
static void f_test_autochdir(typval_T *argvars, typval_T *rettv); static void f_test_autochdir(typval_T *argvars, typval_T *rettv);
static void f_test_feedinput(typval_T *argvars, typval_T *rettv); static void f_test_feedinput(typval_T *argvars, typval_T *rettv);
static void f_test_option_not_set(typval_T *argvars, typval_T *rettv);
static void f_test_override(typval_T *argvars, typval_T *rettv); static void f_test_override(typval_T *argvars, typval_T *rettv);
static void f_test_garbagecollect_now(typval_T *argvars, typval_T *rettv); static void f_test_garbagecollect_now(typval_T *argvars, typval_T *rettv);
static void f_test_ignore_error(typval_T *argvars, typval_T *rettv); static void f_test_ignore_error(typval_T *argvars, typval_T *rettv);
@ -922,6 +923,7 @@ static struct fst
{"test_null_list", 0, 0, f_test_null_list}, {"test_null_list", 0, 0, f_test_null_list},
{"test_null_partial", 0, 0, f_test_null_partial}, {"test_null_partial", 0, 0, f_test_null_partial},
{"test_null_string", 0, 0, f_test_null_string}, {"test_null_string", 0, 0, f_test_null_string},
{"test_option_not_set", 1, 1, f_test_option_not_set},
{"test_override", 2, 2, f_test_override}, {"test_override", 2, 2, f_test_override},
{"test_settime", 1, 1, f_test_settime}, {"test_settime", 1, 1, f_test_settime},
#ifdef FEAT_TIMERS #ifdef FEAT_TIMERS
@ -13062,7 +13064,25 @@ f_test_feedinput(typval_T *argvars, typval_T *rettv UNUSED)
} }
/* /*
* "test_disable({name}, {val})" function * "test_option_not_set({name})" function
*/
static void
f_test_option_not_set(typval_T *argvars, typval_T *rettv UNUSED)
{
char_u *name = (char_u *)"";
if (argvars[0].v_type != VAR_STRING)
EMSG(_(e_invarg));
else
{
name = get_tv_string_chk(&argvars[0]);
if (reset_option_was_set(name) == FAIL)
EMSG2(_(e_invarg2), name);
}
}
/*
* "test_override({name}, {val})" function
*/ */
static void static void
f_test_override(typval_T *argvars, typval_T *rettv UNUSED) f_test_override(typval_T *argvars, typval_T *rettv UNUSED)

View File

@ -12480,13 +12480,17 @@ option_was_set(char_u *name)
/* /*
* Reset the flag indicating option "name" was set. * Reset the flag indicating option "name" was set.
*/ */
void int
reset_option_was_set(char_u *name) reset_option_was_set(char_u *name)
{ {
int idx = findoption(name); int idx = findoption(name);
if (idx >= 0) if (idx >= 0)
{
options[idx].flags &= ~P_WAS_SET; options[idx].flags &= ~P_WAS_SET;
return OK;
}
return FAIL;
} }
/* /*

View File

@ -55,7 +55,7 @@ int shortmess(int x);
void vimrc_found(char_u *fname, char_u *envname); void vimrc_found(char_u *fname, char_u *envname);
void change_compatible(int on); void change_compatible(int on);
int option_was_set(char_u *name); int option_was_set(char_u *name);
void reset_option_was_set(char_u *name); int reset_option_was_set(char_u *name);
int can_bs(int what); int can_bs(int what);
void save_file_ff(buf_T *buf); void save_file_ff(buf_T *buf);
int file_ff_differs(buf_T *buf, int ignore_empty); int file_ff_differs(buf_T *buf, int ignore_empty);

View File

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