]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.4373: expression test fails v8.2.4373
authorBram Moolenaar <Bram@vim.org>
Sun, 13 Feb 2022 20:46:18 +0000 (20:46 +0000)
committerBram Moolenaar <Bram@vim.org>
Sun, 13 Feb 2022 20:46:18 +0000 (20:46 +0000)
Problem:    Expression test fails.
Solution:   Make the test work with latest Vim9 syntax.

src/testdir/test_expr.vim
src/version.c

index d45b998c4053a5644c9a4131e512e32da796e0a1..7a998bc3072e4ede917953fd89c7f804e437e5c5 100644 (file)
@@ -595,8 +595,8 @@ endfunc
 
 func Test_function_with_funcref()
   let lines =<< trim END
-      VAR s:F = function('type')
-      VAR s:Fref = function(s:F)
+      let s:F = function('type')
+      let s:Fref = function(s:F)
       call assert_equal(v:t_string, s:Fref('x'))
       call assert_fails("call function('s:F')", 'E700:')
 
@@ -604,17 +604,34 @@ func Test_function_with_funcref()
       call assert_fails("call function('foo()')", 'foo()')
       call assert_fails("function('')", 'E129:')
 
-      legacy let s:Len = {s -> strlen(s)}
+      let s:Len = {s -> strlen(s)}
       call assert_equal(6, s:Len('foobar'))
-      VAR name = string(s:Len)
-      #" can evaluate "function('<lambda>99')"
-      call execute('VAR Ref = ' .. name)
+      let name = string(s:Len)
+      " can evaluate "function('<lambda>99')"
+      call execute('let Ref = ' .. name)
       call assert_equal(4, Ref('text'))
   END
-  call v9.CheckTransLegacySuccess(lines)
-  " skip CheckTransDefSuccess(), cannot assign to script variable
-  call map(lines, {k, v -> v =~ 'legacy' ? v : substitute(v, 's:', '', 'g')})
-  call v9.CheckTransVim9Success(lines)
+  call v9.CheckScriptSuccess(lines)
+
+  let lines =<< trim END
+      vim9script
+      var F = function('type')
+      var Fref = function(F)
+      call assert_equal(v:t_string, Fref('x'))
+      call assert_fails("call function('F')", 'E700:')
+
+      call assert_fails("call function('foo()')", 'E475:')
+      call assert_fails("call function('foo()')", 'foo()')
+      call assert_fails("function('')", 'E129:')
+
+      var Len = (s) => strlen(s)
+      call assert_equal(6, Len('foobar'))
+      var name = string(Len)
+      # can evaluate "function('<lambda>99')"
+      call execute('var Ref = ' .. name)
+      call assert_equal(4, Ref('text'))
+  END
+  call v9.CheckScriptSuccess(lines)
 endfunc
 
 func Test_funcref()
index 744ed8d115004caf3165aa95fa1bc208c0302bfb..30547279d9958c901dd9865b744a939138c65ba9 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4373,
 /**/
     4372,
 /**/