]> granicus.if.org Git - vim/commitdiff
patch 8.2.3333: Vim9: not enough tests run with Vim9 v8.2.3333
authorBram Moolenaar <Bram@vim.org>
Thu, 12 Aug 2021 08:39:10 +0000 (10:39 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 12 Aug 2021 08:39:10 +0000 (10:39 +0200)
Problem:    Vim9: not enough tests run with Vim9.
Solution:   Run a few more tests in Vim9 script and :def function.

src/testdir/test_listdict.vim
src/testdir/vim9.vim
src/version.c

index 1e7c8125c2881242677e97bc70492a405fadc6c3..f9048724cc6415f9029d075ea7693089adbfa4ce 100644 (file)
@@ -457,6 +457,19 @@ func Test_dict_func_remove_in_use()
   endfunc
   let expected = 'a:' . string(get(d, 'func'))
   call assert_equal(expected, d.func(string(remove(d, 'func'))))
+
+  " similar, in a way it also works in Vim9
+  let lines =<< trim END
+      VAR d = {1: 1, 2: 'x'}
+      func GetArg(a)
+        return "a:" .. a:a
+      endfunc
+      LET d.func = function('GetArg')
+      VAR expected = 'a:' .. string(get(d, 'func'))
+      call assert_equal(expected, d.func(string(remove(d, 'func'))))
+  END
+  call CheckTransLegacySuccess(lines)
+  call CheckTransVim9Success(lines)
 endfunc
 
 func Test_dict_literal_keys()
index cb66d4260863e5a8452697d77f4bd2792c99fcb2..879d918be547032662981dc5504cb34091ec0707 100644 (file)
@@ -107,7 +107,7 @@ def CheckDefAndScriptFailure(lines: list<string>, error: string, lnum = -3)
   CheckScriptFailure(['vim9script'] + lines, error, lnum + 1)
 enddef
 
-" As CheckDefAndScriptFailure() but with two different exepected errors.
+" As CheckDefAndScriptFailure() but with two different expected errors.
 def CheckDefAndScriptFailure2(
        lines: list<string>,
        errorDef: string,
@@ -166,24 +166,44 @@ func CheckLegacyFailure(lines, error)
   endtry
 endfunc
 
-" Execute "lines" in a legacy function, :def function and Vim9 script.
-" Use 'VAR' for a declaration.
-" Use 'LET' for an assignment
-" Use ' #"' for a comment
-def CheckLegacyAndVim9Success(lines: list<string>)
+" Execute "lines" in a legacy function, translated as in
+" CheckLegacyAndVim9Success()
+def CheckTransLegacySuccess(lines: list<string>)
   var legacylines = lines->mapnew((_, v) =>
                                v->substitute('\<VAR\>', 'let', 'g')
                                 ->substitute('\<LET\>', 'let', 'g')
                                 ->substitute('#"', ' "', 'g'))
   CheckLegacySuccess(legacylines)
+enddef
 
+" Execute "lines" in a :def function, translated as in
+" CheckLegacyAndVim9Success()
+def CheckTransDefSuccess(lines: list<string>)
   var vim9lines = lines->mapnew((_, v) =>
                                v->substitute('\<VAR\>', 'var', 'g')
                                 ->substitute('\<LET ', '', 'g'))
   CheckDefSuccess(vim9lines)
+enddef
+
+" Execute "lines" in a Vim9 script, translated as in
+" CheckLegacyAndVim9Success()
+def CheckTransVim9Success(lines: list<string>)
+  var vim9lines = lines->mapnew((_, v) =>
+                               v->substitute('\<VAR\>', 'var', 'g')
+                                ->substitute('\<LET ', '', 'g'))
   CheckScriptSuccess(['vim9script'] + vim9lines)
 enddef
 
+" Execute "lines" in a legacy function, :def function and Vim9 script.
+" Use 'VAR' for a declaration.
+" Use 'LET' for an assignment
+" Use ' #"' for a comment
+def CheckLegacyAndVim9Success(lines: list<string>)
+  CheckTransLegacySuccess(lines)
+  CheckTransDefSuccess(lines)
+  CheckTransVim9Success(lines)
+enddef
+
 " Execute "lines" in a legacy function, :def function and Vim9 script.
 " Use 'VAR' for a declaration.
 " Use 'LET' for an assignment
index 9579c27890bf9d67f720c2f4aa95f9f9bdc0e223..4e374026b4ce7bd7f42af6c9b4b1ffb35e98c3ac 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3333,
 /**/
     3332,
 /**/