]> granicus.if.org Git - vim/commitdiff
patch 8.2.2881: various pieces of code not covered by tests v8.2.2881
authorYegappan Lakshmanan <yegappan@yahoo.com>
Mon, 24 May 2021 13:15:47 +0000 (15:15 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 24 May 2021 13:15:47 +0000 (15:15 +0200)
Problem:    Various pieces of code not covered by tests.
Solution:   Add a few more tests. (Yegappan Lakshmanan, closes #8245)

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
src/version.c

index c88efa632b060a0b9ab7c83bce8ce1572def3942..2b79f42feb28ad266709b5d962300a3812529b3f 100644 (file)
@@ -223,8 +223,28 @@ func Test_lockvar()
   call add(val, 4)
   call assert_equal([9, 2, 3, 4], val)
   call assert_fails('let val = [4, 5, 6]', 'E1122:')
-endfunc
 
+  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]
index b4d462b86c03e42ed6536c59ca554c416e0fc1fb..dcc2b0486303b5532248120c8ed70e9c0b7c063e 100644 (file)
@@ -1843,6 +1843,10 @@ func Test_func_exists_on_reload()
   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()\<CR>", "xt")', 'E122:')
+
   delfunc ExistingFunction
   call assert_equal(0, exists('*ExistingFunction'))
   call writefile([
index 84c917316ddc4f212e1f63cf6d6513467e7bccea..89afa2b5a1b3bbb2691d5ed706ad515731e93ff2 100644 (file)
@@ -314,6 +314,8 @@ func Test_python_window()
   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
index 1e9ef82b0750015fb3c6715a81c044f76d5c0e2c..66d5db57fef91ce75036d96f963587565b9e4e63 100644 (file)
@@ -511,6 +511,8 @@ func Test_python3_window()
   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
index a58aa64b9de60fade7a65a2ecb9a7acd2d99f225..4b8ec99a2b3a0cfe84057fd693318d9a40114095 100644 (file)
@@ -405,6 +405,7 @@ func Test_func_def_error()
   let l = join(lines, "\n") . "\n"
   exe l
   call assert_fails('exe l', 'E717:')
+  call assert_fails('call feedkeys(":func d.F1()\<CR>", "xt")', 'E717:')
 
   " Define an autoload function with an incorrect file name
   call writefile(['func foo#Bar()', 'return 1', 'endfunc'], 'Xscript')
@@ -420,6 +421,11 @@ func Test_del_func()
   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,11 +457,12 @@ func Test_func_dict()
     return len(self)
   endfunc
 
-  call assert_equal("{'a': 'b', 'somefunc': function('2')}", string(mydict))
+  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()
index fe5de29d0bb6628df980cb70c1ae81d2c7bee88d..4a67522cb62191fb20c2cb8fa644b55fbd5d801f 100644 (file)
@@ -1941,6 +1941,9 @@ def Test_expr7_lambda()
   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
index 7eca70919dd2dd479d77548c20eac40536ce0ee8..2ac97d0f46741c22f1256f187e42a967a20be3ba 100644 (file)
@@ -887,6 +887,12 @@ def Test_lambda_return_type()
   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,6 +1324,7 @@ def Test_white_space_before_comma()
     enddef
   END
   CheckScriptFailure(lines, 'E1068:')
+  call assert_fails('vim9cmd echo stridx("a" .. "b" , "a")', 'E1068:')
 enddef
 
 def Test_white_space_after_comma()
index 1c4bbfada614f6d7f278a3e39ab766dbeeec2aee..7fb1401122c7a8122e93730fbf53840574797162 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2881,
 /**/
     2880,
 /**/