]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1998: tests: not enough tests for :setlocal omnifunc v9.1.1998
authorzeertzjq <zeertzjq@outlook.com>
Thu, 18 Dec 2025 20:02:48 +0000 (21:02 +0100)
committerChristian Brabandt <cb@256bit.org>
Thu, 18 Dec 2025 20:02:48 +0000 (21:02 +0100)
Problem:  Not enough tests for :setlocal omnifunc (after 9.1.1991).
Solution: Move the last :new after :setlocal. Also test with 'complete'
          (zeertzjq).

closes: #18958

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/testdir/test_ins_complete.vim
src/testdir/test_tagfunc.vim
src/version.c

index 315b81e49e25ef4d1c5e4424a8d518326bc67e94..b60f7c62234adc1009fee80c61b7d6e298a34fac 100644 (file)
@@ -2428,32 +2428,49 @@ func Test_completefunc_callback()
     bw!
 
     #" :setlocal and :setglobal
-    set completefunc&
+    set complete=F completefunc&
     setlocal completefunc=function('g:CompleteFunc1',\ [22])
     call setline(1, 'sun')
     LET g:CompleteFunc1Args = []
     call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
     call assert_equal([[22, 1, ''], [22, 0, 'sun']], g:CompleteFunc1Args)
+    LET g:CompleteFunc1Args = []
+    call feedkeys("A\<C-N>\<Esc>", 'x')
+    call assert_equal([[22, 1, ''], [22, 0, 'sun']], g:CompleteFunc1Args)
     new
     call setline(1, 'sun')
     LET g:CompleteFunc1Args = []
     call assert_fails('call feedkeys("A\<C-X>\<C-U>\<Esc>", "x")', 'E764:')
     call assert_equal([], g:CompleteFunc1Args)
+    LET g:CompleteFunc1Args = []
+    call feedkeys("A\<C-N>\<Esc>", 'x')
+    call assert_equal([], g:CompleteFunc1Args)
     bw!
     setglobal completefunc=function('g:CompleteFunc1',\ [23])
     call setline(1, 'sun')
+    LET g:CompleteFunc1Args = []
     call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
     call assert_equal([[22, 1, ''], [22, 0, 'sun']], g:CompleteFunc1Args)
-    new
-    call setline(1, 'sun')
     LET g:CompleteFunc1Args = []
-    call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
-    call assert_equal([[23, 1, ''], [23, 0, 'sun']], g:CompleteFunc1Args)
+    call feedkeys("A\<C-N>\<Esc>", 'x')
+    call assert_equal([[22, 1, ''], [22, 0, 'sun']], g:CompleteFunc1Args)
     setlocal completefunc&
     call setline(1, 'sun')
     LET g:CompleteFunc1Args = []
     call assert_fails('call feedkeys("A\<C-X>\<C-U>\<Esc>", "x")', 'E764:')
     call assert_equal([], g:CompleteFunc1Args)
+    LET g:CompleteFunc1Args = []
+    call feedkeys("A\<C-N>\<Esc>", 'x')
+    call assert_equal([], g:CompleteFunc1Args)
+    new
+    call setline(1, 'sun')
+    LET g:CompleteFunc1Args = []
+    call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
+    call assert_equal([[23, 1, ''], [23, 0, 'sun']], g:CompleteFunc1Args)
+    LET g:CompleteFunc1Args = []
+    call feedkeys("A\<C-N>\<Esc>", 'x')
+    call assert_equal([[23, 1, ''], [23, 0, 'sun']], g:CompleteFunc1Args)
+    set complete& completefunc&
     :%bw!
   END
   call v9.CheckLegacyAndVim9Success(lines)
@@ -2731,32 +2748,49 @@ func Test_omnifunc_callback()
     bw!
 
     #" :setlocal and :setglobal
-    set omnifunc&
+    set complete=o omnifunc&
     setlocal omnifunc=function('g:OmniFunc1',\ [22])
     call setline(1, 'sun')
     LET g:OmniFunc1Args = []
     call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
     call assert_equal([[22, 1, ''], [22, 0, 'sun']], g:OmniFunc1Args)
+    LET g:OmniFunc1Args = []
+    call feedkeys("A\<C-N>\<Esc>", 'x')
+    call assert_equal([[22, 1, ''], [22, 0, 'sun']], g:OmniFunc1Args)
     new
     call setline(1, 'sun')
     LET g:OmniFunc1Args = []
     call assert_fails('call feedkeys("A\<C-X>\<C-O>\<Esc>", "x")', 'E764:')
     call assert_equal([], g:OmniFunc1Args)
+    LET g:OmniFunc1Args = []
+    call feedkeys("A\<C-N>\<Esc>", 'x')
+    call assert_equal([], g:OmniFunc1Args)
     bw!
     setglobal omnifunc=function('g:OmniFunc1',\ [23])
     call setline(1, 'sun')
+    LET g:OmniFunc1Args = []
     call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
     call assert_equal([[22, 1, ''], [22, 0, 'sun']], g:OmniFunc1Args)
-    new
-    call setline(1, 'sun')
     LET g:OmniFunc1Args = []
-    call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
-    call assert_equal([[23, 1, ''], [23, 0, 'sun']], g:OmniFunc1Args)
+    call feedkeys("A\<C-N>\<Esc>", 'x')
+    call assert_equal([[22, 1, ''], [22, 0, 'sun']], g:OmniFunc1Args)
     setlocal omnifunc&
     call setline(1, 'sun')
     LET g:OmniFunc1Args = []
     call assert_fails('call feedkeys("A\<C-X>\<C-O>\<Esc>", "x")', 'E764:')
     call assert_equal([], g:OmniFunc1Args)
+    LET g:OmniFunc1Args = []
+    call feedkeys("A\<C-N>\<Esc>", 'x')
+    call assert_equal([], g:OmniFunc1Args)
+    new
+    call setline(1, 'sun')
+    LET g:OmniFunc1Args = []
+    call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
+    call assert_equal([[23, 1, ''], [23, 0, 'sun']], g:OmniFunc1Args)
+    LET g:OmniFunc1Args = []
+    call feedkeys("A\<C-N>\<Esc>", 'x')
+    call assert_equal([[23, 1, ''], [23, 0, 'sun']], g:OmniFunc1Args)
+    set complete& omnifunc&
     :%bw!
   END
   call v9.CheckLegacyAndVim9Success(lines)
index 286a54a3c5266855afa5550f775541cdac53ac75..4ce9d2164b4c9238b7b486977cdd7584ce96a8bf 100644 (file)
@@ -275,16 +275,17 @@ func Test_tagfunc_callback()
     call assert_equal([], g:TagFunc1Args)
     bw!
     setglobal tagfunc=function('g:TagFunc1',\ [23])
+    LET g:TagFunc1Args = []
     call assert_fails("tag a22", 'E433:')
     call assert_equal([22, 'a22', '', {}], g:TagFunc1Args)
-    new
-    LET g:TagFunc1Args = []
-    call assert_fails("tag a23", 'E433:')
-    call assert_equal([23, 'a23', '', {}], g:TagFunc1Args)
     setlocal tagfunc&
     LET g:TagFunc1Args = []
     call assert_fails("tag a23", 'E433:')
     call assert_equal([], g:TagFunc1Args)
+    new
+    LET g:TagFunc1Args = []
+    call assert_fails("tag a23", 'E433:')
+    call assert_equal([23, 'a23', '', {}], g:TagFunc1Args)
     :%bw!
   END
   call v9.CheckLegacyAndVim9Success(lines)
index a8783de4b1a07e5fb80359aea36e24e639a42d48..39b6496e3ba37aa724ddd17413a6572d0f074dcb 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1998,
 /**/
     1997,
 /**/