Compare commits

...

29 Commits

Author SHA1 Message Date
8314454648 patch 8.2.1359: Vim9: cannot assign to / register in Vim9 script
Problem:    Vim9: cannot assign to / register in Vim9 script.
Solution:   Adjust check for assignment in Vim9 script. (closes #6567)
2020-08-02 20:40:43 +02:00
434d72cbf2 patch 8.2.1358: Vim9: test fails with +dnd is not available
Problem:    Vim9: test fails with +dnd is not available.
Solution:   Add condition.
2020-08-02 20:03:25 +02:00
658217276f patch 8.2.1357: Vim9: cannot assign to / register
Problem:    Vim9: cannot assign to / register.
Solution:   Adjust check for assignment.
2020-08-02 18:58:54 +02:00
7226e5b19b patch 8.2.1356: Vim9: cannot get the percent register
Problem:    Vim9: cannot get the percent register.
Solution:   Check for readable registers instead of writable. (closes #6566)
2020-08-02 17:33:26 +02:00
c2ee44cc38 patch 8.2.1355: Vim9: no error using :let for options and registers
Problem:    Vim9: no error using :let for options and registers.
Solution:   Give an error. (closes #6568)
2020-08-02 16:59:00 +02:00
aa970abd0a patch 8.2.1354: test 59 is old style
Problem:    Test 59 is old style.
Solution:   Convert into a new style test. (Yegappan Lakshmanan, closes #6604)
2020-08-02 16:10:39 +02:00
8b89614e69 patch 8.2.1353: crash when drawing double-wide character in terminal window
Problem:    Crash when drawing double-wide character in terminal window.
            (Masato Nishihata)
Solution:   Check getcell() returning NULL. (issue #6141)
2020-08-02 15:05:05 +02:00
ad486a0f0d patch 8.2.1352: Vim9: no error for shadowing a script-local function
Problem:    Vim9: no error for shadowing a script-local function by a nested
            function.
Solution:   Check for script-local function. (closes #6586)
2020-08-01 23:22:18 +02:00
bcbf41395f patch 8.2.1351: Vim9: no proper error if using namespace for nested function
Problem:    Vim9: no proper error if using namespace for nested function.
Solution:   Specifically check for a namespace. (closes #6582)
2020-08-01 22:35:13 +02:00
b9a2cac3ef patch 8.2.1350: Vim9: no test for error message when redefining function
Problem:    Vim9: no test for error message when redefining function.
Solution:   Add a test.
2020-08-01 22:23:20 +02:00
eef2102e20 patch 8.2.1349: Vim9: can define a function with the name of an import
Problem:    Vim9: can define a function with the name of an import.
Solution:   Disallow using an existing name. (closes #6585)
2020-08-01 22:16:43 +02:00
e4218b9416 patch 8.2.1348: build failure without the eval feature
Problem:    Build failure without the eval feature.
Solution:   Add #ifdef.
2020-08-01 21:11:38 +02:00
909443028b patch 8.2.1347: cannot easily get the script ID
Problem:    Cannot easily get the script ID.
Solution:   Support expand('<SID>').
2020-08-01 20:45:11 +02:00
491799be50 patch 8.2.1346: small build fails
Problem:    Small build fails.
Solution:   Add #ifdef.
2020-08-01 19:23:43 +02:00
f8992d47cd patch 8.2.1345: Redraw error when using visual block and scroll
Problem:    Redraw error when using visual block and scroll.
Solution:   Add check for w_topline. ( closes #6597)
2020-08-01 19:14:13 +02:00
2c79e9d14d patch 8.2.1344: Vim9: No test for trying to redefine global function
Problem:    Vim9: No test for trying to redefine global function.
Solution:   Add a test.
2020-08-01 18:57:52 +02:00
333894b195 patch 8.2.1343: Vim9: cannot find global function when using g:
Problem:    Vim9: cannot find global function when using g: when local
            function with the same name exists.
Solution:   Find global function when using g:.
2020-08-01 18:53:07 +02:00
f5a48010ef patch 8.2.1342: Vim9: accidentally using "t" gives a confusing error
Problem:    Vim9: accidentally using "x" gives a confusing error.
Solution:   Disallow using ":t" in Vim9 script. (issue #6399)
2020-08-01 17:00:03 +02:00
2ec208172c patch 8.2.1341: build failures
Problem:    Build failures.
Solution:   Add missing error message.
2020-08-01 16:35:08 +02:00
b86abadf87 patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Problem:    Some tests fail on Cirrus CI and/or with FreeBSD.
Solution:   Make 'backupskip' empty. Do not run tests as root. Check for
            directory when using viminfo. (Ozaki Kiichi, closes #6596)
2020-08-01 16:08:19 +02:00
2caa1594e7 patch 8.2.1339: Vim9: assigning to global dict variable doesn't work
Problem:    Vim9: assigning to global dict variable doesn't work.
Solution:   Guess variable type based in index type. (issue #6591)
2020-08-01 15:53:19 +02:00
8e4c8c853e patch 8.2.1338: Vim9: assigning to script-local variable doesn't check type
Problem:    Vim9: assigning to script-local variable doesn't check type.
Solution:   Use the type. (issue #6591)
2020-08-01 15:38:38 +02:00
586268721d patch 8.2.1337: Vim9: cannot use empty key in dict assignment
Problem:    Vim9: cannot use empty key in dict assignment.
Solution:   Allow empty key. (closes #6591)
2020-08-01 14:06:38 +02:00
af50e899e7 patch 8.2.1336: build failure on non-Unix systems
Problem:    Build failure on non-Unix systems.
Solution:   Add #ifdef.
2020-08-01 13:22:10 +02:00
4e1d8bd79b patch 8.2.1335: CTRL-C in the GUI doesn't interrupt
Problem:    CTRL-C in the GUI doesn't interrupt. (Sergey Vlasov)
Solution:   Recognize "C" with CTRL modifier as CTRL-C. (issue #6565)
2020-08-01 13:10:14 +02:00
b53da7918c patch 8.2.1334: Github workflow timeout needs tuning
Problem:    Github workflow timeout needs tuning
Solution:   Use a 10 minute timeout. Fail when timing out. (Ken Takata,
            closes #6590)
2020-08-01 12:26:04 +02:00
af8edbb8dc patch 8.2.1333: Vim9: memory leak when using nested global function
Problem:    Vim9: memory leak when using nested global function.
Solution:   Swap from and to when copying the lines.
2020-08-01 00:03:09 +02:00
ce6583568f patch 8.2.1332: Vim9: memory leak when using nested global function
Problem:    Vim9: memory leak when using nested global function.
Solution:   Delete the function when deleting the instruction.  Disable test
            that still causes a leak.
2020-07-31 23:47:12 +02:00
badd8486f7 patch 8.2.1331: Vim9: :echo with two lists doesn't work
Problem:    Vim9: :echo with two lists doesn't work.
Solution:   Do not skip white space before []. (closes #6552)
2020-07-31 22:38:17 +02:00
39 changed files with 1461 additions and 1156 deletions

View File

@ -11,6 +11,9 @@ freebsd_12_task:
- NPROC=$(getconf _NPROCESSORS_ONLN)
- ./configure --with-features=${FEATURES}
- make -j${NPROC}
- src/vim --version
test_script:
- make test
- src/vim --version
# run tests as user "cirrus" instead of root
- pw useradd cirrus -m
- chown -R cirrus:cirrus .
- sudo -u cirrus make test

View File

@ -210,14 +210,18 @@ jobs:
echo %COL_GREEN%Wait for vim tests to finish.%COL_RESET%
cd ..\src2\testdir
:: Wait about 5 minutes.
for /L %%i in (1,1,300) do (
:: Wait about 10 minutes.
for /L %%i in (1,1,600) do (
if exist done.txt goto exitloop
ping -n 2 localhost > nul
)
echo %COL_RED%Timed out.%COL_RESET%
set timeout=1
:exitloop
echo %COL_GREEN%Test results of vim:%COL_RESET%
if exist messages type messages
nmake -nologo -f Make_dos.mak report VIMPROG=..\..\src\vim || exit 1
if "%timeout%"=="1" (
echo %COL_RED%Timed out.%COL_RESET%
exit 1
)

View File

@ -1,4 +1,4 @@
*eval.txt* For Vim version 8.2. Last change: 2020 Jul 21
*eval.txt* For Vim version 8.2. Last change: 2020 Aug 01
VIM REFERENCE MANUAL by Bram Moolenaar
@ -4273,6 +4273,8 @@ expand({expr} [, {nosuf} [, {list}]]) *expand()*
line number
<sflnum> script file line number, also when in
a function
<SID> "<SNR>123_" where "123" is the
current script ID |<SID>|
<cword> word under the cursor
<cWORD> WORD under the cursor
<client> the {clientid} of the last received
@ -12129,7 +12131,8 @@ text...
{endmarker}
Set internal variable {var-name} to a |List|
containing the lines of text bounded by the string
{endmarker}.
{endmarker}. The lines of text is used as a
|literal-string|.
{endmarker} must not contain white space.
{endmarker} cannot start with a lower case character.
The last line should end only with the {endmarker}

View File

@ -1167,6 +1167,10 @@ When executing an autocommand or a user command, it will run in the context of
the script it was defined in. This makes it possible that the command calls a
local function or uses a local mapping.
In case the value is used in a context where <SID> cannot be correctly
expanded, use the expand() function: >
let &includexpr = expand('<SID>') .. 'My_includeexpr()'
Otherwise, using "<SID>" outside of a script context is an error.
If you need to get the script number to use in a complicated script, you can

View File

@ -190,8 +190,8 @@ To intentionally avoid a variable being available later, a block can be used:
An existing variable cannot be assigned to with `:let`, since that implies a
declaration. Global, window, tab, buffer and Vim variables can only be used
without `:let`, because they are are not really declared, they can also be
deleted with `:unlet`.
without `:let`, because they are not really declared, they can also be deleted
with `:unlet`.
Variables cannot shadow previously defined variables.
Variables may shadow Ex commands, rename the variable if needed.
@ -352,10 +352,11 @@ No curly braces expansion ~
|curly-braces-names| cannot be used.
No :xit, :append, :change or :insert ~
No :xit, :t, :append, :change or :insert ~
These commands are too easily confused with local variable names. Instead of
`:x` or `:xit` you can use `:exit`.
These commands are too easily confused with local variable names.
Instead of `:x` or `:xit` you can use `:exit`.
Instead of `:t` you can use `:copy`.
Comparators ~

View File

@ -2310,7 +2310,7 @@ test_libvterm:
# Run individual OLD style test.
# These do not depend on the executable, compile it when needed.
test1 test49 test59:
test1 test49:
cd testdir; rm -f $@.out; $(MAKE) -f Makefile $@.out VIMPROG=../$(VIMTESTTARGET) $(GUI_TESTARG) SCRIPTSOURCE=../$(SCRIPTSOURCE)
# Run individual NEW style test.

View File

@ -1659,10 +1659,13 @@ win_update(win_T *wp)
#endif
)
{
if (mod_top != 0 && wp->w_topline == mod_top)
if (mod_top != 0
&& wp->w_topline == mod_top
&& (!wp->w_lines[0].wl_valid
|| wp->w_topline == wp->w_lines[0].wl_lnum))
{
// w_topline is the first changed line, the scrolling will be done
// further down.
// w_topline is the first changed line and window is not scrolled,
// the scrolling from changed lines will be done further down.
}
else if (wp->w_lines[0].wl_valid
&& (wp->w_topline < wp->w_lines[0].wl_lnum

View File

@ -1219,6 +1219,13 @@ ex_let_one(
int opt_flags;
char_u *tofree = NULL;
if (in_vim9script() && (flags & LET_NO_COMMAND) == 0
&& vim_strchr((char_u *)"$@&", *arg) != NULL)
{
vim9_declare_error(arg);
return NULL;
}
// ":let $VAR = expr": Set environment variable.
if (*arg == '$')
{
@ -1227,11 +1234,6 @@ ex_let_one(
emsg(_("E996: Cannot lock an environment variable"));
return NULL;
}
if (in_vim9script() && (flags & LET_NO_COMMAND) == 0)
{
vim9_declare_error(arg);
return NULL;
}
// Find the end of the name.
++arg;
@ -2427,7 +2429,7 @@ eval_variable(
else
{
scriptitem_T *si = SCRIPT_ITEM(import->imp_sid);
svar_T *sv = ((svar_T *)si->sn_var_vals.ga_data)
svar_T *sv = ((svar_T *)si->sn_var_vals.ga_data)
+ import->imp_var_vals_idx;
tv = sv->sv_tv;
}

View File

@ -3274,10 +3274,10 @@ find_ex_command(
if (lookup != NULL)
{
// Skip over first char for "&opt = val", "$ENV = val" and "@r = val".
char_u *pskip = (*eap->cmd == '&' || *eap->cmd == '$'
|| *eap->cmd == '@') ? eap->cmd + 1 : eap->cmd;
char_u *pskip = (*eap->cmd == '&' || *eap->cmd == '$')
? eap->cmd + 1 : eap->cmd;
if (vim_strchr((char_u *)"{('[\"", *p) != NULL
if (vim_strchr((char_u *)"{('[\"@", *p) != NULL
|| ((p = to_name_const_end(pskip)) > eap->cmd && *p != NUL))
{
int oplen;
@ -3336,6 +3336,8 @@ find_ex_command(
// Recognize an assignment if we recognize the variable name:
// "g:var = expr"
// "var = expr" where "var" is a local var name.
if (*eap->cmd == '@')
p = eap->cmd + 2;
oplen = assignment_len(skipwhite(p), &heredoc);
if (oplen > 0)
{
@ -7276,6 +7278,10 @@ ex_copymove(exarg_T *eap)
{
long n;
#ifdef FEAT_EVAL
if (not_in_vim9(eap) == FAIL)
return;
#endif
n = get_address(eap, &eap->arg, eap->addr_type, FALSE, FALSE, FALSE, 1);
if (eap->arg == NULL) // error detected
{
@ -8298,9 +8304,11 @@ find_cmdline_var(char_u *src, int *usedlen)
#define SPEC_AMATCH (SPEC_ABUF + 1)
"<sflnum>", // script file line number
#define SPEC_SFLNUM (SPEC_AMATCH + 1)
"<SID>", // script ID: <SNR>123_
#define SPEC_SID (SPEC_SFLNUM + 1)
#ifdef FEAT_CLIENTSERVER
"<client>"
# define SPEC_CLIENT (SPEC_SFLNUM + 1)
# define SPEC_CLIENT (SPEC_SID + 1)
#endif
};
@ -8575,6 +8583,16 @@ eval_vars(
(long)(current_sctx.sc_lnum + SOURCING_LNUM));
result = strbuf;
break;
case SPEC_SID:
if (current_sctx.sc_sid <= 0)
{
*errormsg = _(e_usingsid);
return NULL;
}
sprintf((char *)strbuf, "<SNR>%d_", current_sctx.sc_sid);
result = strbuf;
break;
#endif
#ifdef FEAT_CLIENTSERVER

View File

@ -1684,6 +1684,7 @@ EXTERN char e_readonlysbx[] INIT(= N_("E794: Cannot set variable in the sandbox:
EXTERN char e_stringreq[] INIT(= N_("E928: String required"));
EXTERN char e_emptykey[] INIT(= N_("E713: Cannot use empty key for Dictionary"));
EXTERN char e_dictreq[] INIT(= N_("E715: Dictionary required"));
EXTERN char e_dictnull[] INIT(= N_("E1103: Dictionary not set"));
EXTERN char e_listidx[] INIT(= N_("E684: list index out of range: %ld"));
EXTERN char e_blobidx[] INIT(= N_("E979: Blob index out of range: %ld"));
EXTERN char e_invalblob[] INIT(= N_("E978: Invalid operation for Blob"));
@ -1745,6 +1746,7 @@ EXTERN char e_missing_dict_colon[] INIT(= N_("E720: Missing colon in Dictionary:
EXTERN char e_duplicate_key[] INIT(= N_("E721: Duplicate key in Dictionary: \"%s\""));
EXTERN char e_missing_dict_comma[] INIT(= N_("E722: Missing comma in Dictionary: %s"));
EXTERN char e_missing_dict_end[] INIT(= N_("E723: Missing end of Dictionary '}': %s"));
EXTERN char e_already_defined[] INIT(= N_("E1073: name already defined: %s"));
#endif
#ifdef FEAT_CLIENTSERVER
EXTERN char e_invexprmsg[] INIT(= N_("E449: Invalid expression received"));

View File

@ -5575,3 +5575,27 @@ gui_handle_drop(
entered = FALSE;
}
#endif
/*
* Check if "key" is to interrupt us. Handles a key that has not had modifiers
* applied yet.
* Return the key with modifiers applied if so, NUL if not.
*/
int
check_for_interrupt(int key, int modifiers_arg)
{
int modifiers = modifiers_arg;
int c = merge_modifyOtherKeys(key, &modifiers);
if ((c == Ctrl_C && ctrl_c_interrupts)
#ifdef UNIX
|| (intr_char != Ctrl_C && c == intr_char)
#endif
)
{
got_int = TRUE;
return c;
}
return NUL;
}

View File

@ -1254,11 +1254,16 @@ key_press_event(GtkWidget *widget UNUSED,
add_to_input_buf(string2, 3);
}
if (len == 1 && ((string[0] == Ctrl_C && ctrl_c_interrupts)
|| (string[0] == intr_char && intr_char != Ctrl_C)))
// Check if the key interrupts.
{
trash_input_buf();
got_int = TRUE;
int int_ch = check_for_interrupt(key, modifiers);
if (int_ch != NUL)
{
trash_input_buf();
string[0] = int_ch;
len = 1;
}
}
add_to_input_buf(string, len);

View File

@ -596,11 +596,17 @@ gui_ph_handle_keyboard(PtWidget_t *widget, void *data, PtCallbackInfo_t *info)
string[ len++ ] = ch;
}
if (len == 1 && ((ch == Ctrl_C && ctrl_c_interrupts)
|| ch == intr_char))
// Check if the key interrupts.
{
trash_input_buf();
got_int = TRUE;
int int_ch = check_for_interrupt(ch, modifiers);
if (int_ch != NUL)
{
ch = int_ch;
string[0] = ch;
len = 1;
trash_input_buf();
}
}
if (len == 1 && string[0] == CSI)

View File

@ -970,14 +970,16 @@ gui_x11_key_hit_cb(
add_to_input_buf(string2, 3);
}
if (len == 1 && ((string[0] == Ctrl_C && ctrl_c_interrupts)
#ifdef UNIX
|| (intr_char != 0 && string[0] == intr_char)
#endif
))
// Check if the key interrupts.
{
trash_input_buf();
got_int = TRUE;
int int_ch = check_for_interrupt(key, modifiers);
if (int_ch != NUL)
{
trash_input_buf();
string[0] = int_ch;
len = 1;
}
}
add_to_input_buf(string, len);

View File

@ -186,7 +186,12 @@ static int putglyph(VTermGlyphInfo *info, VTermPos pos, void *user)
cell->chars[i] = 0;
for(col = 1; col < info->width; col++)
getcell(screen, pos.row, pos.col + col)->chars[0] = (uint32_t)-1;
{
ScreenCell *onecell = getcell(screen, pos.row, pos.col + col);
if (onecell == NULL)
break;
onecell->chars[0] = (uint32_t)-1;
}
rect.start_row = pos.row;
rect.end_row = pos.row+1;

View File

@ -65,4 +65,5 @@ void gui_update_screen(void);
char_u *get_find_dialog_text(char_u *arg, int *wwordp, int *mcasep);
int gui_do_findrepl(int flags, char_u *find_text, char_u *repl_text, int down);
void gui_handle_drop(int x, int y, int_u modifiers, char_u **fnames, int count);
int check_for_interrupt(int key, int modifiers_arg);
/* vim: set ft=c : */

View File

@ -5,12 +5,13 @@ int get_function_args(char_u **argp, char_u endchar, garray_T *newargs, garray_T
char_u *get_lambda_name(void);
char_u *register_cfunc(cfunc_T cb, cfunc_free_T cb_free, void *state);
int get_lambda_tv(char_u **arg, typval_T *rettv, evalarg_T *evalarg);
void copy_func(char_u *lambda, char_u *global);
char_u *deref_func_name(char_u *name, int *lenp, partial_T **partialp, int no_autoload);
void emsg_funcname(char *ermsg, char_u *name);
int get_func_tv(char_u *name, int len, typval_T *rettv, char_u **arg, evalarg_T *evalarg, funcexe_T *funcexe);
char_u *fname_trans_sid(char_u *name, char_u *fname_buf, char_u **tofree, int *error);
ufunc_T *find_func_even_dead(char_u *name, int is_global, cctx_T *cctx);
ufunc_T *find_func(char_u *name, int is_global, cctx_T *cctx);
void copy_func(char_u *lambda, char_u *global);
int call_user_func_check(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rettv, funcexe_T *funcexe, dict_T *selfdict);
void save_funccal(funccal_entry_T *entry);
void restore_funccal(void);

View File

@ -20,7 +20,7 @@ SCRIPTS_MORE1 =
SCRIPTS_MORE2 = test49.out
# Tests that run on most systems, but not on VMS
SCRIPTS_MORE4 = test59.out
SCRIPTS_MORE4 =
# Tests specifically for MS-Windows.
SCRIPTS_WIN32 =
@ -242,6 +242,7 @@ NEW_TESTS = \
test_source \
test_source_utf8 \
test_spell \
test_spell_utf8 \
test_spellfile \
test_startup \
test_startup_utf8 \
@ -464,6 +465,7 @@ NEW_TESTS_RES = \
test_sound.res \
test_source.res \
test_spell.res \
test_spell_utf8.res \
test_spellfile.res \
test_startup.res \
test_stat.res \

View File

@ -32,22 +32,6 @@
# and directory handling.
# WANT_UNIX = YES
# Comment out if you want to run Win32 specific tests as well, but please
# be aware, that on OpenVMS will fail, because of cat, rm, etc commands
# and directory handling.
# WANT_WIN = YES
# Comment out if you want to run spell checker tests.
# They fail because VMS does not support file names.
# WANT_SPELL = YES
# Comment out if you want to run mzschema tests.
# It fails because VMS does not support this feature yet.
# WANT_MZSCH = YES
# Comment out if you have ODS-5 file system
# HAVE_ODS5 = YES
# Comment out if you have gzip on your system
# HAVE_GZIP = YES
@ -75,12 +59,6 @@ VIMPROG = <->vim.exe
SCRIPT = test1.out test49.out test77a.out
# Known problems:
#
# test59: Failed/Hangs - VMS does not support spell files (file names
# with too many dots).
#
.IFDEF WANT_GUI
GUI_OPTION = -g
.ENDIF
@ -89,10 +67,6 @@ GUI_OPTION = -g
SCRIPT_UNIX = test49.out
.ENDIF
.IFDEF WANT_SPELL
SCRIPT_SPELL = test59.out
.ENDIF
.in.out :
-@ !clean up before doing the test
-@ if "''F$SEARCH("test.out.*")'" .NES. "" then delete/noconfirm/nolog test.out.*
@ -113,8 +87,7 @@ SCRIPT_SPELL = test59.out
-@ if "''F$SEARCH("Xdotest.*")'" .NES. "" then delete/noconfirm/nolog Xdotest.*.*
-@ if "''F$SEARCH("Xtest.*")'" .NES. "" then delete/noconfirm/nolog Xtest.*.*
all : clean nolog $(START_WITH) $(SCRIPT) $(SCRIPT_UNIX) $(SCRIPT_SPELL) \
nolog
all : clean nolog $(START_WITH) $(SCRIPT) $(SCRIPT_UNIX) nolog
-@ write sys$output " "
-@ write sys$output "-----------------------------------------------"
-@ write sys$output " All done"
@ -139,10 +112,6 @@ nolog :
-@ write sys$output "MAKE_VMS.MMS options:"
-@ write sys$output " WANT_GUI = ""$(WANT_GUI)"" "
-@ write sys$output " WANT_UNIX = ""$(WANT_UNIX)"" "
-@ write sys$output " WANT_WIN = ""$(WANT_WIN)"" "
-@ write sys$output " WANT_SPELL = ""$(WANT_SPELL)"" "
-@ write sys$output " WANT_MZSCH = ""$(WANT_MZSCH)"" "
-@ write sys$output " HAVE_ODS5 = ""$(HAVE_ODS5)"" "
-@ write sys$output " HAVE_GZIP = ""$(HAVE_GZIP)"" "
-@ write sys$output " HAVE_GDIFF = ""$(HAVE_GDIFF)"" "
-@ write sys$output " HAVE_ICONV = ""$(HAVE_ICONV)"" "

View File

@ -0,0 +1,7 @@
|{+0&#e0e0e08| | +0&#ffffff0@72
|}+0&#e0e0e08| | +0&#ffffff0@72
|{+0&#e0e0e08| | +0&#ffffff0@72
|f+0&#e0e0e08| | +0&#ffffff0@72
>g| +0&#e0e0e08| +0&#ffffff0@72
|}| @73
|-+2&&@1| |V|I|S|U|A|L| |L|I|N|E| |-@1| +0&&@29|7| @8|1@1|,|1| @9|B|o|t|

View File

@ -1,626 +0,0 @@
Tests for spell checking with 'encoding' set to "utf-8". vim: set ft=vim :
STARTTEST
:so small.vim
:so mbyte.vim
:"
:" Don't want to depend on the locale from the environment. The .aff and .dic
:" text is in latin1, the test text is utf-8.
:set enc=latin1
:e!
:set enc=utf-8
:set fenc=
:"
:" Function to test .aff/.dic with list of good and bad words.
:func TestOne(aff, dic)
set spellfile=
$put =''
$put ='test '. a:aff . '-' . a:dic
" Generate a .spl file from a .dic and .aff file.
exe '1;/^' . a:aff . 'affstart/+1,/^' . a:aff . 'affend/-1w! Xtest.aff'
exe '1;/^' . a:dic . 'dicstart/+1,/^' . a:dic . 'dicend/-1w! Xtest.dic'
mkspell! Xtest Xtest
" use that spell file
set spl=Xtest.utf-8.spl spell
" list all valid words
spelldump
%yank
quit
$put
$put ='-------'
" find all bad words and suggestions for them
exe '1;/^' . a:aff . 'good:'
normal 0f:]s
let prevbad = ''
while 1
let [bad, a] = spellbadword()
if bad == '' || bad == prevbad || bad == 'badend'
break
endif
let prevbad = bad
let lst = spellsuggest(bad, 3)
normal mm
$put =bad
$put =string(lst)
normal `m]s
endwhile
endfunc
:"
:call TestOne('1', '1')
:$put =soundfold('goobledygoook')
:$put =soundfold('kóopërÿnôven')
:$put =soundfold('oeverloos gezwets edale')
:"
:"
:" and now with SAL instead of SOFO items; test automatic reloading
gg:/^affstart_sal/+1,/^affend_sal/-1w! Xtest.aff
:mkspell! Xtest Xtest
:$put =soundfold('goobledygoook')
:$put =soundfold('kóopërÿnôven')
:$put =soundfold('oeverloos gezwets edale')
:"
:" also use an addition file
gg:/^addstart/+1,/^addend/-1w! Xtest.utf-8.add
:mkspell! Xtest.utf-8.add.spl Xtest.utf-8.add
:set spellfile=Xtest.utf-8.add
/^test2:
]s:let [str, a] = spellbadword()
:$put =str
:set spl=Xtest_us.utf-8.spl
/^test2:
]smm:let [str, a] = spellbadword()
:$put =str
`m]s:let [str, a] = spellbadword()
:$put =str
:set spl=Xtest_gb.utf-8.spl
/^test2:
]smm:let [str, a] = spellbadword()
:$put =str
`m]s:let [str, a] = spellbadword()
:$put =str
:set spl=Xtest_nz.utf-8.spl
/^test2:
]smm:let [str, a] = spellbadword()
:$put =str
`m]s:let [str, a] = spellbadword()
:$put =str
:set spl=Xtest_ca.utf-8.spl
/^test2:
]smm:let [str, a] = spellbadword()
:$put =str
`m]s:let [str, a] = spellbadword()
:$put =str
:unlet str a
:"
:" Postponed prefixes
:call TestOne('2', '1')
:"
:" Compound words
:call TestOne('3', '3')
:call TestOne('4', '4')
:call TestOne('5', '5')
:call TestOne('6', '6')
:call TestOne('7', '7')
:"
:" clean up for valgrind
:delfunc TestOne
:set spl= enc=latin1
:"
gg:/^test output:/,$wq! test.out
ENDTEST
1affstart
SET ISO8859-1
TRY esianrtolcdugmphbyfvkwjkqxz-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'ESIANRTOLCDUGMPHBYFVKWJKQXZ
FOL <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
LOW <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPP <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
SOFOFROM abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ<59><5A><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޿
SOFOTO ebctefghejklnnepkrstevvkesebctefghejklnnepkrstevvkeseeeeeeeceeeeeeeedneeeeeeeeeeepseeeeeeeeceeeeeeeedneeeeeeeeeeep?
MIDWORD '-
KEP =
RAR ?
BAD !
#NOSPLITSUGS
PFX I N 1
PFX I 0 in .
PFX O Y 1
PFX O 0 out .
SFX S Y 2
SFX S 0 s [^s]
SFX S 0 es s
SFX N N 3
SFX N 0 en [^n]
SFX N 0 nen n
SFX N 0 n .
REP 3
REP g ch
REP ch g
REP svp s.v.p.
MAP 9
MAP a<><61><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
MAP e<><65><EFBFBD><EFBFBD>
MAP i<><69><EFBFBD><EFBFBD>
MAP o<><6F><EFBFBD><EFBFBD><EFBFBD>
MAP u<><75><EFBFBD><EFBFBD>
MAP n<>
MAP c<>
MAP y<><79>
MAP s<>
1affend
affstart_sal
SET ISO8859-1
TRY esianrtolcdugmphbyfvkwjkqxz-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'ESIANRTOLCDUGMPHBYFVKWJKQXZ
FOL <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
LOW <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPP <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
MIDWORD '-
KEP =
RAR ?
BAD !
#NOSPLITSUGS
PFX I N 1
PFX I 0 in .
PFX O Y 1
PFX O 0 out .
SFX S Y 2
SFX S 0 s [^s]
SFX S 0 es s
SFX N N 3
SFX N 0 en [^n]
SFX N 0 nen n
SFX N 0 n .
REP 3
REP g ch
REP ch g
REP svp s.v.p.
MAP 9
MAP a<><61><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
MAP e<><65><EFBFBD><EFBFBD>
MAP i<><69><EFBFBD><EFBFBD>
MAP o<><6F><EFBFBD><EFBFBD><EFBFBD>
MAP u<><75><EFBFBD><EFBFBD>
MAP n<>
MAP c<>
MAP y<><79>
MAP s<>
SAL AH(AEIOUY)-^ *H
SAL AR(AEIOUY)-^ *R
SAL A(HR)^ *
SAL A^ *
SAL AH(AEIOUY)- H
SAL AR(AEIOUY)- R
SAL A(HR) _
SAL <20>^ *
SAL <20>^ *
SAL BB- _
SAL B B
SAL CQ- _
SAL CIA X
SAL CH X
SAL C(EIY)- S
SAL CK K
SAL COUGH^ KF
SAL CC< C
SAL C K
SAL DG(EIY) K
SAL DD- _
SAL D T
SAL <20>< E
SAL EH(AEIOUY)-^ *H
SAL ER(AEIOUY)-^ *R
SAL E(HR)^ *
SAL ENOUGH^$ *NF
SAL E^ *
SAL EH(AEIOUY)- H
SAL ER(AEIOUY)- R
SAL E(HR) _
SAL FF- _
SAL F F
SAL GN^ N
SAL GN$ N
SAL GNS$ NS
SAL GNED$ N
SAL GH(AEIOUY)- K
SAL GH _
SAL GG9 K
SAL G K
SAL H H
SAL IH(AEIOUY)-^ *H
SAL IR(AEIOUY)-^ *R
SAL I(HR)^ *
SAL I^ *
SAL ING6 N
SAL IH(AEIOUY)- H
SAL IR(AEIOUY)- R
SAL I(HR) _
SAL J K
SAL KN^ N
SAL KK- _
SAL K K
SAL LAUGH^ LF
SAL LL- _
SAL L L
SAL MB$ M
SAL MM M
SAL M M
SAL NN- _
SAL N N
SAL OH(AEIOUY)-^ *H
SAL OR(AEIOUY)-^ *R
SAL O(HR)^ *
SAL O^ *
SAL OH(AEIOUY)- H
SAL OR(AEIOUY)- R
SAL O(HR) _
SAL PH F
SAL PN^ N
SAL PP- _
SAL P P
SAL Q K
SAL RH^ R
SAL ROUGH^ RF
SAL RR- _
SAL R R
SAL SCH(EOU)- SK
SAL SC(IEY)- S
SAL SH X
SAL SI(AO)- X
SAL SS- _
SAL S S
SAL TI(AO)- X
SAL TH @
SAL TCH-- _
SAL TOUGH^ TF
SAL TT- _
SAL T T
SAL UH(AEIOUY)-^ *H
SAL UR(AEIOUY)-^ *R
SAL U(HR)^ *
SAL U^ *
SAL UH(AEIOUY)- H
SAL UR(AEIOUY)- R
SAL U(HR) _
SAL V^ W
SAL V F
SAL WR^ R
SAL WH^ W
SAL W(AEIOU)- W
SAL X^ S
SAL X KS
SAL Y(AEIOU)- Y
SAL ZZ- _
SAL Z S
affend_sal
2affstart
SET ISO8859-1
FOL <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
LOW <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPP <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
PFXPOSTPONE
MIDWORD '-
KEP =
RAR ?
BAD !
#NOSPLITSUGS
PFX I N 1
PFX I 0 in .
PFX O Y 1
PFX O 0 out [a-z]
SFX S Y 2
SFX S 0 s [^s]
SFX S 0 es s
SFX N N 3
SFX N 0 en [^n]
SFX N 0 nen n
SFX N 0 n .
REP 3
REP g ch
REP ch g
REP svp s.v.p.
MAP 9
MAP a<><61><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
MAP e<><65><EFBFBD><EFBFBD>
MAP i<><69><EFBFBD><EFBFBD>
MAP o<><6F><EFBFBD><EFBFBD><EFBFBD>
MAP u<><75><EFBFBD><EFBFBD>
MAP n<>
MAP c<>
MAP y<><79>
MAP s<>
2affend
1dicstart
123456
test/NO
# comment
wrong
Comment
OK
uk
put/ISO
the end
deol
d<EFBFBD><EFBFBD>r
1dicend
addstart
/regions=usgbnz
elequint/2
elekwint/3
addend
1good: wrong OK puts. Test the end
bad: inputs comment ok Ok. test déôl end the
badend
2good: puts
bad: inputs comment ok Ok end the. test déôl
badend
Test rules for compounding.
3affstart
SET ISO8859-1
COMPOUNDMIN 3
COMPOUNDRULE m*
NEEDCOMPOUND x
3affend
3dicstart
1234
foo/m
bar/mx
m<EFBFBD>/m
la/mx
3dicend
3good: foo mï foobar foofoobar barfoo barbarfoo
bad: bar la foomï barmï mïfoo mïbar mïmï lala mïla lamï foola labar
badend
Tests for compounding.
4affstart
SET ISO8859-1
FOL <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
LOW <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPP <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
COMPOUNDRULE m+
COMPOUNDRULE sm*e
COMPOUNDRULE sm+
COMPOUNDMIN 3
COMPOUNDWORDMAX 3
COMPOUNDFORBIDFLAG t
COMPOUNDSYLMAX 5
SYLLABLE a<>e<EFBFBD>i<EFBFBD>o<EFBFBD><6F><EFBFBD>u<EFBFBD><75><EFBFBD>y/aa/au/ea/ee/ei/ie/oa/oe/oo/ou/uu/ui
MAP 9
MAP a<><61><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
MAP e<><65><EFBFBD><EFBFBD>
MAP i<><69><EFBFBD><EFBFBD>
MAP o<><6F><EFBFBD><EFBFBD><EFBFBD>
MAP u<><75><EFBFBD><EFBFBD>
MAP n<>
MAP c<>
MAP y<><79>
MAP s<>
NEEDAFFIX x
PFXPOSTPONE
MIDWORD '-
SFX q N 1
SFX q 0 -ok .
SFX a Y 2
SFX a 0 s .
SFX a 0 ize/t .
PFX p N 1
PFX p 0 pre .
PFX P N 1
PFX P 0 nou .
4affend
4dicstart
1234
word/mP
util/am
pro/xq
tomato/m
bork/mp
start/s
end/e
4dicend
4good: word util bork prebork start end wordutil wordutils pro-ok
bork borkbork borkborkbork borkborkborkbork borkborkborkborkbork
tomato tomatotomato startend startword startwordword startwordend
startwordwordend startwordwordwordend prebork preborkbork
preborkborkbork
nouword
bad: wordutilize pro borkborkborkborkborkbork tomatotomatotomato
endstart endend startstart wordend wordstart
preborkprebork preborkpreborkbork
startwordwordwordwordend borkpreborkpreborkbork
utilsbork startnouword
badend
test2:
elequint test elekwint test elekwent asdf
Test affix flags with two characters
5affstart
SET ISO8859-1
FLAG long
NEEDAFFIX !!
COMPOUNDRULE ssmm*ee
NEEDCOMPOUND xx
COMPOUNDPERMITFLAG pp
SFX 13 Y 1
SFX 13 0 bork .
SFX a1 Y 1
SFX a1 0 a1 .
SFX a<> Y 1
SFX a<> 0 a<> .
PFX zz Y 1
PFX zz 0 pre/pp .
PFX yy Y 1
PFX yy 0 nou .
5affend
5dicstart
1234
foo/a1a<31>!!
bar/zz13ee
start/ss
end/eeyy
middle/mmxx
5dicend
5good: fooa1 fooaé bar prebar barbork prebarbork startprebar
start end startend startmiddleend nouend
bad: foo fooa2 prabar probarbirk middle startmiddle middleend endstart
startprobar startnouend
badend
6affstart
SET ISO8859-1
FLAG caplong
NEEDAFFIX A!
COMPOUNDRULE sMm*Ee
NEEDCOMPOUND Xx
COMPOUNDPERMITFLAG p
SFX N3 Y 1
SFX N3 0 bork .
SFX A1 Y 1
SFX A1 0 a1 .
SFX A<> Y 1
SFX A<> 0 a<> .
PFX Zz Y 1
PFX Zz 0 pre/p .
6affend
6dicstart
1234
mee/A1A<31>A!
bar/ZzN3Ee
lead/s
end/Ee
middle/MmXx
6dicend
6good: meea1 meeaé bar prebar barbork prebarbork leadprebar
lead end leadend leadmiddleend
bad: mee meea2 prabar probarbirk middle leadmiddle middleend endlead
leadprobar
badend
7affstart
SET ISO8859-1
FOL <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
LOW <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPP <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
FLAG num
NEEDAFFIX 9999
COMPOUNDRULE 2,77*123
NEEDCOMPOUND 1
COMPOUNDPERMITFLAG 432
SFX 61003 Y 1
SFX 61003 0 meat .
SFX 391 Y 1
SFX 391 0 a1 .
SFX 111 Y 1
SFX 111 0 a<> .
PFX 17 Y 1
PFX 17 0 pre/432 .
7affend
7dicstart
1234
mee/391,111,9999
bar/17,61003,123
lead/2
tail/123
middle/77,1
7dicend
7good: meea1 meeaé bar prebar barmeat prebarmeat leadprebar
lead tail leadtail leadmiddletail
bad: mee meea2 prabar probarmaat middle leadmiddle middletail taillead
leadprobar
badend
test output:

View File

@ -1,270 +0,0 @@
test output:
test 1-1
# file: Xtest.utf-8.spl
Comment
deol
déôr
input
OK
output
outputs
outtest
put
puts
test
testen
testn
the end
uk
wrong
-------
bad
['put', 'uk', 'OK']
inputs
['input', 'puts', 'outputs']
comment
['Comment', 'outtest', 'the end']
ok
['OK', 'uk', 'put']
Ok
['OK', 'Uk', 'Put']
test
['Test', 'testn', 'testen']
déôl
['deol', 'déôr', 'test']
end
['put', 'uk', 'test']
the
['put', 'uk', 'test']
gebletegek
kepereneven
everles gesvets etele
kbltykk
kprnfn
*fls kswts tl
elekwent
elequint
elekwint
elekwint
elekwent
elequint
elekwent
elequint
elekwint
test 2-1
# file: Xtest.utf-8.spl
Comment
deol
déôr
OK
put
input
output
puts
outputs
test
outtest
testen
testn
the end
uk
wrong
-------
bad
['put', 'uk', 'OK']
inputs
['input', 'puts', 'outputs']
comment
['Comment']
ok
['OK', 'uk', 'put']
Ok
['OK', 'Uk', 'Put']
end
['put', 'uk', 'deol']
the
['put', 'uk', 'test']
test
['Test', 'testn', 'testen']
déôl
['deol', 'déôr', 'test']
test 3-3
# file: Xtest.utf-8.spl
foo
-------
bad
['foo', 'mï']
bar
['barfoo', 'foobar', 'foo']
la
['mï', 'foo']
foomï
['foo mï', 'foo', 'foofoo']
barmï
['barfoo', 'mï', 'barbar']
mïfoo
['mï foo', 'foo', 'foofoo']
mïbar
['foobar', 'barbar', 'mï']
mïmï
['mï mï', 'mï']
lala
[]
mïla
['mï', 'mï mï']
lamï
['mï', 'mï mï']
foola
['foo', 'foobar', 'foofoo']
labar
['barbar', 'foobar']
test 4-4
# file: Xtest.utf-8.spl
bork
prebork
end
pro-ok
start
tomato
util
utilize
utils
word
nouword
-------
bad
['end', 'bork', 'word']
wordutilize
['word utilize', 'wordutils', 'wordutil']
pro
['bork', 'word', 'end']
borkborkborkborkborkbork
['bork borkborkborkborkbork', 'borkbork borkborkborkbork', 'borkborkbork borkborkbork']
tomatotomatotomato
['tomato tomatotomato', 'tomatotomato tomato', 'tomato tomato tomato']
endstart
['end start', 'start']
endend
['end end', 'end']
startstart
['start start']
wordend
['word end', 'word', 'wordword']
wordstart
['word start', 'bork start']
preborkprebork
['prebork prebork', 'preborkbork', 'preborkborkbork']
preborkpreborkbork
['prebork preborkbork', 'preborkborkbork', 'preborkborkborkbork']
startwordwordwordwordend
['startwordwordwordword end', 'startwordwordwordword', 'start wordwordwordword end']
borkpreborkpreborkbork
['bork preborkpreborkbork', 'bork prebork preborkbork', 'bork preborkprebork bork']
utilsbork
['utilbork', 'utils bork', 'util bork']
startnouword
['start nouword', 'startword', 'startborkword']
test 5-5
# file: Xtest.utf-8.spl
bar
barbork
end
fooa1
fooaé
nouend
prebar
prebarbork
start
-------
bad
['bar', 'end', 'fooa1']
foo
['fooa1', 'fooaé', 'bar']
fooa2
['fooa1', 'fooaé', 'bar']
prabar
['prebar', 'bar', 'bar bar']
probarbirk
['prebarbork']
middle
[]
startmiddle
['startmiddleend', 'startmiddlebar']
middleend
[]
endstart
['end start', 'start']
startprobar
['startprebar', 'start prebar', 'startbar']
startnouend
['start nouend', 'startend']
test 6-6
# file: Xtest.utf-8.spl
bar
barbork
end
lead
meea1
meeaé
prebar
prebarbork
-------
bad
['bar', 'end', 'lead']
mee
['meea1', 'meeaé', 'bar']
meea2
['meea1', 'meeaé', 'lead']
prabar
['prebar', 'bar', 'leadbar']
probarbirk
['prebarbork']
middle
[]
leadmiddle
['leadmiddleend', 'leadmiddlebar']
middleend
[]
endlead
['end lead', 'lead', 'end end']
leadprobar
['leadprebar', 'lead prebar', 'leadbar']
test 7-7
# file: Xtest.utf-8.spl
bar
barmeat
lead
meea1
meeaé
prebar
prebarmeat
tail
-------
bad
['bar', 'lead', 'tail']
mee
['meea1', 'meeaé', 'bar']
meea2
['meea1', 'meeaé', 'lead']
prabar
['prebar', 'bar', 'leadbar']
probarmaat
['prebarmeat']
middle
[]
leadmiddle
['leadmiddlebar']
middletail
[]
taillead
['tail lead', 'tail']
leadprobar
['leadprebar', 'lead prebar', 'leadbar']

View File

@ -19,6 +19,22 @@ func Test_backup()
call delete('Xbackup.txt~')
endfunc
func Test_backup_backupskip()
set backup backupdir=. backupskip=*.txt
new
call setline(1, ['line1', 'line2'])
:f Xbackup.txt
:w! Xbackup.txt
" backup file is only created after
" writing a second time (before overwriting)
:w! Xbackup.txt
call assert_false(filereadable('Xbackup.txt~'))
bw!
set backup&vim backupdir&vim backupskip&vim
call delete('Xbackup.txt')
call delete('Xbackup.txt~')
endfunc
func Test_backup2()
set backup backupdir=.// backupskip=
new
@ -30,7 +46,7 @@ func Test_backup2()
:w! Xbackup.txt
sp *Xbackup.txt~
call assert_equal(['line1', 'line2', 'line3'], getline(1,'$'))
let f=expand('%')
let f = expand('%')
call assert_match('%testdir%Xbackup.txt\~', f)
bw!
bw!
@ -50,7 +66,7 @@ func Test_backup2_backupcopy()
:w! Xbackup.txt
sp *Xbackup.txt~
call assert_equal(['line1', 'line2', 'line3'], getline(1,'$'))
let f=expand('%')
let f = expand('%')
call assert_match('%testdir%Xbackup.txt\~', f)
bw!
bw!
@ -61,14 +77,11 @@ endfunc
" Test for using a non-existing directory as a backup directory
func Test_non_existing_backupdir()
CheckNotBSD
let save_backup = &backupdir
set backupdir=./non_existing_dir
set backupdir=./non_existing_dir backupskip=
call writefile(['line1'], 'Xfile')
new Xfile
" TODO: write doesn't fail in Cirrus FreeBSD CI test
call assert_fails('write', 'E510:')
let &backupdir = save_backup
set backupdir&vim backupskip&vim
call delete('Xfile')
endfunc

View File

@ -220,3 +220,26 @@ func Test_unprintable_fileformats()
call delete('Xmac.txt')
call delete(filename)
endfunc
" Test for scrolling that modifies buffer during visual block
func Test_visual_block_scroll()
CheckScreendump
let lines =<< trim END
source $VIMRUNTIME/plugin/matchparen.vim
set scrolloff=1
call setline(1, ['a', 'b', 'c', 'd', 'e', '', '{', '}', '{', 'f', 'g', '}'])
call cursor(5, 1)
END
let filename = 'Xvisualblockmodifiedscroll'
call writefile(lines, filename)
let buf = RunVimInTerminal('-S '.filename, #{rows: 7})
call term_sendkeys(buf, "V\<C-D>\<C-D>")
call VerifyScreenDump(buf, 'Test_display_visual_block_scroll', {})
call StopVimInTerminal(buf)
call delete(filename)
endfunc

View File

@ -1682,7 +1682,6 @@ endfunc
" Test for editing a file without read permission
func Test_edit_file_no_read_perm()
CheckUnix
CheckNotBSD
call writefile(['one', 'two'], 'Xfile')
call setfperm('Xfile', '-w-------')
new

View File

@ -1,5 +1,7 @@
" Tests for expand()
source shared.vim
let s:sfile = expand('<sfile>')
let s:slnum = str2nr(expand('<slnum>'))
let s:sflnum = str2nr(expand('<sflnum>'))
@ -18,20 +20,20 @@ endfunc
" This test depends on the location in the test file, put it first.
func Test_expand_sflnum()
call assert_equal(5, s:sflnum)
call assert_equal(22, str2nr(expand('<sflnum>')))
call assert_equal(7, s:sflnum)
call assert_equal(24, str2nr(expand('<sflnum>')))
" Line-continuation
call assert_equal(
\ 25,
\ 27,
\ str2nr(expand('<sflnum>')))
" Call in script-local function
call assert_equal(16, s:expand_sflnum())
call assert_equal(18, s:expand_sflnum())
" Call in command
command Flnum echo expand('<sflnum>')
call assert_equal(34, str2nr(trim(execute('Flnum'))))
call assert_equal(36, str2nr(trim(execute('Flnum'))))
delcommand Flnum
endfunc
@ -60,7 +62,7 @@ func Test_expand_sfile_and_stack()
endfunc
func Test_expand_slnum()
call assert_equal(4, s:slnum)
call assert_equal(6, s:slnum)
call assert_equal(2, str2nr(expand('<slnum>')))
" Line-continuation
@ -86,6 +88,17 @@ func Test_expand()
quit
endfunc
func s:sid_test()
return 'works'
endfunc
func Test_expand_SID()
let sid = expand('<SID>')
execute 'let g:sid_result = ' .. sid .. 'sid_test()'
call assert_equal('works', g:sid_result)
endfunc
" Test for 'wildignore' with expand()
func Test_expand_wildignore()
set wildignore=*.vim

View File

@ -0,0 +1,768 @@
" Test for spell checking with 'encoding' set to utf-8
source check.vim
CheckFeature spell
scriptencoding utf-8
func TearDown()
set nospell
call delete('Xtest.aff')
call delete('Xtest.dic')
call delete('Xtest.utf-8.add')
call delete('Xtest.utf-8.add.spl')
call delete('Xtest.utf-8.spl')
call delete('Xtest.utf-8.sug')
endfunc
let g:test_data_aff1 = [
\"SET ISO8859-1",
\"TRY esianrtolcdugmphbyfvkwjkqxz-ëéèêïîäàâöüû'ESIANRTOLCDUGMPHBYFVKWJKQXZ",
\"",
\"FOL àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþßÿ",
\"LOW àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþßÿ",
\"UPP ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßÿ",
\"",
\"SOFOFROM abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xDF\xFF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xBF",
\"SOFOTO ebctefghejklnnepkrstevvkesebctefghejklnnepkrstevvkeseeeeeeeceeeeeeeedneeeeeeeeeeepseeeeeeeeceeeeeeeedneeeeeeeeeeep?",
\"",
\"MIDWORD\t'-",
\"",
\"KEP =",
\"RAR ?",
\"BAD !",
\"",
\"PFX I N 1",
\"PFX I 0 in .",
\"",
\"PFX O Y 1",
\"PFX O 0 out .",
\"",
\"SFX S Y 2",
\"SFX S 0 s [^s]",
\"SFX S 0 es s",
\"",
\"SFX N N 3",
\"SFX N 0 en [^n]",
\"SFX N 0 nen n",
\"SFX N 0 n .",
\"",
\"REP 3",
\"REP g ch",
\"REP ch g",
\"REP svp s.v.p.",
\"",
\"MAP 9",
\"MAP a\xE0\xE1\xE2\xE3\xE4\xE5",
\"MAP e\xE8\xE9\xEA\xEB",
\"MAP i\xEC\xED\xEE\xEF",
\"MAP o\xF2\xF3\xF4\xF5\xF6",
\"MAP u\xF9\xFA\xFB\xFC",
\"MAP n\xF1",
\"MAP c\xE7",
\"MAP y\xFF\xFD",
\"MAP s\xDF"
\ ]
let g:test_data_dic1 = [
\"123456",
\"test/NO",
\"# comment",
\"wrong",
\"Comment",
\"OK",
\"uk",
\"put/ISO",
\"the end",
\"deol",
\"d\xE9\xF4r",
\ ]
let g:test_data_aff2 = [
\"SET ISO8859-1",
\"",
\"FOL \xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xDF\xFF",
\"LOW \xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xDF\xFF",
\"UPP \xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xFF",
\"",
\"PFXPOSTPONE",
\"",
\"MIDWORD\t'-",
\"",
\"KEP =",
\"RAR ?",
\"BAD !",
\"",
\"PFX I N 1",
\"PFX I 0 in .",
\"",
\"PFX O Y 1",
\"PFX O 0 out [a-z]",
\"",
\"SFX S Y 2",
\"SFX S 0 s [^s]",
\"SFX S 0 es s",
\"",
\"SFX N N 3",
\"SFX N 0 en [^n]",
\"SFX N 0 nen n",
\"SFX N 0 n .",
\"",
\"REP 3",
\"REP g ch",
\"REP ch g",
\"REP svp s.v.p.",
\"",
\"MAP 9",
\"MAP a\xE0\xE1\xE2\xE3\xE4\xE5",
\"MAP e\xE8\xE9\xEA\xEB",
\"MAP i\xEC\xED\xEE\xEF",
\"MAP o\xF2\xF3\xF4\xF5\xF6",
\"MAP u\xF9\xFA\xFB\xFC",
\"MAP n\xF1",
\"MAP c\xE7",
\"MAP y\xFF\xFD",
\"MAP s\xDF",
\ ]
let g:test_data_aff3 = [
\"SET ISO8859-1",
\"",
\"COMPOUNDMIN 3",
\"COMPOUNDRULE m*",
\"NEEDCOMPOUND x",
\ ]
let g:test_data_dic3 = [
\"1234",
\"foo/m",
\"bar/mx",
\"m\xEF/m",
\"la/mx",
\ ]
let g:test_data_aff4 = [
\"SET ISO8859-1",
\"",
\"FOL \xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xDF\xFF",
\"LOW \xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xDF\xFF",
\"UPP \xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xFF",
\"",
\"COMPOUNDRULE m+",
\"COMPOUNDRULE sm*e",
\"COMPOUNDRULE sm+",
\"COMPOUNDMIN 3",
\"COMPOUNDWORDMAX 3",
\"COMPOUNDFORBIDFLAG t",
\"",
\"COMPOUNDSYLMAX 5",
\"SYLLABLE a\xE1e\xE9i\xEDo\xF3\xF6\xF5u\xFA\xFC\xFBy/aa/au/ea/ee/ei/ie/oa/oe/oo/ou/uu/ui",
\"",
\"MAP 9",
\"MAP a\xE0\xE1\xE2\xE3\xE4\xE5",
\"MAP e\xE8\xE9\xEA\xEB",
\"MAP i\xEC\xED\xEE\xEF",
\"MAP o\xF2\xF3\xF4\xF5\xF6",
\"MAP u\xF9\xFA\xFB\xFC",
\"MAP n\xF1",
\"MAP c\xE7",
\"MAP y\xFF\xFD",
\"MAP s\xDF",
\"",
\"NEEDAFFIX x",
\"",
\"PFXPOSTPONE",
\"",
\"MIDWORD '-",
\"",
\"SFX q N 1",
\"SFX q 0 -ok .",
\"",
\"SFX a Y 2",
\"SFX a 0 s .",
\"SFX a 0 ize/t .",
\"",
\"PFX p N 1",
\"PFX p 0 pre .",
\"",
\"PFX P N 1",
\"PFX P 0 nou .",
\ ]
let g:test_data_dic4 = [
\"1234",
\"word/mP",
\"util/am",
\"pro/xq",
\"tomato/m",
\"bork/mp",
\"start/s",
\"end/e",
\ ]
let g:test_data_aff5 = [
\"SET ISO8859-1",
\"",
\"FLAG long",
\"",
\"NEEDAFFIX !!",
\"",
\"COMPOUNDRULE ssmm*ee",
\"",
\"NEEDCOMPOUND xx",
\"COMPOUNDPERMITFLAG pp",
\"",
\"SFX 13 Y 1",
\"SFX 13 0 bork .",
\"",
\"SFX a1 Y 1",
\"SFX a1 0 a1 .",
\"",
\"SFX a\xE9 Y 1",
\"SFX a\xE9 0 a\xE9 .",
\"",
\"PFX zz Y 1",
\"PFX zz 0 pre/pp .",
\"",
\"PFX yy Y 1",
\"PFX yy 0 nou .",
\ ]
let g:test_data_dic5 = [
\"1234",
\"foo/a1a\xE9!!",
\"bar/zz13ee",
\"start/ss",
\"end/eeyy",
\"middle/mmxx",
\ ]
let g:test_data_aff6 = [
\"SET ISO8859-1",
\"",
\"FLAG caplong",
\"",
\"NEEDAFFIX A!",
\"",
\"COMPOUNDRULE sMm*Ee",
\"",
\"NEEDCOMPOUND Xx",
\"",
\"COMPOUNDPERMITFLAG p",
\"",
\"SFX N3 Y 1",
\"SFX N3 0 bork .",
\"",
\"SFX A1 Y 1",
\"SFX A1 0 a1 .",
\"",
\"SFX A\xE9 Y 1",
\"SFX A\xE9 0 a\xE9 .",
\"",
\"PFX Zz Y 1",
\"PFX Zz 0 pre/p .",
\ ]
let g:test_data_dic6 = [
\"1234",
\"mee/A1A\xE9A!",
\"bar/ZzN3Ee",
\"lead/s",
\"end/Ee",
\"middle/MmXx",
\ ]
let g:test_data_aff7 = [
\"SET ISO8859-1",
\"",
\"FLAG num",
\"",
\"NEEDAFFIX 9999",
\"",
\"COMPOUNDRULE 2,77*123",
\"",
\"NEEDCOMPOUND 1",
\"COMPOUNDPERMITFLAG 432",
\"",
\"SFX 61003 Y 1",
\"SFX 61003 0 meat .",
\"",
\"SFX 0 Y 1",
\"SFX 0 0 zero .",
\"",
\"SFX 391 Y 1",
\"SFX 391 0 a1 .",
\"",
\"SFX 111 Y 1",
\"SFX 111 0 a\xE9 .",
\"",
\"PFX 17 Y 1",
\"PFX 17 0 pre/432 .",
\ ]
let g:test_data_dic7 = [
\"1234",
\"mee/0,391,111,9999",
\"bar/17,61003,123",
\"lead/2",
\"tail/123",
\"middle/77,1",
\ ]
let g:test_data_aff8 = [
\"SET ISO8859-1",
\"",
\"NOSPLITSUGS",
\ ]
let g:test_data_dic8 = [
\"1234",
\"foo",
\"bar",
\"faabar",
\ ]
let g:test_data_aff9 = [
\ ]
let g:test_data_dic9 = [
\"1234",
\"foo",
\"bar",
\ ]
let g:test_data_aff10 = [
\"COMPOUNDRULE se",
\"COMPOUNDPERMITFLAG p",
\"",
\"SFX A Y 1",
\"SFX A 0 able/Mp .",
\"",
\"SFX M Y 1",
\"SFX M 0 s .",
\ ]
let g:test_data_dic10 = [
\"1234",
\"drink/As",
\"table/e",
\ ]
let g:test_data_aff_sal = [
\"SET ISO8859-1",
\"TRY esianrtolcdugmphbyfvkwjkqxz-\xEB\xE9\xE8\xEA\xEF\xEE\xE4\xE0\xE2\xF6\xFC\xFB'ESIANRTOLCDUGMPHBYFVKWJKQXZ",
\"",
\"FOL \xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xDF\xFF",
\"LOW \xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xDF\xFF",
\"UPP \xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xFF",
\"",
\"MIDWORD\t'-",
\"",
\"KEP =",
\"RAR ?",
\"BAD !",
\"",
\"PFX I N 1",
\"PFX I 0 in .",
\"",
\"PFX O Y 1",
\"PFX O 0 out .",
\"",
\"SFX S Y 2",
\"SFX S 0 s [^s]",
\"SFX S 0 es s",
\"",
\"SFX N N 3",
\"SFX N 0 en [^n]",
\"SFX N 0 nen n",
\"SFX N 0 n .",
\"",
\"REP 3",
\"REP g ch",
\"REP ch g",
\"REP svp s.v.p.",
\"",
\"MAP 9",
\"MAP a\xE0\xE1\xE2\xE3\xE4\xE5",
\"MAP e\xE8\xE9\xEA\xEB",
\"MAP i\xEC\xED\xEE\xEF",
\"MAP o\xF2\xF3\xF4\xF5\xF6",
\"MAP u\xF9\xFA\xFB\xFC",
\"MAP n\xF1",
\"MAP c\xE7",
\"MAP y\xFF\xFD",
\"MAP s\xDF",
\"",
\"SAL AH(AEIOUY)-^ *H",
\"SAL AR(AEIOUY)-^ *R",
\"SAL A(HR)^ *",
\"SAL A^ *",
\"SAL AH(AEIOUY)- H",
\"SAL AR(AEIOUY)- R",
\"SAL A(HR) _",
\"SAL \xC0^ *",
\"SAL \xC5^ *",
\"SAL BB- _",
\"SAL B B",
\"SAL CQ- _",
\"SAL CIA X",
\"SAL CH X",
\"SAL C(EIY)- S",
\"SAL CK K",
\"SAL COUGH^ KF",
\"SAL CC< C",
\"SAL C K",
\"SAL DG(EIY) K",
\"SAL DD- _",
\"SAL D T",
\"SAL \xC9< E",
\"SAL EH(AEIOUY)-^ *H",
\"SAL ER(AEIOUY)-^ *R",
\"SAL E(HR)^ *",
\"SAL ENOUGH^$ *NF",
\"SAL E^ *",
\"SAL EH(AEIOUY)- H",
\"SAL ER(AEIOUY)- R",
\"SAL E(HR) _",
\"SAL FF- _",
\"SAL F F",
\"SAL GN^ N",
\"SAL GN$ N",
\"SAL GNS$ NS",
\"SAL GNED$ N",
\"SAL GH(AEIOUY)- K",
\"SAL GH _",
\"SAL GG9 K",
\"SAL G K",
\"SAL H H",
\"SAL IH(AEIOUY)-^ *H",
\"SAL IR(AEIOUY)-^ *R",
\"SAL I(HR)^ *",
\"SAL I^ *",
\"SAL ING6 N",
\"SAL IH(AEIOUY)- H",
\"SAL IR(AEIOUY)- R",
\"SAL I(HR) _",
\"SAL J K",
\"SAL KN^ N",
\"SAL KK- _",
\"SAL K K",
\"SAL LAUGH^ LF",
\"SAL LL- _",
\"SAL L L",
\"SAL MB$ M",
\"SAL MM M",
\"SAL M M",
\"SAL NN- _",
\"SAL N N",
\"SAL OH(AEIOUY)-^ *H",
\"SAL OR(AEIOUY)-^ *R",
\"SAL O(HR)^ *",
\"SAL O^ *",
\"SAL OH(AEIOUY)- H",
\"SAL OR(AEIOUY)- R",
\"SAL O(HR) _",
\"SAL PH F",
\"SAL PN^ N",
\"SAL PP- _",
\"SAL P P",
\"SAL Q K",
\"SAL RH^ R",
\"SAL ROUGH^ RF",
\"SAL RR- _",
\"SAL R R",
\"SAL SCH(EOU)- SK",
\"SAL SC(IEY)- S",
\"SAL SH X",
\"SAL SI(AO)- X",
\"SAL SS- _",
\"SAL S S",
\"SAL TI(AO)- X",
\"SAL TH @",
\"SAL TCH-- _",
\"SAL TOUGH^ TF",
\"SAL TT- _",
\"SAL T T",
\"SAL UH(AEIOUY)-^ *H",
\"SAL UR(AEIOUY)-^ *R",
\"SAL U(HR)^ *",
\"SAL U^ *",
\"SAL UH(AEIOUY)- H",
\"SAL UR(AEIOUY)- R",
\"SAL U(HR) _",
\"SAL V^ W",
\"SAL V F",
\"SAL WR^ R",
\"SAL WH^ W",
\"SAL W(AEIOU)- W",
\"SAL X^ S",
\"SAL X KS",
\"SAL Y(AEIOU)- Y",
\"SAL ZZ- _",
\"SAL Z S",
\ ]
func LoadAffAndDic(aff_contents, dic_contents)
set enc=utf-8
set spellfile=
call writefile(a:aff_contents, "Xtest.aff")
call writefile(a:dic_contents, "Xtest.dic")
" Generate a .spl file from a .dic and .aff file.
mkspell! Xtest Xtest
" use that spell file
set spl=Xtest.utf-8.spl spell
endfunc
func ListWords()
spelldump
%yank
quit
return split(@", "\n")
endfunc
func TestGoodBadBase()
exe '1;/^good:'
normal 0f:]s
let prevbad = ''
let result = []
while 1
let [bad, a] = spellbadword()
if bad == '' || bad == prevbad || bad == 'badend'
break
endif
let prevbad = bad
let lst = bad->spellsuggest(3)
normal mm
call add(result, [bad, lst])
normal `m]s
endwhile
return result
endfunc
func RunGoodBad(good, bad, expected_words, expected_bad_words)
%bwipe!
call setline(1, ['', "good: ", a:good, a:bad, " badend "])
let words = ListWords()
call assert_equal(a:expected_words, words[1:-1])
let bad_words = TestGoodBadBase()
call assert_equal(a:expected_bad_words, bad_words)
%bwipe!
endfunc
func Test_spell_basic()
call LoadAffAndDic(g:test_data_aff1, g:test_data_dic1)
call RunGoodBad("wrong OK puts. Test the end",
\ "bad: inputs comment ok Ok. test d\u00E9\u00F4l end the",
\["Comment", "deol", "d\u00E9\u00F4r", "input", "OK", "output", "outputs", "outtest", "put", "puts",
\ "test", "testen", "testn", "the end", "uk", "wrong"],
\[
\ ["bad", ["put", "uk", "OK"]],
\ ["inputs", ["input", "puts", "outputs"]],
\ ["comment", ["Comment", "outtest", "the end"]],
\ ["ok", ["OK", "uk", "put"]],
\ ["Ok", ["OK", "Uk", "Put"]],
\ ["test", ["Test", "testn", "testen"]],
\ ["d\u00E9\u00F4l", ["deol", "d\u00E9\u00F4r", "test"]],
\ ["end", ["put", "uk", "test"]],
\ ["the", ["put", "uk", "test"]],
\ ]
\ )
call assert_equal("gebletegek", soundfold('goobledygoook'))
call assert_equal("kepereneven", 'kóopërÿnôven'->soundfold())
call assert_equal("everles gesvets etele", soundfold('oeverloos gezwets edale'))
endfunc
" Postponed prefixes
func Test_spell_prefixes()
call LoadAffAndDic(g:test_data_aff2, g:test_data_dic1)
call RunGoodBad("puts",
\ "bad: inputs comment ok Ok end the. test d\u00E9\u00F4l",
\ ["Comment", "deol", "d\u00E9\u00F4r", "OK", "put", "input", "output", "puts", "outputs", "test", "outtest", "testen", "testn", "the end", "uk", "wrong"],
\ [
\ ["bad", ["put", "uk", "OK"]],
\ ["inputs", ["input", "puts", "outputs"]],
\ ["comment", ["Comment"]],
\ ["ok", ["OK", "uk", "put"]],
\ ["Ok", ["OK", "Uk", "Put"]],
\ ["end", ["put", "uk", "deol"]],
\ ["the", ["put", "uk", "test"]],
\ ["test", ["Test", "testn", "testen"]],
\ ["d\u00E9\u00F4l", ["deol", "d\u00E9\u00F4r", "test"]],
\ ])
endfunc
"Compound words
func Test_spell_compound()
call LoadAffAndDic(g:test_data_aff3, g:test_data_dic3)
call RunGoodBad("foo m\u00EF foobar foofoobar barfoo barbarfoo",
\ "bad: bar la foom\u00EF barm\u00EF m\u00EFfoo m\u00EFbar m\u00EFm\u00EF lala m\u00EFla lam\u00EF foola labar",
\ ["foo", "m\u00EF"],
\ [
\ ["bad", ["foo", "m\u00EF"]],
\ ["bar", ["barfoo", "foobar", "foo"]],
\ ["la", ["m\u00EF", "foo"]],
\ ["foom\u00EF", ["foo m\u00EF", "foo", "foofoo"]],
\ ["barm\u00EF", ["barfoo", "m\u00EF", "barbar"]],
\ ["m\u00EFfoo", ["m\u00EF foo", "foo", "foofoo"]],
\ ["m\u00EFbar", ["foobar", "barbar", "m\u00EF"]],
\ ["m\u00EFm\u00EF", ["m\u00EF m\u00EF", "m\u00EF"]],
\ ["lala", []],
\ ["m\u00EFla", ["m\u00EF", "m\u00EF m\u00EF"]],
\ ["lam\u00EF", ["m\u00EF", "m\u00EF m\u00EF"]],
\ ["foola", ["foo", "foobar", "foofoo"]],
\ ["labar", ["barbar", "foobar"]],
\ ])
call LoadAffAndDic(g:test_data_aff4, g:test_data_dic4)
call RunGoodBad("word util bork prebork start end wordutil wordutils pro-ok bork borkbork borkborkbork borkborkborkbork borkborkborkborkbork tomato tomatotomato startend startword startwordword startwordend startwordwordend startwordwordwordend prebork preborkbork preborkborkbork nouword",
\ "bad: wordutilize pro borkborkborkborkborkbork tomatotomatotomato endstart endend startstart wordend wordstart preborkprebork preborkpreborkbork startwordwordwordwordend borkpreborkpreborkbork utilsbork startnouword",
\ ["bork", "prebork", "end", "pro-ok", "start", "tomato", "util", "utilize", "utils", "word", "nouword"],
\ [
\ ["bad", ["end", "bork", "word"]],
\ ["wordutilize", ["word utilize", "wordutils", "wordutil"]],
\ ["pro", ["bork", "word", "end"]],
\ ["borkborkborkborkborkbork", ["bork borkborkborkborkbork", "borkbork borkborkborkbork", "borkborkbork borkborkbork"]],
\ ["tomatotomatotomato", ["tomato tomatotomato", "tomatotomato tomato", "tomato tomato tomato"]],
\ ["endstart", ["end start", "start"]],
\ ["endend", ["end end", "end"]],
\ ["startstart", ["start start"]],
\ ["wordend", ["word end", "word", "wordword"]],
\ ["wordstart", ["word start", "bork start"]],
\ ["preborkprebork", ["prebork prebork", "preborkbork", "preborkborkbork"]],
\ ["preborkpreborkbork", ["prebork preborkbork", "preborkborkbork", "preborkborkborkbork"]],
\ ["startwordwordwordwordend", ["startwordwordwordword end", "startwordwordwordword", "start wordwordwordword end"]],
\ ["borkpreborkpreborkbork", ["bork preborkpreborkbork", "bork prebork preborkbork", "bork preborkprebork bork"]],
\ ["utilsbork", ["utilbork", "utils bork", "util bork"]],
\ ["startnouword", ["start nouword", "startword", "startborkword"]],
\ ])
endfunc
" Test affix flags with two characters
func Test_spell_affix()
call LoadAffAndDic(g:test_data_aff5, g:test_data_dic5)
call RunGoodBad("fooa1 fooa\u00E9 bar prebar barbork prebarbork startprebar start end startend startmiddleend nouend",
\ "bad: foo fooa2 prabar probarbirk middle startmiddle middleend endstart startprobar startnouend",
\ ["bar", "barbork", "end", "fooa1", "fooa\u00E9", "nouend", "prebar", "prebarbork", "start"],
\ [
\ ["bad", ["bar", "end", "fooa1"]],
\ ["foo", ["fooa1", "fooa\u00E9", "bar"]],
\ ["fooa2", ["fooa1", "fooa\u00E9", "bar"]],
\ ["prabar", ["prebar", "bar", "bar bar"]],
\ ["probarbirk", ["prebarbork"]],
\ ["middle", []],
\ ["startmiddle", ["startmiddleend", "startmiddlebar"]],
\ ["middleend", []],
\ ["endstart", ["end start", "start"]],
\ ["startprobar", ["startprebar", "start prebar", "startbar"]],
\ ["startnouend", ["start nouend", "startend"]],
\ ])
call LoadAffAndDic(g:test_data_aff6, g:test_data_dic6)
call RunGoodBad("meea1 meea\u00E9 bar prebar barbork prebarbork leadprebar lead end leadend leadmiddleend",
\ "bad: mee meea2 prabar probarbirk middle leadmiddle middleend endlead leadprobar",
\ ["bar", "barbork", "end", "lead", "meea1", "meea\u00E9", "prebar", "prebarbork"],
\ [
\ ["bad", ["bar", "end", "lead"]],
\ ["mee", ["meea1", "meea\u00E9", "bar"]],
\ ["meea2", ["meea1", "meea\u00E9", "lead"]],
\ ["prabar", ["prebar", "bar", "leadbar"]],
\ ["probarbirk", ["prebarbork"]],
\ ["middle", []],
\ ["leadmiddle", ["leadmiddleend", "leadmiddlebar"]],
\ ["middleend", []],
\ ["endlead", ["end lead", "lead", "end end"]],
\ ["leadprobar", ["leadprebar", "lead prebar", "leadbar"]],
\ ])
call LoadAffAndDic(g:test_data_aff7, g:test_data_dic7)
call RunGoodBad("meea1 meezero meea\u00E9 bar prebar barmeat prebarmeat leadprebar lead tail leadtail leadmiddletail",
\ "bad: mee meea2 prabar probarmaat middle leadmiddle middletail taillead leadprobar",
\ ["bar", "barmeat", "lead", "meea1", "meea\u00E9", "meezero", "prebar", "prebarmeat", "tail"],
\ [
\ ["bad", ["bar", "lead", "tail"]],
\ ["mee", ["meea1", "meea\u00E9", "bar"]],
\ ["meea2", ["meea1", "meea\u00E9", "lead"]],
\ ["prabar", ["prebar", "bar", "leadbar"]],
\ ["probarmaat", ["prebarmeat"]],
\ ["middle", []],
\ ["leadmiddle", ["leadmiddlebar"]],
\ ["middletail", []],
\ ["taillead", ["tail lead", "tail"]],
\ ["leadprobar", ["leadprebar", "lead prebar", "leadbar"]],
\ ])
endfunc
func Test_spell_NOSLITSUGS()
call LoadAffAndDic(g:test_data_aff8, g:test_data_dic8)
call RunGoodBad("foo bar faabar", "bad: foobar barfoo",
\ ["bar", "faabar", "foo"],
\ [
\ ["bad", ["bar", "foo"]],
\ ["foobar", ["faabar", "foo bar", "bar"]],
\ ["barfoo", ["bar foo", "bar", "foo"]],
\ ])
endfunc
" Numbers
func Test_spell_Numbers()
call LoadAffAndDic(g:test_data_aff9, g:test_data_dic9)
call RunGoodBad("0b1011 0777 1234 0x01ff", "",
\ ["bar", "foo"],
\ [
\ ])
endfunc
" Affix flags
func Test_spell_affix_flags()
call LoadAffAndDic(g:test_data_aff10, g:test_data_dic10)
call RunGoodBad("drink drinkable drinkables drinktable drinkabletable",
\ "bad: drinks drinkstable drinkablestable",
\ ["drink", "drinkable", "drinkables", "table"],
\ [['bad', []],
\ ['drinks', ['drink']],
\ ['drinkstable', ['drinktable', 'drinkable', 'drink table']],
\ ['drinkablestable', ['drinkabletable', 'drinkables table', 'drinkable table']],
\ ])
endfunc
function FirstSpellWord()
call feedkeys("/^start:\n", 'tx')
normal ]smm
let [str, a] = spellbadword()
return str
endfunc
function SecondSpellWord()
normal `m]s
let [str, a] = spellbadword()
return str
endfunc
" Test with SAL instead of SOFO items; test automatic reloading
func Test_spell_sal_and_addition()
set spellfile=
call writefile(g:test_data_dic1, "Xtest.dic")
call writefile(g:test_data_aff_sal, "Xtest.aff")
mkspell! Xtest Xtest
set spl=Xtest.utf-8.spl spell
call assert_equal('kbltykk', soundfold('goobledygoook'))
call assert_equal('kprnfn', soundfold('kóopërÿnôven'))
call assert_equal('*fls kswts tl', soundfold('oeverloos gezwets edale'))
"also use an addition file
call writefile(["/regions=usgbnz", "elequint/2", "elekwint/3"], "Xtest.utf-8.add")
mkspell! Xtest.utf-8.add.spl Xtest.utf-8.add
bwipe!
call setline(1, ["start: elequint test elekwint test elekwent asdf"])
set spellfile=Xtest.utf-8.add
call assert_equal("elekwent", FirstSpellWord())
set spl=Xtest_us.utf-8.spl
call assert_equal("elequint", FirstSpellWord())
call assert_equal("elekwint", SecondSpellWord())
set spl=Xtest_gb.utf-8.spl
call assert_equal("elekwint", FirstSpellWord())
call assert_equal("elekwent", SecondSpellWord())
set spl=Xtest_nz.utf-8.spl
call assert_equal("elequint", FirstSpellWord())
call assert_equal("elekwent", SecondSpellWord())
set spl=Xtest_ca.utf-8.spl
call assert_equal("elequint", FirstSpellWord())
call assert_equal("elekwint", SecondSpellWord())
endfunc
func Test_spellfile_value()
set spellfile=Xdir/Xtest.utf-8.add
set spellfile=Xdir/Xtest.utf-8.add,Xtest_other.add
endfunc
" vim: shiftwidth=2 sts=2 expandtab

View File

@ -258,6 +258,21 @@ func Test_terminal_scrape_multibyte()
call delete('Xtext')
endfunc
func Test_terminal_one_column()
" This creates a terminal, displays a double-wide character and makes the
" window one column wide. This used to cause a crash.
let width = &columns
botright vert term
let buf = bufnr('$')
call term_wait(buf, 100)
exe "set columns=" .. (width / 2)
redraw
call term_sendkeys(buf, "キ")
call term_wait(buf, 10)
exe "set columns=" .. width
exe buf . 'bwipe!'
endfunc
func Test_terminal_scroll()
call writefile(range(1, 200), 'Xtext')
if has('win32')

View File

@ -1176,6 +1176,10 @@ def Test_expr7_list()
assert_equal(g:list_mixed, [1, 'b', false,])
assert_equal('b', g:list_mixed[1])
echo [1,
2] [3,
4]
call CheckDefExecFailure(["let x = g:anint[3]"], 'E714:')
call CheckDefFailure(["let x = g:list_mixed[xxx]"], 'E1001:')
call CheckDefFailure(["let x = [1,2,3]"], 'E1069:')
@ -1193,6 +1197,10 @@ def Test_expr7_list_vim9script()
22,
]
assert_equal([11, 22], l)
echo [1,
2] [3,
4]
END
CheckScriptSuccess(lines)
@ -1422,6 +1430,22 @@ enddef
def Test_expr7_register()
@a = 'register a'
assert_equal('register a', @a)
let fname = expand('%')
assert_equal(fname, @%)
feedkeys(":echo 'some'\<CR>", "xt")
assert_equal("echo 'some'", @:)
normal axyz
assert_equal("xyz", @.)
call CheckDefFailure(["@. = 'yes'"], 'E354:')
@/ = 'slash'
assert_equal('slash', @/)
@= = 'equal'
assert_equal('equal', @=)
enddef
def Test_expr7_namespace()

View File

@ -131,8 +131,16 @@ def Test_nested_function()
CheckDefFailure(['def Nested(arg: string)', 'enddef', 'Nested()'], 'E119:')
CheckDefFailure(['func Nested()', 'endfunc'], 'E1086:')
CheckDefFailure(['def s:Nested()', 'enddef'], 'E1075:')
CheckDefFailure(['def b:Nested()', 'enddef'], 'E1075:')
enddef
func Test_call_default_args_from_func()
call assert_equal('string', MyDefaultArgs())
call assert_equal('one', MyDefaultArgs('one'))
call assert_fails('call MyDefaultArgs("one", "two")', 'E118:')
endfunc
def Test_nested_global_function()
let lines =<< trim END
vim9script
@ -141,7 +149,7 @@ def Test_nested_global_function()
return 'inner'
enddef
enddef
disass Outer
defcompile
Outer()
assert_equal('inner', g:Inner())
delfunc g:Inner
@ -153,13 +161,49 @@ def Test_nested_global_function()
delfunc g:Inner
END
CheckScriptSuccess(lines)
lines =<< trim END
vim9script
def Outer()
def g:Inner(): string
return 'inner'
enddef
enddef
defcompile
Outer()
Outer()
END
CheckScriptFailure(lines, "E122:")
lines =<< trim END
vim9script
def Func()
echo 'script'
enddef
def Outer()
def Func()
echo 'inner'
enddef
enddef
defcompile
END
CheckScriptFailure(lines, "E1073:")
enddef
func Test_call_default_args_from_func()
call assert_equal('string', MyDefaultArgs())
call assert_equal('one', MyDefaultArgs('one'))
call assert_fails('call MyDefaultArgs("one", "two")', 'E118:')
endfunc
def Test_global_local_function()
let lines =<< trim END
vim9script
def g:Func(): string
return 'global'
enddef
def Func(): string
return 'local'
enddef
assert_equal('global', g:Func())
assert_equal('local', Func())
END
CheckScriptSuccess(lines)
enddef
func TakesOneArg(arg)
echo a:arg

View File

@ -244,10 +244,60 @@ def Test_assignment_dict()
# overwrite
dict3['key'] = 'another'
call CheckDefExecFailure(['let dd = {}', 'dd[""] = 6'], 'E713:')
# empty key can be used
let dd = {}
dd[""] = 6
assert_equal({'': 6}, dd)
# type becomes dict<any>
let somedict = rand() > 0 ? #{a: 1, b: 2} : #{a: 'a', b: 'b'}
# assignment to script-local dict
let lines =<< trim END
vim9script
let test: dict<any> = {}
def FillDict(): dict<any>
test['a'] = 43
return test
enddef
assert_equal(#{a: 43}, FillDict())
END
call CheckScriptSuccess(lines)
lines =<< trim END
vim9script
let test: dict<any>
def FillDict(): dict<any>
test['a'] = 43
return test
enddef
FillDict()
END
call CheckScriptFailure(lines, 'E1103:')
# assignment to global dict
lines =<< trim END
vim9script
g:test = {}
def FillDict(): dict<any>
g:test['a'] = 43
return g:test
enddef
assert_equal(#{a: 43}, FillDict())
END
call CheckScriptSuccess(lines)
# assignment to buffer dict
lines =<< trim END
vim9script
b:test = {}
def FillDict(): dict<any>
b:test['a'] = 43
return b:test
enddef
assert_equal(#{a: 43}, FillDict())
END
call CheckScriptSuccess(lines)
enddef
def Test_assignment_local()
@ -373,6 +423,23 @@ def Test_assignment_vim9script()
let ll =
Func()
assert_equal([1, 2], ll)
@/ = 'text'
assert_equal('text', @/)
@0 = 'zero'
assert_equal('zero', @0)
@1 = 'one'
assert_equal('one', @1)
@9 = 'nine'
assert_equal('nine', @9)
@- = 'minus'
assert_equal('minus', @-)
if has('clipboard_working')
@* = 'star'
assert_equal('star', @*)
@+ = 'plus'
assert_equal('plus', @+)
endif
END
CheckScriptSuccess(lines)
enddef
@ -413,13 +480,22 @@ def Test_assignment_failure()
'[x, y; z] = [1]'], 'E1093:')
call CheckDefFailure(['let somevar'], "E1022:")
call CheckDefFailure(['let &option'], 'E1052:')
call CheckDefFailure(['let &tabstop = 4'], 'E1052:')
call CheckDefFailure(['&g:option = 5'], 'E113:')
call CheckScriptFailure(['vim9script', 'let &tabstop = 4'], 'E1052:')
call CheckDefFailure(['let $VAR = 5'], 'E1016: Cannot declare an environment variable:')
call CheckScriptFailure(['vim9script', 'let $ENV = "xxx"'], 'E1016:')
call CheckDefFailure(['let @~ = 5'], 'E354:')
if has('dnd')
call CheckDefFailure(['let @~ = 5'], 'E1066:')
else
call CheckDefFailure(['let @~ = 5'], 'E354:')
call CheckDefFailure(['@~ = 5'], 'E354:')
endif
call CheckDefFailure(['let @a = 5'], 'E1066:')
call CheckDefFailure(['let @/ = "x"'], 'E1066:')
call CheckScriptFailure(['vim9script', 'let @a = "abc"'], 'E1066:')
call CheckDefFailure(['let g:var = 5'], 'E1016: Cannot declare a global variable:')
call CheckDefFailure(['let w:var = 5'], 'E1016: Cannot declare a window variable:')
@ -783,13 +859,6 @@ def Test_try_catch()
endtry
assert_equal(300, n)
try
d[''] = 3
catch /E713:/
n = 311
endtry
assert_equal(311, n)
try
unlet g:does_not_exist
catch /E108:/
@ -1575,6 +1644,52 @@ def Test_import_compile_error()
delete('Ximport.vim')
enddef
def Test_func_overrules_import_fails()
let export_lines =<< trim END
vim9script
export def Func()
echo 'imported'
enddef
END
writefile(export_lines, 'XexportedFunc.vim')
let lines =<< trim END
vim9script
import Func from './XexportedFunc.vim'
def Func()
echo 'local to function'
enddef
END
CheckScriptFailure(lines, 'E1073:')
lines =<< trim END
vim9script
import Func from './XexportedFunc.vim'
def Outer()
def Func()
echo 'local to function'
enddef
enddef
defcompile
END
CheckScriptFailure(lines, 'E1073:')
delete('XexportedFunc.vim')
enddef
def Test_func_redefine_fails()
let lines =<< trim END
vim9script
def Func()
echo 'one'
enddef
def Func()
echo 'two'
enddef
END
CheckScriptFailure(lines, 'E1073:')
enddef
def Test_fixed_size_list()
# will be allocated as one piece of memory, check that changes work
let l = [1, 2, 3, 4]
@ -1585,18 +1700,21 @@ def Test_fixed_size_list()
enddef
def Test_no_insert_xit()
call CheckDefExecFailure(['x = 1'], 'E1100:')
call CheckDefExecFailure(['a = 1'], 'E1100:')
call CheckDefExecFailure(['i = 1'], 'E1100:')
call CheckDefExecFailure(['c = 1'], 'E1100:')
call CheckDefExecFailure(['i = 1'], 'E1100:')
call CheckDefExecFailure(['t = 1'], 'E1100:')
call CheckDefExecFailure(['x = 1'], 'E1100:')
CheckScriptFailure(['vim9script', 'x = 1'], 'E1100:')
CheckScriptFailure(['vim9script', 'a = 1'], 'E488:')
CheckScriptFailure(['vim9script', 'a'], 'E1100:')
CheckScriptFailure(['vim9script', 'i = 1'], 'E488:')
CheckScriptFailure(['vim9script', 'i'], 'E1100:')
CheckScriptFailure(['vim9script', 'c = 1'], 'E488:')
CheckScriptFailure(['vim9script', 'c'], 'E1100:')
CheckScriptFailure(['vim9script', 'i = 1'], 'E488:')
CheckScriptFailure(['vim9script', 'i'], 'E1100:')
CheckScriptFailure(['vim9script', 't'], 'E1100:')
CheckScriptFailure(['vim9script', 't = 1'], 'E1100:')
CheckScriptFailure(['vim9script', 'x = 1'], 'E1100:')
enddef
def IfElse(what: number): string

View File

@ -807,7 +807,7 @@ func Test_viminfo_perm()
" Try to write the viminfo to a directory
call mkdir('Xdir')
call assert_fails('wviminfo Xdir', 'E886:')
call assert_fails('wviminfo Xdir', 'E137:')
call delete('Xdir', 'rf')
endfunc

View File

@ -136,9 +136,7 @@ func Test_writefile_sync_arg()
endfunc
func Test_writefile_sync_dev_stdout()
if !has('unix')
return
endif
CheckUnix
if filewritable('/dev/stdout')
" Just check that this doesn't cause an error.
call writefile(['one'], '/dev/stdout')
@ -371,13 +369,10 @@ endfunc
" Test for writing to a readonly file
func Test_write_readonly()
" In Cirrus-CI, the freebsd tests are run under a root account. So this test
" doesn't fail.
CheckNotBSD
call writefile([], 'Xfile')
call setfperm('Xfile', "r--------")
edit Xfile
set noreadonly
set noreadonly backupskip=
call assert_fails('write', 'E505:')
let save_cpo = &cpo
set cpo+=W
@ -386,37 +381,32 @@ func Test_write_readonly()
call setline(1, ['line1'])
write!
call assert_equal(['line1'], readfile('Xfile'))
set backupskip&
call delete('Xfile')
endfunc
" Test for 'patchmode'
func Test_patchmode()
CheckNotBSD
call writefile(['one'], 'Xfile')
set patchmode=.orig nobackup writebackup
set patchmode=.orig nobackup backupskip= writebackup
new Xfile
call setline(1, 'two')
" first write should create the .orig file
write
" TODO: Xfile.orig is not created in Cirrus FreeBSD CI test
call assert_equal(['one'], readfile('Xfile.orig'))
call setline(1, 'three')
" subsequent writes should not create/modify the .orig file
write
call assert_equal(['one'], readfile('Xfile.orig'))
set patchmode& backup& writebackup&
set patchmode& backup& backupskip& writebackup&
call delete('Xfile')
call delete('Xfile.orig')
endfunc
" Test for writing to a file in a readonly directory
func Test_write_readonly_dir()
if !has('unix') || has('bsd')
" On MS-Windows, modifying files in a read-only directory is allowed.
" In Cirrus-CI for Freebsd, tests are run under a root account where
" modifying files in a read-only directory are allowed.
return
endif
" On MS-Windows, modifying files in a read-only directory is allowed.
CheckUnix
call mkdir('Xdir')
call writefile(['one'], 'Xdir/Xfile1')
call setfperm('Xdir', 'r-xr--r--')
@ -426,12 +416,12 @@ func Test_write_readonly_dir()
call assert_fails('write', 'E212:')
" try to create a backup file in the directory
edit! Xdir/Xfile1
set backupdir=./Xdir
set backupdir=./Xdir backupskip=
set patchmode=.orig
call assert_fails('write', 'E509:')
call setfperm('Xdir', 'rwxr--r--')
call delete('Xdir', 'rf')
set backupdir& patchmode&
set backupdir& backupskip& patchmode&
endfunc
" Test for writing a file using invalid file encoding

View File

@ -780,7 +780,7 @@ find_func_with_sid(char_u *name, int sid)
* When "is_global" is true don't find script-local or imported functions.
* Return NULL for unknown function.
*/
static ufunc_T *
ufunc_T *
find_func_even_dead(char_u *name, int is_global, cctx_T *cctx)
{
hashitem_T *hi;
@ -789,9 +789,10 @@ find_func_even_dead(char_u *name, int is_global, cctx_T *cctx)
if (!is_global)
{
char_u *after_script = NULL;
int vim9script = in_vim9script();
char_u *after_script = NULL;
if (in_vim9script())
if (vim9script)
{
// Find script-local function before global one.
func = find_func_with_sid(name, current_sctx.sc_sid);
@ -799,7 +800,7 @@ find_func_even_dead(char_u *name, int is_global, cctx_T *cctx)
return func;
}
if (!in_vim9script()
if (!vim9script
&& name[0] == K_SPECIAL
&& name[1] == KS_EXTRA
&& name[2] == KE_SNR)
@ -815,7 +816,7 @@ find_func_even_dead(char_u *name, int is_global, cctx_T *cctx)
else
after_script = NULL;
}
if (in_vim9script() || after_script != NULL)
if (vim9script || after_script != NULL)
{
// Find imported function before global one.
imported = find_imported(
@ -1188,10 +1189,10 @@ copy_func(char_u *lambda, char_u *global)
fp->uf_flags = (ufunc->uf_flags & ~FC_VIM9) | FC_COPY;
fp->uf_def_status = ufunc->uf_def_status;
fp->uf_dfunc_idx = ufunc->uf_dfunc_idx;
if (ga_copy_strings(&fp->uf_args, &ufunc->uf_args) == FAIL
|| ga_copy_strings(&fp->uf_def_args, &ufunc->uf_def_args)
if (ga_copy_strings(&ufunc->uf_args, &fp->uf_args) == FAIL
|| ga_copy_strings(&ufunc->uf_def_args, &fp->uf_def_args)
== FAIL
|| ga_copy_strings(&fp->uf_lines, &ufunc->uf_lines) == FAIL)
|| ga_copy_strings(&ufunc->uf_lines, &fp->uf_lines) == FAIL)
goto failed;
fp->uf_name_exp = ufunc->uf_name_exp == NULL ? NULL
@ -1759,7 +1760,7 @@ delete_script_functions(int sid)
{
hashitem_T *hi;
ufunc_T *fp;
long_u todo;
long_u todo = 1;
char_u buf[30];
size_t len;
@ -1769,18 +1770,27 @@ delete_script_functions(int sid)
sprintf((char *)buf + 3, "%d_", sid);
len = STRLEN(buf);
todo = func_hashtab.ht_used;
for (hi = func_hashtab.ht_array; todo > 0; ++hi)
if (!HASHITEM_EMPTY(hi))
{
fp = HI2UF(hi);
if (STRNCMP(fp->uf_name, buf, len) == 0)
while (todo > 0)
{
todo = func_hashtab.ht_used;
for (hi = func_hashtab.ht_array; todo > 0; ++hi)
if (!HASHITEM_EMPTY(hi))
{
fp->uf_flags |= FC_DEAD;
func_clear(fp, TRUE);
fp = HI2UF(hi);
if (STRNCMP(fp->uf_name, buf, len) == 0)
{
int changed = func_hashtab.ht_changed;
fp->uf_flags |= FC_DEAD;
func_clear(fp, TRUE);
// When clearing a function another function can be cleared
// as a side effect. When that happens start over.
if (changed != func_hashtab.ht_changed)
break;
}
--todo;
}
--todo;
}
}
}
#if defined(EXITFREE) || defined(PROTO)
@ -2077,10 +2087,14 @@ call_func(
if (error == FCERR_NONE && funcexe->evaluate)
{
char_u *rfname = fname;
int is_global = FALSE;
// Ignore "g:" before a function name.
// Skip "g:" before a function name.
if (fp == NULL && fname[0] == 'g' && fname[1] == ':')
{
is_global = TRUE;
rfname = fname + 2;
}
rettv->v_type = VAR_NUMBER; // default rettv is number zero
rettv->vval.v_number = 0;
@ -2092,7 +2106,7 @@ call_func(
* User defined function.
*/
if (fp == NULL)
fp = find_func(rfname, FALSE, NULL);
fp = find_func(rfname, is_global, NULL);
// Trigger FuncUndefined event, may load the function.
if (fp == NULL
@ -2101,13 +2115,13 @@ call_func(
&& !aborting())
{
// executed an autocommand, search for the function again
fp = find_func(rfname, FALSE, NULL);
fp = find_func(rfname, is_global, NULL);
}
// Try loading a package.
if (fp == NULL && script_autoload(rfname, TRUE) && !aborting())
{
// loaded a package, search for the function again
fp = find_func(rfname, FALSE, NULL);
fp = find_func(rfname, is_global, NULL);
}
if (fp == NULL)
{
@ -2116,7 +2130,7 @@ call_func(
// If using Vim9 script try not local to the script.
// TODO: should not do this if the name started with "s:".
if (p != NULL)
fp = find_func(p, FALSE, NULL);
fp = find_func(p, is_global, NULL);
}
if (fp != NULL && (fp->uf_flags & FC_DELETED))
@ -2166,6 +2180,7 @@ call_func(
*/
error = call_internal_func(fname, argcount, argvars, rettv);
}
/*
* The function call (or "FuncUndefined" autocommand sequence) might
* have been aborted by an error, an interrupt, or an explicitly thrown
@ -2637,6 +2652,7 @@ def_function(exarg_T *eap, char_u *name_arg)
char_u *skip_until = NULL;
char_u *heredoc_trimmed = NULL;
int vim9script = in_vim9script();
imported_T *import = NULL;
/*
* ":function" without argument: list functions.
@ -3220,17 +3236,29 @@ def_function(exarg_T *eap, char_u *name_arg)
}
fp = find_func_even_dead(name, is_global, NULL);
if (fp != NULL)
if (vim9script)
{
int dead = fp->uf_flags & FC_DEAD;
char_u *uname = untrans_function_name(name);
import = find_imported(uname == NULL ? name : uname, 0, NULL);
}
if (fp != NULL || import != NULL)
{
int dead = fp != NULL && (fp->uf_flags & FC_DEAD);
// Function can be replaced with "function!" and when sourcing the
// same script again, but only once.
if (!dead && !eap->forceit
// A name that is used by an import can not be overruled.
if (import != NULL
|| (!dead && !eap->forceit
&& (fp->uf_script_ctx.sc_sid != current_sctx.sc_sid
|| fp->uf_script_ctx.sc_seq == current_sctx.sc_seq))
|| fp->uf_script_ctx.sc_seq == current_sctx.sc_seq)))
{
emsg_funcname(e_funcexts, name);
if (vim9script)
emsg_funcname(e_already_defined, name);
else
emsg_funcname(e_funcexts, name);
goto erret;
}
if (fp->uf_calls > 0)

View File

@ -754,6 +754,64 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1359,
/**/
1358,
/**/
1357,
/**/
1356,
/**/
1355,
/**/
1354,
/**/
1353,
/**/
1352,
/**/
1351,
/**/
1350,
/**/
1349,
/**/
1348,
/**/
1347,
/**/
1346,
/**/
1345,
/**/
1344,
/**/
1343,
/**/
1342,
/**/
1341,
/**/
1340,
/**/
1339,
/**/
1338,
/**/
1337,
/**/
1336,
/**/
1335,
/**/
1334,
/**/
1333,
/**/
1332,
/**/
1331,
/**/
1330,
/**/

View File

@ -291,14 +291,21 @@ lookup_script(char_u *name, size_t len)
int
check_defined(char_u *p, size_t len, cctx_T *cctx)
{
int c = p[len];
p[len] = NUL;
if (lookup_script(p, len) == OK
|| (cctx != NULL
&& (lookup_local(p, len, cctx) != NULL
|| find_imported(p, len, cctx) != NULL)))
|| lookup_arg(p, len, NULL, NULL, NULL, cctx) == OK))
|| find_imported(p, len, cctx) != NULL
|| find_func_even_dead(p, FALSE, cctx) != NULL)
{
semsg("E1073: imported name already defined: %s", p);
p[len] = c;
semsg(_(e_already_defined), p);
return FAIL;
}
p[len] = c;
return OK;
}
@ -3558,7 +3565,7 @@ compile_get_register(char_u **arg, cctx_T *cctx)
semsg(_(e_syntax_at), *arg - 1);
return FAIL;
}
if (!valid_yank_reg(**arg, TRUE))
if (!valid_yank_reg(**arg, FALSE))
{
emsg_invreg(**arg);
return FAIL;
@ -3855,7 +3862,7 @@ compile_subscript(
return FAIL;
}
}
else if (*p == '[')
else if (**arg == '[')
{
garray_T *stack = &cctx->ctx_type_stack;
type_T **typep;
@ -4898,18 +4905,28 @@ compile_nested_function(exarg_T *eap, cctx_T *cctx)
{
int is_global = *eap->arg == 'g' && eap->arg[1] == ':';
char_u *name_start = eap->arg;
char_u *name_end = to_name_end(eap->arg, is_global);
char_u *name = get_lambda_name();
char_u *name_end = to_name_end(eap->arg, TRUE);
char_u *lambda_name;
lvar_T *lvar;
ufunc_T *ufunc;
int r;
// Only g:Func() can use a namespace.
if (name_start[1] == ':' && !is_global)
{
semsg(_(e_namespace), name_start);
return NULL;
}
if (check_defined(name_start, name_end - name_start, cctx) == FAIL)
return NULL;
eap->arg = name_end;
eap->getline = exarg_getline;
eap->cookie = cctx;
eap->skip = cctx->ctx_skip == SKIP_YES;
eap->forceit = FALSE;
ufunc = def_function(eap, name);
lambda_name = get_lambda_name();
ufunc = def_function(eap, lambda_name);
if (ufunc == NULL)
return NULL;
@ -4925,13 +4942,15 @@ compile_nested_function(exarg_T *eap, cctx_T *cctx)
if (func_name == NULL)
r = FAIL;
else
r = generate_NEWFUNC(cctx, name, func_name);
r = generate_NEWFUNC(cctx, lambda_name, func_name);
}
else
{
// Define a local variable for the function reference.
lvar = reserve_local(cctx, name_start, name_end - name_start,
TRUE, ufunc->uf_func_type);
if (lvar == NULL)
return NULL;
if (generate_FUNCREF(cctx, ufunc->uf_dfunc_idx) == FAIL)
return NULL;
r = generate_STORE(cctx, ISN_STORE, lvar->lv_idx, NULL);
@ -5048,7 +5067,12 @@ vim9_declare_error(char_u *name)
case 'w': scope = _("window"); break;
case 't': scope = _("tab"); break;
case 'v': scope = "v:"; break;
case '$': semsg(_(e_declare_env_var), name); return;
case '$': semsg(_(e_declare_env_var), name);
return;
case '&': semsg(_("E1052: Cannot declare an option: %s"), name);
return;
case '@': semsg(_("E1066: Cannot declare a register: %s"), name);
return;
default: return;
}
semsg(_(e_declare_var), scope, name);
@ -5070,6 +5094,8 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
char_u *ret = NULL;
int var_count = 0;
int var_idx;
int scriptvar_sid = 0;
int scriptvar_idx = -1;
int semicolon = 0;
garray_T *instr = &cctx->ctx_instr;
garray_T *stack = &cctx->ctx_type_stack;
@ -5188,9 +5214,14 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
int has_index = FALSE;
int instr_count = -1;
p = (*var_start == '&' || *var_start == '$'
|| *var_start == '@') ? var_start + 1 : var_start;
p = to_name_end(p, TRUE);
if (*var_start == '@')
p = var_start + 2;
else
{
p = (*var_start == '&' || *var_start == '$')
? var_start + 1 : var_start;
p = to_name_end(p, TRUE);
}
// "a: type" is declaring variable "a" with a type, not "a:".
if (is_decl && var_end == var_start + 2 && var_end[-1] == ':')
@ -5208,6 +5239,8 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
if (cctx->ctx_skip != SKIP_YES)
{
int declare_error = FALSE;
if (*var_start == '&')
{
int cc;
@ -5219,11 +5252,7 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
emsg(_(e_const_option));
goto theend;
}
if (is_decl)
{
semsg(_("E1052: Cannot declare an option: %s"), var_start);
goto theend;
}
declare_error = is_decl;
p = var_start;
p = find_option_end(&p, &opt_flags);
if (p == NULL)
@ -5251,62 +5280,38 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
{
dest = dest_env;
type = &t_string;
if (is_decl)
{
vim9_declare_error(name);
goto theend;
}
declare_error = is_decl;
}
else if (*var_start == '@')
{
if (!valid_yank_reg(var_start[1], TRUE))
if (!valid_yank_reg(var_start[1], FALSE) || var_start[1] == '.')
{
emsg_invreg(var_start[1]);
goto theend;
}
dest = dest_reg;
type = &t_string;
if (is_decl)
{
semsg(_("E1066: Cannot declare a register: %s"), name);
goto theend;
}
declare_error = is_decl;
}
else if (varlen > 1 && STRNCMP(var_start, "g:", 2) == 0)
{
dest = dest_global;
if (is_decl)
{
vim9_declare_error(name);
goto theend;
}
declare_error = is_decl;
}
else if (varlen > 1 && STRNCMP(var_start, "b:", 2) == 0)
{
dest = dest_buffer;
if (is_decl)
{
vim9_declare_error(name);
goto theend;
}
declare_error = is_decl;
}
else if (varlen > 1 && STRNCMP(var_start, "w:", 2) == 0)
{
dest = dest_window;
if (is_decl)
{
vim9_declare_error(name);
goto theend;
}
declare_error = is_decl;
}
else if (varlen > 1 && STRNCMP(var_start, "t:", 2) == 0)
{
dest = dest_tab;
if (is_decl)
{
vim9_declare_error(name);
goto theend;
}
declare_error = is_decl;
}
else if (varlen > 1 && STRNCMP(var_start, "v:", 2) == 0)
{
@ -5325,15 +5330,12 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
dest = dest_vimvar;
vtv = get_vim_var_tv(vimvaridx);
type = typval2type_vimvar(vtv, cctx->ctx_type_list);
if (is_decl)
{
vim9_declare_error(name);
goto theend;
}
declare_error = is_decl;
}
else
{
int idx;
int idx;
imported_T *import = NULL;
for (idx = 0; reserved[idx] != NULL; ++idx)
if (STRCMP(reserved[idx], name) == 0)
@ -5374,9 +5376,11 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
}
else if ((varlen > 1 && STRNCMP(var_start, "s:", 2) == 0)
|| lookup_script(var_start, varlen) == OK
|| find_imported(var_start, varlen, cctx) != NULL)
|| (import = find_imported(var_start, varlen, cctx))
!= NULL)
{
dest = dest_script;
char_u *rawname = name + (name[1] == ':' ? 2 : 0);
if (is_decl)
{
if ((varlen > 1 && STRNCMP(var_start, "s:", 2) == 0))
@ -5387,6 +5391,21 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
name);
goto theend;
}
dest = dest_script;
// existing script-local variables should have a type
scriptvar_sid = current_sctx.sc_sid;
if (import != NULL)
scriptvar_sid = import->imp_sid;
scriptvar_idx = get_script_item_idx(scriptvar_sid,
rawname, TRUE);
if (scriptvar_idx >= 0)
{
scriptitem_T *si = SCRIPT_ITEM(scriptvar_sid);
svar_T *sv = ((svar_T *)si->sn_var_vals.ga_data)
+ scriptvar_idx;
type = sv->sv_type;
}
}
else if (name[1] == ':' && name[2] != NUL)
{
@ -5400,6 +5419,12 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
goto theend;
}
}
if (declare_error)
{
vim9_declare_error(name);
goto theend;
}
}
// handle "a:name" as a name, not index "name" on "a"
@ -5466,11 +5491,9 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
{
has_index = TRUE;
if (type->tt_member == NULL)
{
semsg(_("E1088: cannot use an index on %s"), name);
goto theend;
}
member_type = type->tt_member;
member_type = &t_any;
else
member_type = type->tt_member;
}
else
{
@ -5699,6 +5722,18 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
emsg(_(e_missbrac));
goto theend;
}
if (type == &t_any)
{
type_T *idx_type = ((type_T **)stack->ga_data)[
stack->ga_len - 1];
// Index on variable of unknown type: guess the type from the
// index type: number is dict, otherwise dict.
// TODO: should do the assignment at runtime
if (idx_type->tt_type == VAR_NUMBER)
type = &t_list_any;
else
type = &t_dict_any;
}
if (type->tt_type == VAR_DICT
&& may_generate_2STRING(-1, cctx) == FAIL)
goto theend;
@ -5766,21 +5801,7 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
break;
case dest_script:
{
char_u *rawname = name + (name[1] == ':' ? 2 : 0);
imported_T *import = NULL;
int sid = current_sctx.sc_sid;
int idx;
if (name[1] != ':')
{
import = find_imported(name, 0, cctx);
if (import != NULL)
sid = import->imp_sid;
}
idx = get_script_item_idx(sid, rawname, TRUE);
// TODO: specific type
if (idx < 0)
if (scriptvar_idx < 0)
{
char_u *name_s = name;
@ -5796,14 +5817,14 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
vim_snprintf((char *)name_s, len,
"s:%s", name);
}
generate_OLDSCRIPT(cctx, ISN_STORES, name_s, sid,
&t_any);
generate_OLDSCRIPT(cctx, ISN_STORES, name_s,
scriptvar_sid, type);
if (name_s != name)
vim_free(name_s);
}
else
generate_VIM9SCRIPT(cctx, ISN_STORESCRIPT,
sid, idx, &t_any);
scriptvar_sid, scriptvar_idx, type);
}
break;
case dest_local:
@ -7231,7 +7252,10 @@ compile_def_function(ufunc_T *ufunc, int set_return_type, cctx_T *outer_cctx)
int oplen;
int heredoc;
var_end = find_name_end(pskip, NULL, NULL,
if (ea.cmd[0] == '@')
var_end = ea.cmd + 2;
else
var_end = find_name_end(pskip, NULL, NULL,
FNE_CHECK_START | FNE_INCL_BR);
oplen = assignment_len(skipwhite(var_end), &heredoc);
if (oplen > 0)
@ -7451,6 +7475,7 @@ compile_def_function(ufunc_T *ufunc, int set_return_type, cctx_T *outer_cctx)
case CMD_append:
case CMD_change:
case CMD_insert:
case CMD_t:
case CMD_xit:
not_in_vim9(&ea);
goto erret;
@ -7677,8 +7702,21 @@ delete_instr(isn_T *isn)
break;
case ISN_NEWFUNC:
vim_free(isn->isn_arg.newfunc.nf_lambda);
vim_free(isn->isn_arg.newfunc.nf_global);
{
char_u *lambda = isn->isn_arg.newfunc.nf_lambda;
ufunc_T *ufunc = find_func_even_dead(lambda, TRUE, NULL);
if (ufunc != NULL)
{
// Clear uf_dfunc_idx so that the function is deleted.
clear_def_function(ufunc);
ufunc->uf_dfunc_idx = 0;
func_ptr_unref(ufunc);
}
vim_free(lambda);
vim_free(isn->isn_arg.newfunc.nf_global);
}
break;
case ISN_2BOOL:

View File

@ -1422,11 +1422,13 @@ call_def_function(
dict_T *dict = tv_dict->vval.v_dict;
dictitem_T *di;
if (key == NULL || *key == NUL)
if (dict == NULL)
{
emsg(_(e_emptykey));
emsg(_(e_dictnull));
goto on_error;
}
if (key == NULL)
key = (char_u *)"";
tv = STACK_TV_BOT(-3);
di = dict_find(dict, key, -1);
if (di != NULL)

View File

@ -67,9 +67,10 @@ not_in_vim9(exarg_T *eap)
if (in_vim9script())
switch (eap->cmdidx)
{
case CMD_insert:
case CMD_append:
case CMD_change:
case CMD_insert:
case CMD_t:
case CMD_xit:
semsg(_("E1100: Missing :let: %s"), eap->cmd);
return FAIL;

View File

@ -3007,6 +3007,7 @@ read_viminfo(
{
FILE *fp;
char_u *fname;
stat_T st; // mch_stat() of existing viminfo file
if (no_viminfo())
return FAIL;
@ -3031,6 +3032,11 @@ read_viminfo(
vim_free(fname);
if (fp == NULL)
return FAIL;
if (mch_fstat(fileno(fp), &st) < 0 || S_ISDIR(st.st_mode))
{
fclose(fp);
return FAIL;
}
viminfo_errcnt = 0;
do_viminfo(fp, NULL, flags);
@ -3054,12 +3060,12 @@ write_viminfo(char_u *file, int forceit)
FILE *fp_out = NULL; // output viminfo file
char_u *tempname = NULL; // name of temp viminfo file
stat_T st_new; // mch_stat() of potential new file
stat_T st_old; // mch_stat() of existing viminfo file
#if defined(UNIX) || defined(VMS)
mode_t umask_save;
#endif
#ifdef UNIX
int shortname = FALSE; // use 8.3 file name
stat_T st_old; // mch_stat() of existing viminfo file
#endif
#ifdef MSWIN
int hidden = FALSE;
@ -3097,20 +3103,20 @@ write_viminfo(char_u *file, int forceit)
// write the new viminfo into, in the same directory as the
// existing viminfo file, which will be renamed once all writing is
// successful.
if (mch_fstat(fileno(fp_in), &st_old) < 0
|| S_ISDIR(st_old.st_mode)
#ifdef UNIX
// For Unix we check the owner of the file. It's not very nice to
// overwrite a user's viminfo file after a "su root", with a
// viminfo file that the user can't read.
st_old.st_dev = (dev_t)0;
st_old.st_ino = 0;
st_old.st_mode = 0600;
if (mch_stat((char *)fname, &st_old) == 0
&& getuid() != ROOT_UID
&& !(st_old.st_uid == getuid()
? (st_old.st_mode & 0200)
: (st_old.st_gid == getgid()
? (st_old.st_mode & 0020)
: (st_old.st_mode & 0002))))
// For Unix we check the owner of the file. It's not very nice
// to overwrite a user's viminfo file after a "su root", with a
// viminfo file that the user can't read.
|| (getuid() != ROOT_UID
&& !(st_old.st_uid == getuid()
? (st_old.st_mode & 0200)
: (st_old.st_gid == getgid()
? (st_old.st_mode & 0020)
: (st_old.st_mode & 0002))))
#endif
)
{
int tt = msg_didany;
@ -3120,7 +3126,6 @@ write_viminfo(char_u *file, int forceit)
fclose(fp_in);
goto end;
}
#endif
#ifdef MSWIN
// Get the file attributes of the existing viminfo file.
hidden = mch_ishidden(fname);