diff src/testing.c @ 27412:557a50b0d10b v8.2.4234

patch 8.2.4234: test_garbagecollect_now() does not check v:testing Commit: https://github.com/vim/vim/commit/b3d83980d2ac0f7a25314270416f17af874ca269 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jan 27 19:59:47 2022 +0000 patch 8.2.4234: test_garbagecollect_now() does not check v:testing Problem: test_garbagecollect_now() does not check v:testing as documented. Solution: Give an error if v:testing is not set.
author Bram Moolenaar <Bram@vim.org>
date Thu, 27 Jan 2022 21:00:04 +0100
parents 722db0819111
children 7c233f560a7f
line wrap: on
line diff
--- a/src/testing.c
+++ b/src/testing.c
@@ -1153,7 +1153,10 @@ f_test_garbagecollect_now(typval_T *argv
 {
     // 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);
 }
 
 /*