]> granicus.if.org Git - vim/commitdiff
patch 8.2.2100: insufficient testing for function range and dict v8.2.2100
authorBram Moolenaar <Bram@vim.org>
Sun, 6 Dec 2020 14:03:19 +0000 (15:03 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 6 Dec 2020 14:03:19 +0000 (15:03 +0100)
Problem:    Insufficient testing for function range and dict.
Solution:   Add a few tests. (Dominique PellĂ©, closes #7428)

src/testdir/test_functions.vim
src/testdir/test_lambda.vim
src/testdir/test_signals.vim
src/testdir/test_user_func.vim
src/version.c

index d6e408a8433b7bcae5f875e98d0afdd4fd506078..dd4429e709866eeab3275d57240226d54c8c2d74 100644 (file)
@@ -2099,6 +2099,7 @@ func Test_call()
   let mydict = {'data': [0, 1, 2, 3], 'len': function("Mylen")}
   eval mydict.len->call([], mydict)->assert_equal(4)
   call assert_fails("call call('Mylen', [], 0)", 'E715:')
+  call assert_fails('call foo', 'E107:')
 endfunc
 
 func Test_char2nr()
index aa734624addab26797ea1e3f69d10591e32533f4..60d58c542b845c358575435d7e82d66cfb1e3fca 100644 (file)
@@ -247,6 +247,11 @@ func Test_closure_counter()
   call assert_equal(2, l:F())
   call assert_equal(3, l:F())
   call assert_equal(4, l:F())
+
+  call assert_match("^\n   function <SNR>\\d\\+_bar() closure"
+  \              .. "\n1        let x += 1"
+  \              .. "\n2        return x"
+  \              .. "\n   endfunction$", execute('func s:bar'))
 endfunc
 
 func Test_closure_unlet()
index 78b2cecb8580264b15a240aae93387ff630013b9..1723f33108d5b70dc7326298990de0be47bf2409 100644 (file)
@@ -153,8 +153,7 @@ func Test_deadly_signal_TERM()
   call assert_equal(['foo'], getline(1, '$'))
 
   let result = readfile('XautoOut')
-  call assert_match('VimLeavePre triggered', result[0])
-  call assert_match('VimLeave triggered', result[1])
+  call assert_equal(["VimLeavePre triggered", "VimLeave triggered"], result)
 
   %bwipe!
   call delete('.Xsig_TERM.swp')
index 2edaec87ece02b00f64f5572873669f27be82591..2db558931daf05176de865db75eacd112f33d673 100644 (file)
@@ -445,4 +445,36 @@ func Test_func_arg_error()
   delfunc Xfunc
 endfunc
 
+func Test_func_dict()
+  let mydict = {'a': 'b'}
+  function mydict.somefunc() dict
+    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()
+  new
+  call setline(1, range(1, 8))
+  func FuncRange() range
+    echo a:firstline
+    echo a:lastline
+  endfunc
+  3
+  call assert_equal("\n3\n3", execute('call FuncRange()'))
+  call assert_equal("\n4\n6", execute('4,6 call FuncRange()'))
+  call assert_equal("\n   function FuncRange() range"
+  \              .. "\n1      echo a:firstline"
+  \              .. "\n2      echo a:lastline"
+  \              .. "\n   endfunction",
+  \                 execute('function FuncRange'))
+
+  bwipe!
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index 9903918f1e72fdcb3f697082299a07d4ffb4afcc..2754d2f72279a49c0413037152439d2dc7aa1ce4 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2100,
 /**/
     2099,
 /**/