aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-04-15 17:13:54 +0800
committerzeertzjq <zeertzjq@outlook.com>2023-04-15 17:14:49 +0800
commit408e5d16a9ecce7e4107298faf3e8f36f0712495 (patch)
treea3a3a2870826080c6e41270f7974ffa2ec9b2d7d
parentb29df57ba7e7e853a3f8082020e7658f468ea826 (diff)
downloadrneovim-408e5d16a9ecce7e4107298faf3e8f36f0712495.tar.gz
rneovim-408e5d16a9ecce7e4107298faf3e8f36f0712495.tar.bz2
rneovim-408e5d16a9ecce7e4107298faf3e8f36f0712495.zip
vim-patch:8.2.4373: expression test fails
Problem: Expression test fails. Solution: Make the test work with latest Vim9 syntax. https://github.com/vim/vim/commit/c87aa34dfd68e95e4b1aac96d2274fcd672753ac Co-authored-by: Bram Moolenaar <Bram@vim.org>
-rw-r--r--test/old/testdir/test_expr.vim37
1 files changed, 27 insertions, 10 deletions
diff --git a/test/old/testdir/test_expr.vim b/test/old/testdir/test_expr.vim
index 95ae54b6c1..3e5b21a07c 100644
--- a/test/old/testdir/test_expr.vim
+++ b/test/old/testdir/test_expr.vim
@@ -596,8 +596,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:')
@@ -605,17 +605,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 CheckTransLegacySuccess(lines)
- " skip CheckTransDefSuccess(), cannot assign to script variable
- call map(lines, {k, v -> v =~ 'legacy' ? v : substitute(v, 's:', '', 'g')})
- call CheckTransVim9Success(lines)
+ call 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 CheckScriptSuccess(lines)
endfunc
func Test_funcref()