diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-01-27 19:59:47 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-01-27 19:59:47 +0000 |
commit | b3d83980d2ac0f7a25314270416f17af874ca269 (patch) | |
tree | 354adb94d90c85e3f5a33cf713ebe6e27801078e | |
parent | a4bc2dd7cccf5a4a9f78b58b6f35a45d17164323 (diff) | |
download | vim-git-b3d83980d2ac0f7a25314270416f17af874ca269.tar.gz |
patch 8.2.4234: test_garbagecollect_now() does not check v:testingv8.2.4234
Problem: test_garbagecollect_now() does not check v:testing as documented.
Solution: Give an error if v:testing is not set.
-rw-r--r-- | src/errors.h | 3 | ||||
-rw-r--r-- | src/testdir/test_functions.vim | 6 | ||||
-rw-r--r-- | src/testing.c | 5 | ||||
-rw-r--r-- | src/version.c | 2 |
4 files changed, 14 insertions, 2 deletions
diff --git a/src/errors.h b/src/errors.h index dd1b9fcc8..6d3d06d26 100644 --- a/src/errors.h +++ b/src/errors.h @@ -2909,7 +2909,8 @@ EXTERN char e_for_argument_must_be_sequence_of_lists[] INIT(= N_("E1140: :for argument must be a sequence of lists")); EXTERN char e_indexable_type_required[] INIT(= N_("E1141: Indexable type required")); -// E1142 unused +EXTERN char e_calling_test_garbagecollect_now_while_v_testing_is_not_set[] + INIT(= N_("E1142: Calling test_garbagecollect_now() while v:testing is not set")); EXTERN char e_empty_expression_str[] INIT(= N_("E1143: Empty expression: \"%s\"")); EXTERN char e_command_str_not_followed_by_white_space_str[] diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim index 917e89f35..ff079168f 100644 --- a/src/testdir/test_functions.vim +++ b/src/testdir/test_functions.vim @@ -2663,6 +2663,12 @@ func Test_range() call assert_fails('let x=range(1, 4, [])', 'E745:') endfunc +func Test_garbagecollect_now_fails() + let v:testing = 0 + call assert_fails('call test_garbagecollect_now()', 'E1142:') + let v:testing = 1 +endfunc + func Test_echoraw() CheckScreendump diff --git a/src/testing.c b/src/testing.c index 675eaa249..4e688a71d 100644 --- a/src/testing.c +++ b/src/testing.c @@ -1153,7 +1153,10 @@ 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); + if (!get_vim_var_nr(VV_TESTING)) + emsg(_(e_calling_test_garbagecollect_now_while_v_testing_is_not_set)); + else + garbage_collect(TRUE); } /* diff --git a/src/version.c b/src/version.c index bc956cee0..7247ca753 100644 --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 4234, +/**/ 4233, /**/ 4232, |