To: vim_dev@googlegroups.com Subject: Patch 8.2.0503 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0503 Problem: Vim9: some code is not tested. Solution: Add tests. Fix uncovered problems. Files: src/vim9compile.c, src/testdir/test_vim9_script.vim *** ../vim-8.2.0502/src/vim9compile.c 2020-04-02 21:13:21.388362421 +0200 --- src/vim9compile.c 2020-04-02 22:15:06.120821633 +0200 *************** *** 4972,4977 **** --- 4972,4978 ---- // Fill in the "end" label in jumps at the end of the blocks. compile_fill_jump_to_end(&scope->se_u.se_try.ts_end_label, cctx); + isn->isn_arg.try.try_finally = instr->ga_len; if (scope->se_u.se_try.ts_catch_label != 0) { // Previous catch without match jumps here *************** *** 4979,4985 **** isn->isn_arg.jump.jump_where = instr->ga_len; } - isn->isn_arg.try.try_finally = instr->ga_len; // TODO: set index in ts_finally_label jumps return arg; --- 4980,4985 ---- *************** *** 5350,5362 **** line = p; continue; } ! if (ea.cmdidx == CMD_let) ! { ! line = compile_assignment(ea.cmd, &ea, CMD_SIZE, &cctx); ! if (line == NULL) ! goto erret; ! continue; ! } iemsg("Command from find_ex_command() not handled"); goto erret; } --- 5350,5356 ---- line = p; continue; } ! // CMD_let cannot happen, compile_assignment() above is used iemsg("Command from find_ex_command() not handled"); goto erret; } *************** *** 5464,5469 **** --- 5458,5464 ---- } if (line == NULL) goto erret; + line = skipwhite(line); if (cctx.ctx_type_stack.ga_len < 0) { *** ../vim-8.2.0502/src/testdir/test_vim9_script.vim 2020-04-02 21:13:21.396362396 +0200 --- src/testdir/test_vim9_script.vim 2020-04-02 22:31:42.772675662 +0200 *************** *** 112,117 **** --- 112,119 ---- call CheckDefFailure(['¬ex += 3'], 'E113:') call CheckDefFailure(['&ts ..= "xxx"'], 'E1019:') call CheckDefFailure(['&path += 3'], 'E1013:') + " test freeing ISN_STOREOPT + call CheckDefFailure(['&ts = 3', 'let asdf'], 'E1022:') &ts = 8 g:inc_counter += 1 *************** *** 171,176 **** --- 173,181 ---- let thechannel: channel assert_equal(test_null_channel(), thechannel) endif + + let nr = 1234 | nr = 5678 + assert_equal(5678, nr) enddef func Test_assignment_failure() *************** *** 253,260 **** --- 258,273 ---- func Test_block_failure() call CheckDefFailure(['{', 'let inner = 1', '}', 'echo inner'], 'E1001:') + call CheckDefFailure(['}'], 'E1025:') + call CheckDefFailure(['{', 'echo 1'], 'E1026:') endfunc + def Test_cmd_modifier() + tab echo '0' + call CheckDefFailure(['5tab echo 3'], 'E16:') + enddef + + def ReturnString(): string return 'string' enddef *************** *** 326,331 **** --- 339,346 ---- assert_equal('string', MyDefaultArgs()) assert_equal('one', MyDefaultArgs('one')) assert_fails('call MyDefaultArgs("one", "two")', 'E118:') + + call CheckScriptFailure(['def Func(arg: number = asdf)', 'enddef'], 'E1001:') enddef func Test_call_default_args_from_func() *************** *** 480,485 **** --- 495,510 ---- call CheckDefFailure(['catch'], 'E603:') call CheckDefFailure(['try', 'echo 0', 'catch','catch'], 'E1033:') call CheckDefFailure(['try', 'echo 0', 'catch /pat'], 'E1067:') + call CheckDefFailure(['finally'], 'E606:') + call CheckDefFailure(['try', 'echo 0', 'finally', 'echo 1', 'finally'], 'E607:') + call CheckDefFailure(['endtry'], 'E602:') + call CheckDefFailure(['while 1', 'endtry'], 'E170:') + call CheckDefFailure(['for i in range(5)', 'endtry'], 'E170:') + call CheckDefFailure(['if 2', 'endtry'], 'E171:') + call CheckDefFailure(['try', 'echo 1', 'endtry'], 'E1032:') + + call CheckDefFailure(['throw'], 'E471:') + call CheckDefFailure(['throw xxx'], 'E1001:') enddef let s:export_script_lines =<< trim END *************** *** 939,944 **** --- 964,970 ---- call CheckDefFailure(['else'], 'E581:') call CheckDefFailure(['endif'], 'E580:') call CheckDefFailure(['if true', 'elseif xxx'], 'E1001:') + call CheckDefFailure(['if true', 'echo 1'], 'E171:') enddef let g:bool_true = v:true *************** *** 951,956 **** --- 977,992 ---- endif assert_equal(true, res) + g:glob = 2 + if false + execute('let g:glob = 3') + endif + assert_equal(2, g:glob) + if true + execute('let g:glob = 3') + endif + assert_equal(3, g:glob) + res = false if g:bool_true ? true : false res = true *************** *** 1092,1101 **** execute cmd_first .. cmd_last assert_equal('execute-var-var', getline(1)) bwipe! enddef def Test_echo_cmd() ! echo 'something' assert_match('^something$', Screenline(&lines)) let str1 = 'some' --- 1128,1140 ---- execute cmd_first .. cmd_last assert_equal('execute-var-var', getline(1)) bwipe! + + call CheckDefFailure(['execute xxx'], 'E1001:') enddef def Test_echo_cmd() ! echo 'some' ! echon 'thing' assert_match('^something$', Screenline(&lines)) let str1 = 'some' *************** *** 1141,1146 **** --- 1180,1186 ---- call CheckDefFailure(['for i in "text"'], 'E1024:') call CheckDefFailure(['for i in xxx'], 'E1001:') call CheckDefFailure(['endfor'], 'E588:') + call CheckDefFailure(['for i in range(3)', 'echo 3'], 'E170:') enddef def Test_while_loop() *************** *** 1166,1171 **** --- 1206,1212 ---- call CheckDefFailure(['if true', 'continue'], 'E586:') call CheckDefFailure(['break'], 'E587:') call CheckDefFailure(['if true', 'break'], 'E587:') + call CheckDefFailure(['while 1', 'echo 3'], 'E170:') enddef def Test_interrupt_loop() *************** *** 1185,1212 **** assert_true(caught, 'should have caught an exception') enddef - def Test_substitute_cmd() - new - setline(1, 'something') - :substitute(some(other( - assert_equal('otherthing', getline(1)) - bwipe! - - " also when the context is Vim9 script - let lines =<< trim END - vim9script - new - setline(1, 'something') - :substitute(some(other( - assert_equal('otherthing', getline(1)) - bwipe! - END - writefile(lines, 'Xvim9lines') - source Xvim9lines - - delete('Xvim9lines') - enddef - def Test_redef_failure() call writefile(['def Func0(): string', 'return "Func0"', 'enddef'], 'Xdef') so Xdef --- 1226,1231 ---- *************** *** 1285,1288 **** --- 1304,1330 ---- call delete('Xinvalidarg') endfunc + " Keep this last, it messes up highlighting. + def Test_substitute_cmd() + new + setline(1, 'something') + :substitute(some(other( + assert_equal('otherthing', getline(1)) + bwipe! + + " also when the context is Vim9 script + let lines =<< trim END + vim9script + new + setline(1, 'something') + :substitute(some(other( + assert_equal('otherthing', getline(1)) + bwipe! + END + writefile(lines, 'Xvim9lines') + source Xvim9lines + + delete('Xvim9lines') + enddef + " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker *** ../vim-8.2.0502/src/version.c 2020-04-02 21:13:21.396362396 +0200 --- src/version.c 2020-04-02 21:31:52.488123728 +0200 *************** *** 740,741 **** --- 740,743 ---- { /* Add new patch number below this line */ + /**/ + 503, /**/ -- "When I die, I want a tombstone that says "GAME OVER" - Ton Richters /// 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 ///