]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0819: tests: using findexpr and imported func not tested v9.1.0819
authorYegappan Lakshmanan <yegappan@yahoo.com>
Mon, 28 Oct 2024 20:01:28 +0000 (21:01 +0100)
committerChristian Brabandt <cb@256bit.org>
Mon, 28 Oct 2024 20:01:28 +0000 (21:01 +0100)
Problem:  tests: need a test for findexpr and vim9 imported func
Solution: Add a test for 'findexpr' and Vim9 imported script
          (Yegappan Lakshmanan)

closes: #15954

Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/testdir/test_vim9_import.vim
src/version.c

index fb309cb3bc009ebd18bb5bc1c77f479c6b1d3b21..ad0248c179a967fe17424237e7a4fc59b88aeef4 100644 (file)
@@ -1560,6 +1560,43 @@ def Run_Test_import_in_printexpr()
   set printexpr=
 enddef
 
+" Test for using an imported function as 'findexpr'
+func Test_import_in_findexpr()
+  call Run_Test_import_in_findexpr()
+endfunc
+
+def Run_Test_import_in_findexpr()
+  var lines =<< trim END
+      vim9script
+
+      export def FindExpr(): list<string>
+        var fnames = ['Xfile1.c', 'Xfile2.c', 'Xfile3.c']
+        return fnames->copy()->filter('v:val =~? v:fname')
+      enddef
+  END
+  writefile(lines, 'Xfindexpr', 'D')
+
+  lines =<< trim END
+      vim9script
+      import './Xfindexpr' as find
+
+      set findexpr=find.FindExpr()
+  END
+  v9.CheckScriptSuccess(lines)
+
+  enew!
+  find Xfile2
+  assert_equal('Xfile2.c', @%)
+  bwipe!
+
+  botright vert new
+  find Xfile1
+  assert_equal('Xfile1.c', @%)
+
+  set findexpr=
+  bwipe!
+enddef
+
 def Test_import_in_charconvert()
   var lines =<< trim END
       vim9script
index 02e24d5529ce3859cb5e1c03a4b1e0e6288e529c..838f25acda06a17d18d9622ee926d55d1e0bd352 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    819,
 /**/
     818,
 /**/