summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYegappan Lakshmanan <yegappan@yahoo.com>2024-05-03 18:24:07 +0200
committerChristian Brabandt <cb@256bit.org>2024-05-03 18:27:51 +0200
commit5715a726282018e708cff7dd930c9f8f7c37fa7e (patch)
treef6c0049084d51445a5d1bd00d47447981707b16f
parentc8330b8fff8e44c450a606ba91c1fec5f41478f7 (diff)
patch 9.1.0391: Vim9: could improve testingv9.1.0391
Problem: Vim9: could improve testing (Ernie Rael) Solution: Support defcompile for test_override() to improve testing (Yegappan Lakshmanan) fixes: #14553 closes: #14712 Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
-rw-r--r--runtime/doc/testing.txt5
-rw-r--r--src/globals.h1
-rw-r--r--src/testdir/test_vim9_func.vim13
-rw-r--r--src/testing.c2
-rw-r--r--src/userfunc.c4
-rw-r--r--src/version.c2
6 files changed, 26 insertions, 1 deletions
diff --git a/runtime/doc/testing.txt b/runtime/doc/testing.txt
index 9b9f60b667..d0f1d46c48 100644
--- a/runtime/doc/testing.txt
+++ b/runtime/doc/testing.txt
@@ -1,4 +1,4 @@
-*testing.txt* For Vim version 9.1. Last change: 2024 Apr 07
+*testing.txt* For Vim version 9.1. Last change: 2024 May 03
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -369,6 +369,9 @@ test_override({name}, {val}) *test_override()*
autoload `import autoload` will load the script right
away, not postponed until an item is used
char_avail disable the char_avail() function
+ defcompile all the |:def| functions in a sourced script are
+ compiled when defined. This is similar to using
+ the |:defcompile| command in a script.
nfa_fail makes the NFA regexp engine fail to force a
fallback to the old engine
no_query_mouse do not query the mouse position for "dec"
diff --git a/src/globals.h b/src/globals.h
index 2c00e5f99b..fb5c7b34a2 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -1936,6 +1936,7 @@ EXTERN int reset_term_props_on_termresponse INIT(= FALSE);
EXTERN int disable_vterm_title_for_testing INIT(= FALSE);
EXTERN long override_sysinfo_uptime INIT(= -1);
EXTERN int override_autoload INIT(= FALSE);
+EXTERN int override_defcompile INIT(= FALSE);
EXTERN int ml_get_alloc_lines INIT(= FALSE);
EXTERN int ignore_unreachable_code_for_testing INIT(= FALSE);
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim
index b008929611..d07bbfba70 100644
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -4633,6 +4633,19 @@ def Run_Test_keytyped_in_nested_function()
g:StopVimInTerminal(buf)
enddef
+" Test for test_override('defcompile')
+def Test_test_override_defcompile()
+ var lines =<< trim END
+ vim9script
+ def Foo()
+ xxx
+ enddef
+ END
+ test_override('defcompile', 1)
+ v9.CheckScriptFailure(lines, 'E476: Invalid command: xxx')
+ test_override('defcompile', 0)
+enddef
+
" The following messes up syntax highlight, keep near the end.
if has('python3')
def Test_python3_command()
diff --git a/src/testing.c b/src/testing.c
index 33de3a5cd8..3e9e07704b 100644
--- a/src/testing.c
+++ b/src/testing.c
@@ -1051,6 +1051,8 @@ f_test_override(typval_T *argvars, typval_T *rettv UNUSED)
ml_get_alloc_lines = val;
else if (STRCMP(name, (char_u *)"autoload") == 0)
override_autoload = val;
+ else if (STRCMP(name, (char_u *)"defcompile") == 0)
+ override_defcompile = val;
else if (STRCMP(name, (char_u *)"ALL") == 0)
{
disable_char_avail_for_testing = FALSE;
diff --git a/src/userfunc.c b/src/userfunc.c
index 71b39837c7..7536234b82 100644
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -5452,6 +5452,10 @@ define_function(
// :func does not use Vim9 script syntax, even in a Vim9 script file
fp->uf_script_ctx.sc_version = SCRIPT_VERSION_MAX;
+ // If test_override('defcompile' 1) is used, then compile the function now
+ if (eap->cmdidx == CMD_def && override_defcompile)
+ defcompile_function(fp, NULL);
+
goto ret_free;
erret:
diff --git a/src/version.c b/src/version.c
index 46d9c1afe8..a3bc3f982a 100644
--- a/src/version.c
+++ b/src/version.c
@@ -705,6 +705,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 391,
+/**/
390,
/**/
389,