To: vim_dev@googlegroups.com Subject: Patch 8.2.0313 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0313 Problem: Vim9: insufficient script tests. Solution: Add tests. Make import of alphanumeric name work. Files: src/testdir/test_vim9_script.vim, src/vim9script.c *** ../vim-8.2.0312/src/testdir/test_vim9_script.vim 2020-02-23 21:25:50.464675047 +0100 --- src/testdir/test_vim9_script.vim 2020-02-23 22:20:47.334097263 +0100 *************** *** 352,357 **** --- 352,401 ---- 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') *** ../vim-8.2.0312/src/vim9script.c 2020-02-23 21:25:50.464675047 +0100 --- src/vim9script.c 2020-02-23 22:28:35.612694106 +0100 *************** *** 172,178 **** scriptitem_T *script = SCRIPT_ITEM(sid); // isolate one name ! while (eval_isnamec1(*arg)) ++arg; *name_len = (int)(arg - name); --- 172,178 ---- scriptitem_T *script = SCRIPT_ITEM(sid); // isolate one name ! while (eval_isnamec(*arg)) ++arg; *name_len = (int)(arg - name); *************** *** 262,270 **** { if (*arg == '*') arg = skipwhite(arg + 1); ! else { ! while (eval_isnamec1(*arg)) ++arg; arg = skipwhite(arg); } --- 262,270 ---- { if (*arg == '*') arg = skipwhite(arg + 1); ! else if (eval_isnamec1(*arg)) { ! while (eval_isnamec(*arg)) ++arg; arg = skipwhite(arg); } *************** *** 273,280 **** // skip over "as Name " arg = skipwhite(arg + 2); as_ptr = arg; ! while (eval_isnamec1(*arg)) ! ++arg; as_len = (int)(arg - as_ptr); arg = skipwhite(arg); } --- 273,281 ---- // skip over "as Name " arg = skipwhite(arg + 2); as_ptr = arg; ! if (eval_isnamec1(*arg)) ! while (eval_isnamec(*arg)) ! ++arg; as_len = (int)(arg - as_ptr); arg = skipwhite(arg); } *************** *** 286,292 **** } if (STRNCMP("from", arg, 4) != 0 || !VIM_ISWHITE(arg[4])) { ! emsg(_("E1045: Missing \"from\"")); return NULL; } from_ptr = arg; --- 287,293 ---- } if (STRNCMP("from", arg, 4) != 0 || !VIM_ISWHITE(arg[4])) { ! emsg(_("E1070: Missing \"from\"")); return NULL; } from_ptr = arg; *************** *** 299,305 **** 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\"")); return NULL; } cmd_end = arg; --- 300,306 ---- ret = get_string_tv(&arg, &tv, TRUE); if (ret == FAIL || tv.vval.v_string == NULL || *tv.vval.v_string == NUL) { ! emsg(_("E1071: Invalid string after \"from\"")); return NULL; } cmd_end = arg; *************** *** 423,428 **** --- 424,430 ---- } if (arg != from_ptr) { + // cannot happen, just in case the above has a flaw emsg(_("E1047: syntax error in import")); return NULL; } *** ../vim-8.2.0312/src/version.c 2020-02-23 21:25:50.464675047 +0100 --- src/version.c 2020-02-23 22:29:05.448602462 +0100 *************** *** 740,741 **** --- 740,743 ---- { /* Add new patch number below this line */ + /**/ + 313, /**/ -- hundred-and-one symptoms of being an internet addict: 110. You actually volunteer to become your employer's webmaster. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///