Mercurial > vim
diff src/eval.c @ 9108:d319453f62b3 v7.4.1838
commit https://github.com/vim/vim/commit/574860b5ee9da281c875dad07a607454e135eaee
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue May 24 17:33:34 2016 +0200
patch 7.4.1838
Problem: Functions specifically for testing do not sort together.
Solution: Rename garbagecollect_for_testing() to test_garbagecollect_now().
Add test_null_list(), test_null_dict(), etc.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 24 May 2016 17:45:06 +0200 |
parents | 2242a5766417 |
children | 6d3888e2232c |
line wrap: on
line diff
--- a/src/eval.c +++ b/src/eval.c @@ -583,7 +583,6 @@ static void f_foldtextresult(typval_T *a static void f_foreground(typval_T *argvars, typval_T *rettv); static void f_function(typval_T *argvars, typval_T *rettv); static void f_garbagecollect(typval_T *argvars, typval_T *rettv); -static void f_garbagecollect_for_testing(typval_T *argvars, typval_T *rettv); static void f_get(typval_T *argvars, typval_T *rettv); static void f_getbufline(typval_T *argvars, typval_T *rettv); static void f_getbufvar(typval_T *argvars, typval_T *rettv); @@ -806,7 +805,17 @@ static void f_tabpagewinnr(typval_T *arg 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(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); +#endif +static void f_test_null_dict(typval_T *argvars, typval_T *rettv); +#ifdef FEAT_JOB_CHANNEL +static void f_test_null_job(typval_T *argvars, typval_T *rettv); +#endif +static void f_test_null_list(typval_T *argvars, typval_T *rettv); +static void f_test_null_partial(typval_T *argvars, typval_T *rettv); +static void f_test_null_string(typval_T *argvars, typval_T *rettv); #ifdef FEAT_FLOAT static void f_tan(typval_T *argvars, typval_T *rettv); static void f_tanh(typval_T *argvars, typval_T *rettv); @@ -6925,7 +6934,7 @@ static garray_T funcargs = GA_EMPTY; /* * Do garbage collection for lists and dicts. - * When "testing" is TRUE this is called from garbagecollect_for_testing(). + * When "testing" is TRUE this is called from test_garbagecollect_now(). * Return TRUE if some memory was freed. */ int @@ -8451,7 +8460,6 @@ static struct fst {"foreground", 0, 0, f_foreground}, {"function", 1, 3, f_function}, {"garbagecollect", 0, 1, f_garbagecollect}, - {"garbagecollect_for_testing", 0, 0, f_garbagecollect_for_testing}, {"get", 2, 3, f_get}, {"getbufline", 2, 3, f_getbufline}, {"getbufvar", 2, 3, f_getbufvar}, @@ -8681,7 +8689,17 @@ static struct fst {"tanh", 1, 1, f_tanh}, #endif {"tempname", 0, 0, f_tempname}, - {"test", 1, 1, f_test}, + {"test_garbagecollect_now", 0, 0, f_test_garbagecollect_now}, +#ifdef FEAT_JOB_CHANNEL + {"test_null_channel", 0, 0, f_test_null_channel}, +#endif + {"test_null_dict", 0, 0, f_test_null_dict}, +#ifdef FEAT_JOB_CHANNEL + {"test_null_job", 0, 0, f_test_null_job}, +#endif + {"test_null_list", 0, 0, f_test_null_list}, + {"test_null_partial", 0, 0, f_test_null_partial}, + {"test_null_string", 0, 0, f_test_null_string}, #ifdef FEAT_TIMERS {"timer_start", 2, 3, f_timer_start}, {"timer_stop", 1, 1, f_timer_stop}, @@ -12374,17 +12392,6 @@ f_garbagecollect(typval_T *argvars, typv } /* - * "garbagecollect_for_testing()" function - */ - static void -f_garbagecollect_for_testing(typval_T *argvars UNUSED, typval_T *rettv UNUSED) -{ - /* This is dangerous, any Lists and Dicts used internally may be freed - * while still in use. */ - garbage_collect(TRUE); -} - -/* * "get()" function */ static void @@ -20602,35 +20609,6 @@ f_tempname(typval_T *argvars UNUSED, typ } while (x == 'I' || x == 'O'); } -/* - * "test(list)" function: Just checking the walls... - */ - static void -f_test(typval_T *argvars UNUSED, typval_T *rettv UNUSED) -{ - /* Used for unit testing. Change the code below to your liking. */ -#if 0 - listitem_T *li; - list_T *l; - char_u *bad, *good; - - if (argvars[0].v_type != VAR_LIST) - return; - l = argvars[0].vval.v_list; - if (l == NULL) - return; - li = l->lv_first; - if (li == NULL) - return; - bad = get_tv_string(&li->li_tv); - li = li->li_next; - if (li == NULL) - return; - good = get_tv_string(&li->li_tv); - rettv->vval.v_number = test_edit_score(bad, good); -#endif -} - #ifdef FEAT_FLOAT /* * "tan()" function @@ -20663,6 +20641,63 @@ f_tanh(typval_T *argvars, typval_T *rett } #endif +/* + * "test_garbagecollect_now()" function + */ + static void +f_test_garbagecollect_now(typval_T *argvars UNUSED, typval_T *rettv UNUSED) +{ + /* This is dangerous, any Lists and Dicts used internally may be freed + * while still in use. */ + garbage_collect(TRUE); +} + +#ifdef FEAT_JOB_CHANNEL + static void +f_test_null_channel(typval_T *argvars UNUSED, typval_T *rettv UNUSED) +{ + rettv->v_type = VAR_CHANNEL; + rettv->vval.v_channel = NULL; +} +#endif + + static void +f_test_null_dict(typval_T *argvars UNUSED, typval_T *rettv UNUSED) +{ + rettv->v_type = VAR_DICT; + rettv->vval.v_dict = NULL; +} + +#ifdef FEAT_JOB_CHANNEL + static void +f_test_null_job(typval_T *argvars UNUSED, typval_T *rettv UNUSED) +{ + rettv->v_type = VAR_JOB; + rettv->vval.v_job = NULL; +} +#endif + + static void +f_test_null_list(typval_T *argvars UNUSED, typval_T *rettv UNUSED) +{ + rettv->v_type = VAR_LIST; + rettv->vval.v_list = NULL; +} + + static void +f_test_null_partial(typval_T *argvars UNUSED, typval_T *rettv UNUSED) +{ + rettv->v_type = VAR_PARTIAL; + rettv->vval.v_partial = NULL; +} + + static void +f_test_null_string(typval_T *argvars UNUSED, typval_T *rettv UNUSED) +{ + rettv->v_type = VAR_STRING; + rettv->vval.v_string = NULL; +} + #if defined(FEAT_JOB_CHANNEL) || defined(FEAT_TIMERS) || defined(PROTO) /* * Get a callback from "arg". It can be a Funcref or a function name.