To: vim_dev@googlegroups.com Subject: Patch 8.2.2881 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.2881 Problem: Various pieces of code not covered by tests. Solution: Add a few more tests. (Yegappan Lakshmanan, closes #8245) Files: src/testdir/test_const.vim, src/testdir/test_functions.vim, src/testdir/test_python2.vim, src/testdir/test_python3.vim, src/testdir/test_user_func.vim, src/testdir/test_vim9_expr.vim, src/testdir/test_vim9_func.vim *** ../vim-8.2.2880/src/testdir/test_const.vim 2020-09-16 21:08:23.642361197 +0200 --- src/testdir/test_const.vim 2021-05-24 15:12:01.267608758 +0200 *************** *** 223,230 **** call add(val, 4) call assert_equal([9, 2, 3, 4], val) call assert_fails('let val = [4, 5, 6]', 'E1122:') - endfunc func Test_const_with_index_access() let l = [1, 2, 3] --- 223,250 ---- call add(val, 4) call assert_equal([9, 2, 3, 4], val) call assert_fails('let val = [4, 5, 6]', 'E1122:') + let l =<< trim END + let d = {} + lockvar d + func d.fn() + return 1 + endfunc + END + let @a = l->join("\n") + call assert_fails('exe @a', 'E741:') + + let l =<< trim END + let d = {} + let d.fn = function("min") + lockvar d.fn + func! d.fn() + return 1 + endfunc + END + let @a = l->join("\n") + call assert_fails('exe @a', 'E741:') + endfunc func Test_const_with_index_access() let l = [1, 2, 3] *** ../vim-8.2.2880/src/testdir/test_functions.vim 2021-05-20 21:14:17.166986859 +0200 --- src/testdir/test_functions.vim 2021-05-24 15:12:01.267608758 +0200 *************** *** 1843,1848 **** --- 1843,1852 ---- call writefile(['func ExistingFunction()', 'echo "yes"', 'endfunc'], 'Xfuncexists2') call assert_fails('source Xfuncexists2', 'E122:') + " Defining a new function from the cmdline should fail if the function is + " already defined + call assert_fails('call feedkeys(":func ExistingFunction()\", "xt")', 'E122:') + delfunc ExistingFunction call assert_equal(0, exists('*ExistingFunction')) call writefile([ *** ../vim-8.2.2880/src/testdir/test_python2.vim 2021-05-19 00:16:09.679188079 +0200 --- src/testdir/test_python2.vim 2021-05-24 15:12:01.267608758 +0200 *************** *** 314,319 **** --- 314,321 ---- 10new py vim.current.window.height = 5 call assert_equal(5, winheight(0)) + py vim.current.window.height = 3.2 + call assert_equal(3, winheight(0)) " Test for setting the window width 10vnew *** ../vim-8.2.2880/src/testdir/test_python3.vim 2021-05-19 00:16:09.679188079 +0200 --- src/testdir/test_python3.vim 2021-05-24 15:12:01.271608751 +0200 *************** *** 511,516 **** --- 511,518 ---- 10new py3 vim.current.window.height = 5 call assert_equal(5, winheight(0)) + py3 vim.current.window.height = 3.2 + call assert_equal(3, winheight(0)) " Test for setting the window width 10vnew *** ../vim-8.2.2880/src/testdir/test_user_func.vim 2021-04-06 20:18:23.331648347 +0200 --- src/testdir/test_user_func.vim 2021-05-24 15:12:01.271608751 +0200 *************** *** 405,410 **** --- 405,411 ---- let l = join(lines, "\n") . "\n" exe l call assert_fails('exe l', 'E717:') + call assert_fails('call feedkeys(":func d.F1()\", "xt")', 'E717:') " Define an autoload function with an incorrect file name call writefile(['func foo#Bar()', 'return 1', 'endfunc'], 'Xscript') *************** *** 420,425 **** --- 421,431 ---- call assert_fails('delfunction Xabc', 'E130:') let d = {'a' : 10} call assert_fails('delfunc d.a', 'E718:') + func d.fn() + return 1 + endfunc + delfunc d.fn + call assert_equal({'a' : 10}, d) endfunc " Test for calling return outside of a function *************** *** 451,461 **** return len(self) endfunc ! call assert_equal("{'a': 'b', 'somefunc': function('2')}", string(mydict)) call assert_equal(2, mydict.somefunc()) call assert_match("^\n function \\d\\\+() dict" \ .. "\n1 return len(self)" \ .. "\n endfunction$", execute('func mydict.somefunc')) endfunc func Test_func_range() --- 457,468 ---- return len(self) endfunc ! call assert_equal("{'a': 'b', 'somefunc': function('3')}", string(mydict)) call assert_equal(2, mydict.somefunc()) call assert_match("^\n function \\d\\\+() dict" \ .. "\n1 return len(self)" \ .. "\n endfunction$", execute('func mydict.somefunc')) + call assert_fails('call mydict.nonexist()', 'E716:') endfunc func Test_func_range() *** ../vim-8.2.2880/src/testdir/test_vim9_expr.vim 2021-05-17 00:01:38.807009262 +0200 --- src/testdir/test_vim9_expr.vim 2021-05-24 15:12:01.271608751 +0200 *************** *** 1941,1946 **** --- 1941,1949 ---- CheckDefAndScriptFailure(["var Ref = (a)=>a + 1"], 'E1004:') CheckDefAndScriptFailure(["var Ref = (a)=> a + 1"], 'E1004: White space required before and after ''=>'' at "=> a + 1"') CheckDefAndScriptFailure(["var Ref = (a) =>a + 1"], 'E1004:') + CheckDefAndScriptFailure2(["var Ref = (a) =< a + 1"], 'E1001:', 'E121:') + CheckDefAndScriptFailure(["var Ref = (a: int) => a + 1"], 'E1010:') + CheckDefAndScriptFailure(["var Ref = (a): int => a + 1"], 'E1010:') CheckDefAndScriptFailure(["filter([1, 2], (k,v) => 1)"], 'E1069:', 1) # error is in first line of the lambda *** ../vim-8.2.2880/src/testdir/test_vim9_func.vim 2021-05-18 11:47:31.884191326 +0200 --- src/testdir/test_vim9_func.vim 2021-05-24 15:12:01.271608751 +0200 *************** *** 887,892 **** --- 887,898 ---- END CheckDefAndScriptFailure(lines, 'E1157:', 1) + # no space before the return type + lines =<< trim END + var Ref = (x):number => x + 1 + END + CheckDefAndScriptFailure(lines, 'E1069:', 1) + # this works for x in ['foo', 'boo'] echo FilterWithCond(x, (v) => v =~ '^b') *************** *** 1318,1323 **** --- 1324,1330 ---- enddef END CheckScriptFailure(lines, 'E1068:') + call assert_fails('vim9cmd echo stridx("a" .. "b" , "a")', 'E1068:') enddef def Test_white_space_after_comma() *** ../vim-8.2.2880/src/version.c 2021-05-24 14:20:50.551669187 +0200 --- src/version.c 2021-05-24 15:13:33.371378270 +0200 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 2881, /**/ -- ARTHUR: Then who is your lord? WOMAN: We don't have a lord. ARTHUR: What? DENNIS: I told you. We're an anarcho-syndicalist commune. We take it in turns to act as a sort of executive officer for the week. The Quest for the Holy Grail (Monty Python) /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///