mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 8.2.0313: Vim9: insufficient script tests
Problem: Vim9: insufficient script tests. Solution: Add tests. Make import of alphanumeric name work.
This commit is contained in:
parent
f2d5c240a5
commit
fa29c8abd6
@ -352,6 +352,50 @@ def Test_vim9script()
|
||||
writefile(import_star_lines, 'Ximport.vim')
|
||||
assert_fails('source Ximport.vim', 'E1045:')
|
||||
|
||||
" try to import something that exists but is not exported
|
||||
let import_not_exported_lines =<< trim END
|
||||
vim9script
|
||||
import name from './Xexport.vim'
|
||||
END
|
||||
writefile(import_not_exported_lines, 'Ximport.vim')
|
||||
assert_fails('source Ximport.vim', 'E1049:')
|
||||
|
||||
" import a very long name, requires making a copy
|
||||
let import_long_name_lines =<< trim END
|
||||
vim9script
|
||||
import name012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 from './Xexport.vim'
|
||||
END
|
||||
writefile(import_long_name_lines, 'Ximport.vim')
|
||||
assert_fails('source Ximport.vim', 'E1048:')
|
||||
|
||||
let import_no_from_lines =<< trim END
|
||||
vim9script
|
||||
import name './Xexport.vim'
|
||||
END
|
||||
writefile(import_no_from_lines, 'Ximport.vim')
|
||||
assert_fails('source Ximport.vim', 'E1070:')
|
||||
|
||||
let import_invalid_string_lines =<< trim END
|
||||
vim9script
|
||||
import name from Xexport.vim
|
||||
END
|
||||
writefile(import_invalid_string_lines, 'Ximport.vim')
|
||||
assert_fails('source Ximport.vim', 'E1071:')
|
||||
|
||||
let import_wrong_name_lines =<< trim END
|
||||
vim9script
|
||||
import name from './XnoExport.vim'
|
||||
END
|
||||
writefile(import_wrong_name_lines, 'Ximport.vim')
|
||||
assert_fails('source Ximport.vim', 'E1053:')
|
||||
|
||||
let import_missing_comma_lines =<< trim END
|
||||
vim9script
|
||||
import {exported name} from './Xexport.vim'
|
||||
END
|
||||
writefile(import_missing_comma_lines, 'Ximport.vim')
|
||||
assert_fails('source Ximport.vim', 'E1046:')
|
||||
|
||||
delete('Ximport.vim')
|
||||
delete('Xexport.vim')
|
||||
|
||||
|
@ -738,6 +738,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
313,
|
||||
/**/
|
||||
312,
|
||||
/**/
|
||||
|
@ -172,7 +172,7 @@ find_exported(
|
||||
scriptitem_T *script = SCRIPT_ITEM(sid);
|
||||
|
||||
// isolate one name
|
||||
while (eval_isnamec1(*arg))
|
||||
while (eval_isnamec(*arg))
|
||||
++arg;
|
||||
*name_len = (int)(arg - name);
|
||||
|
||||
@ -262,9 +262,9 @@ handle_import(char_u *arg_start, garray_T *gap, int import_sid)
|
||||
{
|
||||
if (*arg == '*')
|
||||
arg = skipwhite(arg + 1);
|
||||
else
|
||||
else if (eval_isnamec1(*arg))
|
||||
{
|
||||
while (eval_isnamec1(*arg))
|
||||
while (eval_isnamec(*arg))
|
||||
++arg;
|
||||
arg = skipwhite(arg);
|
||||
}
|
||||
@ -273,8 +273,9 @@ handle_import(char_u *arg_start, garray_T *gap, int import_sid)
|
||||
// skip over "as Name "
|
||||
arg = skipwhite(arg + 2);
|
||||
as_ptr = arg;
|
||||
while (eval_isnamec1(*arg))
|
||||
++arg;
|
||||
if (eval_isnamec1(*arg))
|
||||
while (eval_isnamec(*arg))
|
||||
++arg;
|
||||
as_len = (int)(arg - as_ptr);
|
||||
arg = skipwhite(arg);
|
||||
}
|
||||
@ -286,7 +287,7 @@ handle_import(char_u *arg_start, garray_T *gap, int import_sid)
|
||||
}
|
||||
if (STRNCMP("from", arg, 4) != 0 || !VIM_ISWHITE(arg[4]))
|
||||
{
|
||||
emsg(_("E1045: Missing \"from\""));
|
||||
emsg(_("E1070: Missing \"from\""));
|
||||
return NULL;
|
||||
}
|
||||
from_ptr = arg;
|
||||
@ -299,7 +300,7 @@ handle_import(char_u *arg_start, garray_T *gap, int import_sid)
|
||||
ret = get_string_tv(&arg, &tv, TRUE);
|
||||
if (ret == FAIL || tv.vval.v_string == NULL || *tv.vval.v_string == NUL)
|
||||
{
|
||||
emsg(_("E1045: Invalid string after \"from\""));
|
||||
emsg(_("E1071: Invalid string after \"from\""));
|
||||
return NULL;
|
||||
}
|
||||
cmd_end = arg;
|
||||
@ -423,6 +424,7 @@ handle_import(char_u *arg_start, garray_T *gap, int import_sid)
|
||||
}
|
||||
if (arg != from_ptr)
|
||||
{
|
||||
// cannot happen, just in case the above has a flaw
|
||||
emsg(_("E1047: syntax error in import"));
|
||||
return NULL;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user