summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-05-24 17:33:34 +0200
committerBram Moolenaar <Bram@vim.org>2016-05-24 17:33:34 +0200
commit574860b5ee9da281c875dad07a607454e135eaee (patch)
treec4eed36a67682b8fb209142b3f7081e11fee7f8b /src
parentc67e89213476b5f4756d92208b57ce9ef4a4cf24 (diff)
downloadvim-git-574860b5ee9da281c875dad07a607454e135eaee.tar.gz
patch 7.4.1838v7.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.
Diffstat (limited to 'src')
-rw-r--r--src/eval.c125
-rw-r--r--src/testdir/test_channel.vim4
-rw-r--r--src/testdir/test_expr.vim2
-rw-r--r--src/version.c2
4 files changed, 85 insertions, 48 deletions
diff --git a/src/eval.c b/src/eval.c
index ce83143ce..a653b89f7 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -583,7 +583,6 @@ static void f_foldtextresult(typval_T *argvars, typval_T *rettv);
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 *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(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, typval_T *rettv UNUSED)
}
/*
- * "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, typval_T *rettv)
} 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 *rettv)
}
#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.
diff --git a/src/testdir/test_channel.vim b/src/testdir/test_channel.vim
index 8e29d3235..363b5cd9e 100644
--- a/src/testdir/test_channel.vim
+++ b/src/testdir/test_channel.vim
@@ -183,7 +183,7 @@ func s:communicate(port)
call assert_equal('got it', s:responseMsg)
" Collect garbage, tests that our handle isn't collected.
- call garbagecollect_for_testing()
+ call test_garbagecollect_now()
" check setting options (without testing the effect)
call ch_setoptions(handle, {'callback': 's:NotUsed'})
@@ -1302,7 +1302,7 @@ endfunc
func Test_using_freed_memory()
let g:a = job_start(['ls'])
sleep 10m
- call garbagecollect_for_testing()
+ call test_garbagecollect_now()
endfunc
diff --git a/src/testdir/test_expr.vim b/src/testdir/test_expr.vim
index 2cd9625ad..142455bfe 100644
--- a/src/testdir/test_expr.vim
+++ b/src/testdir/test_expr.vim
@@ -85,7 +85,7 @@ func Test_getreg_empty_list()
endfunc
func Test_loop_over_null_list()
- let null_list = submatch(1, 1)
+ let null_list = test_null_list()
for i in null_list
call assert_true(0, 'should not get here')
endfor
diff --git a/src/version.c b/src/version.c
index f1bbbdd77..46aff5391 100644
--- a/src/version.c
+++ b/src/version.c
@@ -754,6 +754,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1838,
+/**/
1837,
/**/
1836,