summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYegappan Lakshmanan <yegappan@yahoo.com>2021-12-12 20:08:05 +0000
committerBram Moolenaar <Bram@vim.org>2021-12-12 20:08:05 +0000
commit04ef1fb13d200f770952e670357dddadb6210dd4 (patch)
tree39647e7db85fd8053c52bab8da89b9b6f720fe25
parentd2439e0443ee26931ab93874c05cc7f57e9af93d (diff)
downloadvim-git-04ef1fb13d200f770952e670357dddadb6210dd4.tar.gz
patch 8.2.3792: setting *func options insufficiently testedv8.2.3792
Problem: Setting *func options insufficiently tested. Solution: Impove tests. (Yegappan Lakshmanan, closes #9337)
-rw-r--r--src/testdir/test_iminsert.vim17
-rw-r--r--src/testdir/test_ins_complete.vim400
-rw-r--r--src/testdir/test_normal.vim132
-rw-r--r--src/testdir/test_quickfix.vim7
-rw-r--r--src/testdir/test_tagfunc.vim132
-rw-r--r--src/version.c2
6 files changed, 386 insertions, 304 deletions
diff --git a/src/testdir/test_iminsert.vim b/src/testdir/test_iminsert.vim
index 860fb07ad..db6152fb5 100644
--- a/src/testdir/test_iminsert.vim
+++ b/src/testdir/test_iminsert.vim
@@ -125,6 +125,11 @@ func Test_imactivatefunc_imstatusfunc_callback()
LET g:IMactivatefunc_called = 0
LET g:IMstatusfunc_called = 0
+ #" Test for using a function name
+ LET &imactivatefunc = 'g:IMactivatefunc1'
+ LET &imstatusfunc = 'g:IMstatusfunc1'
+ normal! i
+
#" Test for using a function()
set imactivatefunc=function('g:IMactivatefunc1')
set imstatusfunc=function('g:IMstatusfunc1')
@@ -215,8 +220,8 @@ func Test_imactivatefunc_imstatusfunc_callback()
call assert_fails("LET &imstatusfunc = function('NonExistingFunc')", 'E700:')
normal! i
- call assert_equal(13, g:IMactivatefunc_called)
- call assert_equal(26, g:IMstatusfunc_called)
+ call assert_equal(14, g:IMactivatefunc_called)
+ call assert_equal(28, g:IMstatusfunc_called)
END
call CheckLegacyAndVim9Success(lines)
@@ -283,12 +288,12 @@ func Test_imactivatefunc_imstatusfunc_callback()
call CheckScriptSuccess(lines)
" cleanup
+ set iminsert=0
+ set imactivatefunc&
+ set imstatusfunc&
delfunc IMactivatefunc1
delfunc IMstatusfunc1
- set iminsert=0
- set imactivatefunc=
- set imstatusfunc=
-
+ unlet g:IMactivatefunc_called g:IMstatusfunc_called
%bw!
endfunc
diff --git a/src/testdir/test_ins_complete.vim b/src/testdir/test_ins_complete.vim
index 1303a1354..d2e2c1100 100644
--- a/src/testdir/test_ins_complete.vim
+++ b/src/testdir/test_ins_complete.vim
@@ -870,123 +870,136 @@ endfunc
" Test for different ways of setting the 'completefunc' option
func Test_completefunc_callback()
- func MycompleteFunc1(val, findstart, base)
- call add(g:MycompleteFunc1_args, [a:val, a:findstart, a:base])
+ func CompleteFunc1(callnr, findstart, base)
+ call add(g:CompleteFunc1Args, [a:callnr, a:findstart, a:base])
+ return a:findstart ? 0 : []
+ endfunc
+ func CompleteFunc2(findstart, base)
+ call add(g:CompleteFunc2Args, [a:findstart, a:base])
return a:findstart ? 0 : []
endfunc
let lines =<< trim END
+ #" Test for using a function name
+ LET &completefunc = 'g:CompleteFunc2'
+ new
+ call setline(1, 'zero')
+ LET g:CompleteFunc2Args = []
+ call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
+ call assert_equal([[1, ''], [0, 'zero']], g:CompleteFunc2Args)
+ bw!
+
#" Test for using a function()
- set completefunc=function('g:MycompleteFunc1',\ [10])
- new | only
+ set completefunc=function('g:CompleteFunc1',\ [10])
+ new
call setline(1, 'one')
- LET g:MycompleteFunc1_args = []
+ LET g:CompleteFunc1Args = []
call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
- call assert_equal([[10, 1, ''], [10, 0, 'one']], g:MycompleteFunc1_args)
+ call assert_equal([[10, 1, ''], [10, 0, 'one']], g:CompleteFunc1Args)
bw!
#" Using a funcref variable to set 'completefunc'
- VAR Fn = function('g:MycompleteFunc1', [11])
+ VAR Fn = function('g:CompleteFunc1', [11])
LET &completefunc = Fn
- new | only
+ new
call setline(1, 'two')
- LET g:MycompleteFunc1_args = []
+ LET g:CompleteFunc1Args = []
call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
- call assert_equal([[11, 1, ''], [11, 0, 'two']], g:MycompleteFunc1_args)
+ call assert_equal([[11, 1, ''], [11, 0, 'two']], g:CompleteFunc1Args)
bw!
#" Using string(funcref_variable) to set 'completefunc'
- LET Fn = function('g:MycompleteFunc1', [12])
+ LET Fn = function('g:CompleteFunc1', [12])
LET &completefunc = string(Fn)
- new | only
+ new
call setline(1, 'two')
- LET g:MycompleteFunc1_args = []
+ LET g:CompleteFunc1Args = []
call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
- call assert_equal([[12, 1, ''], [12, 0, 'two']], g:MycompleteFunc1_args)
+ call assert_equal([[12, 1, ''], [12, 0, 'two']], g:CompleteFunc1Args)
bw!
#" Test for using a funcref()
- set completefunc=funcref('g:MycompleteFunc1',\ [13])
- new | only
+ set completefunc=funcref('g:CompleteFunc1',\ [13])
+ new
call setline(1, 'three')
- LET g:MycompleteFunc1_args = []
+ LET g:CompleteFunc1Args = []
call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
- call assert_equal([[13, 1, ''], [13, 0, 'three']], g:MycompleteFunc1_args)
+ call assert_equal([[13, 1, ''], [13, 0, 'three']], g:CompleteFunc1Args)
bw!
#" Using a funcref variable to set 'completefunc'
- LET Fn = funcref('g:MycompleteFunc1', [14])
+ LET Fn = funcref('g:CompleteFunc1', [14])
LET &completefunc = Fn
- new | only
+ new
call setline(1, 'four')
- LET g:MycompleteFunc1_args = []
+ LET g:CompleteFunc1Args = []
call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
- call assert_equal([[14, 1, ''], [14, 0, 'four']], g:MycompleteFunc1_args)
+ call assert_equal([[14, 1, ''], [14, 0, 'four']], g:CompleteFunc1Args)
bw!
#" Using a string(funcref_variable) to set 'completefunc'
- LET Fn = funcref('g:MycompleteFunc1', [15])
+ LET Fn = funcref('g:CompleteFunc1', [15])
LET &completefunc = string(Fn)
- new | only
+ new
call setline(1, 'four')
- LET g:MycompleteFunc1_args = []
+ LET g:CompleteFunc1Args = []
call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
- call assert_equal([[15, 1, ''], [15, 0, 'four']], g:MycompleteFunc1_args)
+ call assert_equal([[15, 1, ''], [15, 0, 'four']], g:CompleteFunc1Args)
bw!
#" Test for using a lambda function with set
- VAR optval = "LSTART a, b LMIDDLE MycompleteFunc1(16, a, b) LEND"
+ VAR optval = "LSTART a, b LMIDDLE CompleteFunc1(16, a, b) LEND"
LET optval = substitute(optval, ' ', '\\ ', 'g')
exe "set completefunc=" .. optval
- new | only
+ new
call setline(1, 'five')
- LET g:MycompleteFunc1_args = []
+ LET g:CompleteFunc1Args = []
call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
- call assert_equal([[16, 1, ''], [16, 0, 'five']], g:MycompleteFunc1_args)
+ call assert_equal([[16, 1, ''], [16, 0, 'five']], g:CompleteFunc1Args)
bw!
#" Set 'completefunc' to a lambda expression
- LET &completefunc = LSTART a, b LMIDDLE MycompleteFunc1(17, a, b) LEND
- new | only
+ LET &completefunc = LSTART a, b LMIDDLE CompleteFunc1(17, a, b) LEND
+ new
call setline(1, 'six')
- LET g:MycompleteFunc1_args = []
+ LET g:CompleteFunc1Args = []
call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
- call assert_equal([[17, 1, ''], [17, 0, 'six']], g:MycompleteFunc1_args)
+ call assert_equal([[17, 1, ''], [17, 0, 'six']], g:CompleteFunc1Args)
bw!
#" Set 'completefunc' to string(lambda_expression)
- LET &completefunc = 'LSTART a, b LMIDDLE MycompleteFunc1(18, a, b) LEND'
- new | only
+ LET &completefunc = 'LSTART a, b LMIDDLE CompleteFunc1(18, a, b) LEND'
+ new
call setline(1, 'six')
- LET g:MycompleteFunc1_args = []
+ LET g:CompleteFunc1Args = []
call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
- call assert_equal([[18, 1, ''], [18, 0, 'six']], g:MycompleteFunc1_args)
+ call assert_equal([[18, 1, ''], [18, 0, 'six']], g:CompleteFunc1Args)
bw!
#" Set 'completefunc' to a variable with a lambda expression
- VAR Lambda = LSTART a, b LMIDDLE MycompleteFunc1(19, a, b) LEND
+ VAR Lambda = LSTART a, b LMIDDLE CompleteFunc1(19, a, b) LEND
LET &completefunc = Lambda
- new | only
+ new
call setline(1, 'seven')
- LET g:MycompleteFunc1_args = []
+ LET g:CompleteFunc1Args = []
call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
- call assert_equal([[19, 1, ''], [19, 0, 'seven']], g:MycompleteFunc1_args)
+ call assert_equal([[19, 1, ''], [19, 0, 'seven']], g:CompleteFunc1Args)
bw!
#" Set 'completefunc' to a string(variable with a lambda expression)
- LET Lambda = LSTART a, b LMIDDLE MycompleteFunc1(20, a, b) LEND
+ LET Lambda = LSTART a, b LMIDDLE CompleteFunc1(20, a, b) LEND
LET &completefunc = string(Lambda)
- new | only
+ new
call setline(1, 'seven')
- LET g:MycompleteFunc1_args = []
+ LET g:CompleteFunc1Args = []
call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
- call assert_equal([[20, 1, ''], [20, 0, 'seven']], g:MycompleteFunc1_args)
+ call assert_equal([[20, 1, ''], [20, 0, 'seven']], g:CompleteFunc1Args)
bw!
#" Test for using a lambda function with incorrect return value
LET Lambda = LSTART a, b LMIDDLE strlen(a) LEND
LET &completefunc = Lambda
- new | only
+ new
call setline(1, 'eight')
call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
bw!
@@ -998,17 +1011,13 @@ func Test_completefunc_callback()
call assert_fails("set completefunc=funcref('abc')", "E700:")
#" set 'completefunc' to a non-existing function
- func MycompleteFunc2(findstart, base)
- call add(g:MycompleteFunc2_args, [a:findstart, a:base])
- return a:findstart ? 0 : []
- endfunc
- set completefunc=MycompleteFunc2
+ set completefunc=CompleteFunc2
call setline(1, 'five')
call assert_fails("set completefunc=function('NonExistingFunc')", 'E700:')
call assert_fails("LET &completefunc = function('NonExistingFunc')", 'E700:')
- LET g:MycompleteFunc2_args = []
+ LET g:CompleteFunc2Args = []
call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
- call assert_equal([[1, ''], [0, 'five']], g:MycompleteFunc2_args)
+ call assert_equal([[1, ''], [0, 'five']], g:CompleteFunc2Args)
bw!
END
call CheckLegacyAndVim9Success(lines)
@@ -1017,11 +1026,11 @@ func Test_completefunc_callback()
call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
" Using Vim9 lambda expression in legacy context should fail
- set completefunc=(a,\ b)\ =>\ MycompleteFunc1(21,\ a,\ b)
+ set completefunc=(a,\ b)\ =>\ CompleteFunc1(21,\ a,\ b)
new | only
- let g:MycompleteFunc1_args = []
+ let g:CompleteFunc1Args = []
call assert_fails('call feedkeys("A\<C-X>\<C-U>\<Esc>", "x")', 'E117:')
- call assert_equal([], g:MycompleteFunc1_args)
+ call assert_equal([], g:CompleteFunc1Args)
" set 'completefunc' to a partial with dict. This used to cause a crash.
func SetCompleteFunc()
@@ -1063,131 +1072,145 @@ func Test_completefunc_callback()
call CheckScriptSuccess(lines)
" cleanup
- delfunc MycompleteFunc1
- delfunc MycompleteFunc2
set completefunc&
+ delfunc CompleteFunc1
+ delfunc CompleteFunc2
+ unlet g:CompleteFunc1Args g:CompleteFunc2Args
%bw!
endfunc
" Test for different ways of setting the 'omnifunc' option
func Test_omnifunc_callback()
- func MyomniFunc1(val, findstart, base)
- call add(g:MyomniFunc1_args, [a:val, a:findstart, a:base])
+ func OmniFunc1(callnr, findstart, base)
+ call add(g:OmniFunc1Args, [a:callnr, a:findstart, a:base])
+ return a:findstart ? 0 : []
+ endfunc
+ func OmniFunc2(findstart, base)
+ call add(g:OmniFunc2Args, [a:findstart, a:base])
return a:findstart ? 0 : []
endfunc
let lines =<< trim END
+ #" Test for using a function name
+ LET &omnifunc = 'g:OmniFunc2'
+ new
+ call setline(1, 'zero')
+ LET g:OmniFunc2Args = []
+ call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
+ call assert_equal([[1, ''], [0, 'zero']], g:OmniFunc2Args)
+ bw!
+
#" Test for using a function()
- set omnifunc=function('g:MyomniFunc1',\ [10])
- new | only
+ set omnifunc=function('g:OmniFunc1',\ [10])
+ new
call setline(1, 'one')
- LET g:MyomniFunc1_args = []
+ LET g:OmniFunc1Args = []
call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
- call assert_equal([[10, 1, ''], [10, 0, 'one']], g:MyomniFunc1_args)
+ call assert_equal([[10, 1, ''], [10, 0, 'one']], g:OmniFunc1Args)
bw!
#" Using a funcref variable to set 'omnifunc'
- VAR Fn = function('g:MyomniFunc1', [11])
+ VAR Fn = function('g:OmniFunc1', [11])
LET &omnifunc = Fn
- new | only
+ new
call setline(1, 'two')
- LET g:MyomniFunc1_args = []
+ LET g:OmniFunc1Args = []
call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
- call assert_equal([[11, 1, ''], [11, 0, 'two']], g:MyomniFunc1_args)
+ call assert_equal([[11, 1, ''], [11, 0, 'two']], g:OmniFunc1Args)
bw!
#" Using a string(funcref_variable) to set 'omnifunc'
- LET Fn = function('g:MyomniFunc1', [12])
+ LET Fn = function('g:OmniFunc1', [12])
LET &omnifunc = string(Fn)
- new | only
+ new
call setline(1, 'two')
- LET g:MyomniFunc1_args = []
+ LET g:OmniFunc1Args = []
call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
- call assert_equal([[12, 1, ''], [12, 0, 'two']], g:MyomniFunc1_args)
+ call assert_equal([[12, 1, ''], [12, 0, 'two']], g:OmniFunc1Args)
bw!
#" Test for using a funcref()
- set omnifunc=funcref('g:MyomniFunc1',\ [13])
- new | only
+ set omnifunc=funcref('g:OmniFunc1',\ [13])
+ new
call setline(1, 'three')
- LET g:MyomniFunc1_args = []
+ LET g:OmniFunc1Args = []
call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
- call assert_equal([[13, 1, ''], [13, 0, 'three']], g:MyomniFunc1_args)
+ call assert_equal([[13, 1, ''], [13, 0, 'three']], g:OmniFunc1Args)
bw!
#" Use let to set 'omnifunc' to a funcref
- LET Fn = funcref('g:MyomniFunc1', [14])
+ LET Fn = funcref('g:OmniFunc1', [14])
LET &omnifunc = Fn
- new | only
+ new
call setline(1, 'four')
- LET g:MyomniFunc1_args = []
+ LET g:OmniFunc1Args = []
call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
- call assert_equal([[14, 1, ''], [14, 0, 'four']], g:MyomniFunc1_args)
+ call assert_equal([[14, 1, ''], [14, 0, 'four']], g:OmniFunc1Args)
bw!
#" Using a string(funcref) to set 'omnifunc'
- LET Fn = funcref("g:MyomniFunc1", [15])
+ LET Fn = funcref("g:OmniFunc1", [15])
LET &omnifunc = string(Fn)
- new | only
+ new
call setline(1, 'four')
- LET g:MyomniFunc1_args = []
+ LET g:OmniFunc1Args = []
call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
- call assert_equal([[15, 1, ''], [15, 0, 'four']], g:MyomniFunc1_args)
+ call assert_equal([[15, 1, ''], [15, 0, 'four']], g:OmniFunc1Args)
bw!
#" Test for using a lambda function with set
- VAR optval = "LSTART a, b LMIDDLE MyomniFunc1(16, a, b) LEND"
+ VAR optval = "LSTART a, b LMIDDLE OmniFunc1(16, a, b) LEND"
LET optval = substitute(optval, ' ', '\\ ', 'g')
exe "set omnifunc=" .. optval
- new | only
+ new
call setline(1, 'five')
- LET g:MyomniFunc1_args = []
+ LET g:OmniFunc1Args = []
call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
- call assert_equal([[16, 1, ''], [16, 0, 'five']], g:MyomniFunc1_args)
+ call assert_equal([[16, 1, ''], [16, 0, 'five']], g:OmniFunc1Args)
bw!
#" Set 'omnifunc' to a lambda expression
- LET &omnifunc = LSTART a, b LMIDDLE MyomniFunc1(17, a, b) LEND
- new | only
+ LET &omnifunc = LSTART a, b LMIDDLE OmniFunc1(17, a, b) LEND
+ new
call setline(1, 'six')
- LET g:MyomniFunc1_args = []
+ LET g:OmniFunc1Args = []
call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
- call assert_equal([[17, 1, ''], [17, 0, 'six']], g:MyomniFunc1_args)
+ call assert_equal([[17, 1, ''], [17, 0, 'six']], g:OmniFunc1Args)
bw!
#" Set 'omnifunc' to a string(lambda_expression)
- LET &omnifunc = 'LSTART a, b LMIDDLE MyomniFunc1(18, a, b) LEND'
- new | only
+ LET &omnifunc = 'LSTART a, b LMIDDLE OmniFunc1(18, a, b) LEND'
+ new
call setline(1, 'six')
- LET g:MyomniFunc1_args = []
+ LET g:OmniFunc1Args = []
call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
- call assert_equal([[18, 1, ''], [18, 0, 'six']], g:MyomniFunc1_args)
+ call assert_equal([[18, 1, ''], [18, 0, 'six']], g:OmniFunc1Args)
bw!
#" Set 'omnifunc' to a variable with a lambda expression
- VAR Lambda = LSTART a, b LMIDDLE MyomniFunc1(19, a, b) LEND
+ VAR Lambda = LSTART a, b LMIDDLE OmniFunc1(19, a, b) LEND
LET &omnifunc = Lambda
- new | only
+ new
call setline(1, 'seven')
- LET g:MyomniFunc1_args = []
+ LET g:OmniFunc1Args = []
call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
- call assert_equal([[19, 1, ''], [19, 0, 'seven']], g:MyomniFunc1_args)
+ call assert_equal([[19, 1, ''], [19, 0, 'seven']], g:OmniFunc1Args)
bw!
#" Set 'omnifunc' to a string(variable with a lambda expression)
- LET Lambda = LSTART a, b LMIDDLE MyomniFunc1(20, a, b) LEND
+ LET Lambda = LSTART a, b LMIDDLE OmniFunc1(20, a, b) LEND
LET &omnifunc = string(Lambda)
- new | only
+ new
call setline(1, 'seven')
- LET g:MyomniFunc1_args = []
+ LET g:OmniFunc1Args = []
call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
- call assert_equal([[20, 1, ''], [20, 0, 'seven']], g:MyomniFunc1_args)
+ call assert_equal([[20, 1, ''], [20, 0, 'seven']], g:OmniFunc1Args)
bw!
#" Test for using a lambda function with incorrect return value
LET Lambda = LSTART a, b LMIDDLE strlen(a) LEND
LET &omnifunc = Lambda
- new | only
+ new
call setline(1, 'eight')
call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
bw!
@@ -1199,17 +1222,13 @@ func Test_omnifunc_callback()
call assert_fails("set omnifunc=funcref('abc')", "E700:")
#" set 'omnifunc' to a non-existing function
- func MyomniFunc2(findstart, base)
- call add(g:MyomniFunc2_args, [a:findstart, a:base])
- return a:findstart ? 0 : []
- endfunc
- set omnifunc=MyomniFunc2
+ set omnifunc=OmniFunc2
call setline(1, 'nine')
call assert_fails("set omnifunc=function('NonExistingFunc')", 'E700:')
call assert_fails("LET &omnifunc = function('NonExistingFunc')", 'E700:')
- LET g:MyomniFunc2_args = []
+ LET g:OmniFunc2Args = []
call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
- call assert_equal([[1, ''], [0, 'nine']], g:MyomniFunc2_args)
+ call assert_equal([[1, ''], [0, 'nine']], g:OmniFunc2Args)
bw!
END
call CheckLegacyAndVim9Success(lines)
@@ -1218,11 +1237,11 @@ func Test_omnifunc_callback()
call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
" Using Vim9 lambda expression in legacy context should fail
- set omnifunc=(a,\ b)\ =>\ MyomniFunc1(21,\ a,\ b)
+ set omnifunc=(a,\ b)\ =>\ OmniFunc1(21,\ a,\ b)
new | only
- let g:MyomniFunc1_args = []
+ let g:OmniFunc1Args = []
call assert_fails('call feedkeys("A\<C-X>\<C-O>\<Esc>", "x")', 'E117:')
- call assert_equal([], g:MyomniFunc1_args)
+ call assert_equal([], g:OmniFunc1Args)
" set 'omnifunc' to a partial with dict. This used to cause a crash.
func SetOmniFunc()
@@ -1264,131 +1283,145 @@ func Test_omnifunc_callback()
call CheckScriptSuccess(lines)
" cleanup
- delfunc MyomniFunc1
- delfunc MyomniFunc2
set omnifunc&
+ delfunc OmniFunc1
+ delfunc OmniFunc2
+ unlet g:OmniFunc1Args g:OmniFunc2Args
%bw!
endfunc
" Test for different ways of setting the 'thesaurusfunc' option
func Test_thesaurusfunc_callback()
- func MytsrFunc1(val, findstart, base)
- call add(g:MytsrFunc1_args, [a:val, a:findstart, a:base])
+ func TsrFunc1(callnr, findstart, base)
+ call add(g:TsrFunc1Args, [a:callnr, a:findstart, a:base])
return a:findstart ? 0 : []
endfunc
+ func TsrFunc2(findstart, base)
+ call add(g:TsrFunc2Args, [a:findstart, a:base])
+ return a:findstart ? 0 : ['sunday']
+ endfunc
let lines =<< trim END
+ #" Test for using a function name
+ LET &thesaurusfunc = 'g:TsrFunc2'
+ new
+ call setline(1, 'zero')
+ LET g:TsrFunc2Args = []
+ call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
+ call assert_equal([[1, ''], [0, 'zero']], g:TsrFunc2Args)
+ bw!
+
#" Test for using a function()
- set thesaurusfunc=function('g:MytsrFunc1',\ [10])
- new | only
+ set thesaurusfunc=function('g:TsrFunc1',\ [10])
+ new
call setline(1, 'one')
- LET g:MytsrFunc1_args = []
+ LET g:TsrFunc1Args = []
call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
- call assert_equal([[10, 1, ''], [10, 0, 'one']], g:MytsrFunc1_args)
+ call assert_equal([[10, 1, ''], [10, 0, 'one']], g:TsrFunc1Args)
bw!
#" Using a funcref variable to set 'thesaurusfunc'
- VAR Fn = function('g:MytsrFunc1', [11])
+ VAR Fn = function('g:TsrFunc1', [11])
LET &thesaurusfunc = Fn
- new | only
+ new
call setline(1, 'two')
- LET g:MytsrFunc1_args = []
+ LET g:TsrFunc1Args = []
call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
- call assert_equal([[11, 1, ''], [11, 0, 'two']], g:MytsrFunc1_args)
+ call assert_equal([[11, 1, ''], [11, 0, 'two']], g:TsrFunc1Args)
bw!
#" Using a string(funcref_variable) to set 'thesaurusfunc'
- LET Fn = function('g:MytsrFunc1', [12])
+ LET Fn = function('g:TsrFunc1', [12])
LET &thesaurusfunc = string(Fn)
- new | only
+ new
call setline(1, 'two')
- LET g:MytsrFunc1_args = []
+ LET g:TsrFunc1Args = []
call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
- call assert_equal([[12, 1, ''], [12, 0, 'two']], g:MytsrFunc1_args)
+ call assert_equal([[12, 1, ''], [12, 0, 'two']], g:TsrFunc1Args)
bw!
#" Test for using a funcref()
- set thesaurusfunc=funcref('g:MytsrFunc1',\ [13])
- new | only
+ set thesaurusfunc=funcref('g:TsrFunc1',\ [13])
+ new
call setline(1, 'three')
- LET g:MytsrFunc1_args = []
+ LET g:TsrFunc1Args = []
call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
- call assert_equal([[13, 1, ''], [13, 0, 'three']], g:MytsrFunc1_args)
+ call assert_equal([[13, 1, ''], [13, 0, 'three']], g:TsrFunc1Args)
bw!
#" Using a funcref variable to set 'thesaurusfunc'
- LET Fn = funcref('g:MytsrFunc1', [14])
+ LET Fn = funcref('g:TsrFunc1', [14])
LET &thesaurusfunc = Fn
- new | only
+ new
call setline(1, 'four')
- LET g:MytsrFunc1_args = []
+ LET g:TsrFunc1Args = []
call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
- call assert_equal([[14, 1, ''], [14, 0, 'four']], g:MytsrFunc1_args)
+ call assert_equal([[14, 1, ''], [14, 0, 'four']], g:TsrFunc1Args)
bw!
#" Using a string(funcref_variable) to set 'thesaurusfunc'
- LET Fn = funcref('g:MytsrFunc1', [15])
+ LET Fn = funcref('g:TsrFunc1', [15])
LET &thesaurusfunc = string(Fn)
- new | only
+ new
call setline(1, 'four')
- LET g:MytsrFunc1_args = []
+ LET g:TsrFunc1Args = []
call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
- call assert_equal([[15, 1, ''], [15, 0, 'four']], g:MytsrFunc1_args)
+ call assert_equal([[15, 1, ''], [15, 0, 'four']], g:TsrFunc1Args)
bw!
#" Test for using a lambda function
- VAR optval = "LSTART a, b LMIDDLE MytsrFunc1(16, a, b) LEND"
+ VAR optval = "LSTART a, b LMIDDLE TsrFunc1(16, a, b) LEND"
LET optval = substitute(optval, ' ', '\\ ', 'g')
exe "set thesaurusfunc=" .. optval
- new | only
+ new
call setline(1, 'five')
- LET g:MytsrFunc1_args = []
+ LET g:TsrFunc1Args = []
call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
- call assert_equal([[16, 1, ''], [16, 0, 'five']], g:MytsrFunc1_args)
+ call assert_equal([[16, 1, ''], [16, 0, 'five']], g:TsrFunc1Args)
bw!
#" Test for using a lambda function with set
- LET &thesaurusfunc = LSTART a, b LMIDDLE MytsrFunc1(17, a, b) LEND
- new | only
+ LET &thesaurusfunc = LSTART a, b LMIDDLE TsrFunc1(17, a, b) LEND
+ new
call setline(1, 'six')
- LET g:MytsrFunc1_args = []
+ LET g:TsrFunc1Args = []
call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
- call assert_equal([[17, 1, ''], [17, 0, 'six']], g:MytsrFunc1_args)
+ call assert_equal([[17, 1, ''], [17, 0, 'six']], g:TsrFunc1Args)
bw!
#" Set 'thesaurusfunc' to a string(lambda expression)
- LET &thesaurusfunc = 'LSTART a, b LMIDDLE MytsrFunc1(18, a, b) LEND'
- new | only
+ LET &thesaurusfunc = 'LSTART a, b LMIDDLE TsrFunc1(18, a, b) LEND'
+ new
call setline(1, 'six')
- LET g:MytsrFunc1_args = []
+ LET g:TsrFunc1Args = []
call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
- call assert_equal([[18, 1, ''], [18, 0, 'six']], g:MytsrFunc1_args)
+ call assert_equal([[18, 1, ''], [18, 0, 'six']], g:TsrFunc1Args)
bw!
#" Set 'thesaurusfunc' to a variable with a lambda expression
- VAR Lambda = LSTART a, b LMIDDLE MytsrFunc1(19, a, b) LEND
+ VAR Lambda = LSTART a, b LMIDDLE TsrFunc1(19, a, b) LEND
LET &thesaurusfunc = Lambda
- new | only
+ new
call setline(1, 'seven')
- LET g:MytsrFunc1_args = []
+ LET g:TsrFunc1Args = []
call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
- call assert_equal([[19, 1, ''], [19, 0, 'seven']], g:MytsrFunc1_args)
+ call assert_equal([[19, 1, ''], [19, 0, 'seven']], g:TsrFunc1Args)
bw!
#" Set 'thesaurusfunc' to a string(variable with a lambda expression)
- LET Lambda = LSTART a, b LMIDDLE MytsrFunc1(20, a, b) LEND
+ LET Lambda = LSTART a, b LMIDDLE TsrFunc1(20, a, b) LEND
LET &thesaurusfunc = string(Lambda)
- new | only
+ new
call setline(1, 'seven')
- LET g:MytsrFunc1_args = []
+ LET g:TsrFunc1Args = []
call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
- call assert_equal([[20, 1, ''], [20, 0, 'seven']], g:MytsrFunc1_args)
+ call assert_equal([[20, 1, ''], [20, 0, 'seven']], g:TsrFunc1Args)
bw!
#" Test for using a lambda function with incorrect return value
LET Lambda = LSTART a, b LMIDDLE strlen(a) LEND
LET &thesaurusfunc = Lambda
- new | only
+ new
call setline(1, 'eight')
call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
bw!
@@ -1400,40 +1433,36 @@ func Test_thesaurusfunc_callback()
call assert_fails("set thesaurusfunc=funcref('abc')", "E700:")
#" set 'thesaurusfunc' to a non-existing function
- func MytsrFunc2(findstart, base)
- call add(g:MytsrFunc2_args, [a:findstart, a:base])
- return a:findstart ? 0 : ['sunday']
- endfunc
- set thesaurusfunc=MytsrFunc2
+ set thesaurusfunc=TsrFunc2
call setline(1, 'ten')
call assert_fails("set thesaurusfunc=function('NonExistingFunc')", 'E700:')
call assert_fails("LET &thesaurusfunc = function('NonExistingFunc')", 'E700:')
- LET g:MytsrFunc2_args = []
+ LET g:TsrFunc2Args = []
call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
- call assert_equal([[1, ''], [0, 'ten']], g:MytsrFunc2_args)
+ call assert_equal([[1, ''], [0, 'ten']], g:TsrFunc2Args)
bw!
#" Use a buffer-local value and a global value
set thesaurusfunc&
- setlocal thesaurusfunc=function('g:MytsrFunc1',\ [22])
+ setlocal thesaurusfunc=function('g:TsrFunc1',\ [22])
call setline(1, 'sun')
- LET g:MytsrFunc1_args = []
+ LET g:TsrFunc1Args = []
call feedkeys("A\<C-X>\<C-T>\<Esc>", "x")
call assert_equal('sun', getline(1))
- call assert_equal([[22, 1, ''], [22, 0, 'sun']], g:MytsrFunc1_args)
+ call assert_equal([[22, 1, ''], [22, 0, 'sun']], g:TsrFunc1Args)
new
call setline(1, 'sun')
- LET g:MytsrFunc1_args = []
+ LET g:TsrFunc1Args = []
call feedkeys("A\<C-X>\<C-T>\<Esc>", "x")
call assert_equal('sun', getline(1))
- call assert_equal([], g:MytsrFunc1_args)
- set thesaurusfunc=function('g:MytsrFunc1',\ [23])
+ call assert_equal([], g:TsrFunc1Args)
+ set thesaurusfunc=function('g:TsrFunc1',\ [23])
wincmd w
call setline(1, 'sun')
- LET g:MytsrFunc1_args = []
+ LET g:TsrFunc1Args = []
call feedkeys("A\<C-X>\<C-T>\<Esc>", "x")
call assert_equal('sun', getline(1))
- call assert_equal([[22, 1, ''], [22, 0, 'sun']], g:MytsrFunc1_args)
+ call assert_equal([[22, 1, ''], [22, 0, 'sun']], g:TsrFunc1Args)
:%bw!
END
call CheckLegacyAndVim9Success(lines)
@@ -1442,11 +1471,11 @@ func Test_thesaurusfunc_callback()
call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
" Using Vim9 lambda expression in legacy context should fail
- set thesaurusfunc=(a,\ b)\ =>\ MytsrFunc1(21,\ a,\ b)
+ set thesaurusfunc=(a,\ b)\ =>\ TsrFunc1(21,\ a,\ b)
new | only
- let g:MytsrFunc1_args = []
+ let g:TsrFunc1Args = []
call assert_fails('call feedkeys("A\<C-X>\<C-T>\<Esc>", "x")', 'E117:')
- call assert_equal([], g:MytsrFunc1_args)
+ call assert_equal([], g:TsrFunc1Args)
bw!
" set 'thesaurusfunc' to a partial with dict. This used to cause a crash.
@@ -1502,8 +1531,9 @@ func Test_thesaurusfunc_callback()
" cleanup
set thesaurusfunc&
- delfunc MytsrFunc1
- delfunc MytsrFunc2
+ delfunc TsrFunc1
+ delfunc TsrFunc2
+ unlet g:TsrFunc1Args g:TsrFunc2Args
%bw!
endfunc
diff --git a/src/testdir/test_normal.vim b/src/testdir/test_normal.vim
index 8383dde39..e6c392df0 100644
--- a/src/testdir/test_normal.vim
+++ b/src/testdir/test_normal.vim
@@ -444,110 +444,120 @@ endfunc
" Test for different ways of setting the 'operatorfunc' option
func Test_opfunc_callback()
new
- func MyopFunc(val, type)
- let g:OpFuncArgs = [a:val, a:type]
+ func OpFunc1(callnr, type)
+ let g:OpFunc1Args = [a:callnr, a:type]
+ endfunc
+ func OpFunc2(type)
+ let g:OpFunc2Args = [a:type]
endfunc
let lines =<< trim END
+ #" Test for using a function name
+ LET &opfunc = 'g:OpFunc2'
+ LET g:OpFunc2Args = []
+ normal! g@l
+ call assert_equal(['char'], g:OpFunc2Args)
+
#" Test for using a function()
- set opfunc=function('g:MyopFunc',\ [10])
- LET g:OpFuncArgs = []
+ set opfunc=function('g:OpFunc1',\ [10])
+ LET g:OpFunc1Args = []
normal! g@l
- call assert_equal([10, 'char'], g:OpFuncArgs)
+ call assert_equal([10, 'char'], g:OpFunc1Args)
#" Using a funcref variable to set 'operatorfunc'
- VAR Fn = function('g:MyopFunc', [11])
+ VAR Fn = function('g:OpFunc1', [11])
LET &opfunc = Fn
- LET g:OpFuncArgs = []
+ LET g:OpFunc1Args = []
normal! g@l
- call assert_equal([11, 'char'], g:OpFuncArgs)
+ call assert_equal([11, 'char'], g:OpFunc1Args)
#" Using a string(funcref_variable) to set 'operatorfunc'
- LET Fn = function('g:MyopFunc', [12])
+ LET Fn = function('g:OpFunc1', [12])
LET &operatorfunc = string(Fn)
- LET g:OpFuncArgs = []
+ LET g:OpFunc1Args = []
normal! g@l
- call assert_equal([12, 'char'], g:OpFuncArgs)
+ call assert_equal([12, 'char'], g:OpFunc1Args)
#" Test for using a funcref()
- set operatorfunc=funcref('g:MyopFunc',\ [13])
- LET g:OpFuncArgs = []
+ set operatorfunc=funcref('g:OpFunc1',\ [13])
+ LET g:OpFunc1Args = []
normal! g@l
- call assert_equal([13, 'char'], g:OpFuncArgs)
+ call assert_equal([13, 'char'], g:OpFunc1Args)
#" Using a funcref variable to set 'operatorfunc'
- LET Fn = funcref('g:MyopFunc', [14])
+ LET Fn = funcref('g:OpFunc1', [14])
LET &opfunc = Fn
- LET g:OpFuncArgs = []
+ LET g:OpFunc1Args = []
normal! g@l
- call assert_equal([14, 'char'], g:OpFuncArgs)
+ call assert_equal([14, 'char'], g:OpFunc1Args)
#" Using a string(funcref_variable) to set 'operatorfunc'
- LET Fn = funcref('g:MyopFunc', [15])
+ LET Fn = funcref('g:OpFunc1', [15])
LET &opfunc = string(Fn)
- LET g:OpFuncArgs = []
+ LET g:OpFunc1Args = []
normal! g@l
- call assert_equal([15, 'char'], g:OpFuncArgs)
+ call assert_equal([15, 'char'], g:OpFunc1Args)
#" Test for using a lambda function using set
- VAR optval = "LSTART a LMIDDLE MyopFunc(16, a) LEND"
+ VAR optval = "LSTART a LMIDDLE OpFunc1(16, a) LEND"
LET optval = substitute(optval, ' ', '\\ ', 'g')
exe "set opfunc=" .. optval
- LET g:OpFuncArgs = []
+ LET g:OpFunc1Args = []
normal! g@l
- call assert_equal([16, 'char'], g:OpFuncArgs)
+ call assert_equal([16, 'char'], g:OpFunc1Args)
#" Test for using a lambda function using LET
- LET &opfunc = LSTART a LMIDDLE MyopFunc(17, a) LEND
- LET g:OpFuncArgs = []
+ LET &opfunc = LSTART a LMIDDLE OpFunc1(17, a) LEND
+ LET g:OpFunc1Args = []
normal! g@l
- call assert_equal([17, 'char'], g:OpFuncArgs)
+ call assert_equal([17, 'char'], g:OpFunc1Args)
#" Set 'operatorfunc' to a string(lambda expression)
- LET &opfunc = 'LSTART a LMIDDLE MyopFunc(18, a) LEND'
- LET g:OpFuncArgs = []
+ LET &opfunc = 'LSTART a LMIDDLE OpFunc1(18, a) LEND'
+ LET g:OpFunc1Args = []
normal! g@l
- call assert_equal([18, 'char'], g:OpFuncArgs)
+ call assert_equal([18, 'char'], g:OpFunc1Args)
#" Set 'operatorfunc' to a variable with a lambda expression
- VAR Lambda = LSTART a LMIDDLE MyopFunc(19, a) LEND
+ VAR Lambda = LSTART a LMIDDLE OpFunc1(19, a) LEND
LET &opfunc = Lambda
- LET g:OpFuncArgs = []
+ LET g:OpFunc1Args = []
normal! g@l
- call assert_equal([19, 'char'], g:OpFuncArgs)
+ call assert_equal([19, 'char'], g:OpFunc1Args)
#" Set 'operatorfunc' to a string(variable with a lambda expression)
- LET Lambda = LSTART a LMIDDLE MyopFunc(20, a) LEND
+ LET Lambda = LSTART a LMIDDLE OpFunc1(20, a) LEND
LET &opfunc = string(Lambda)
- LET g:OpFuncArgs = []
+ LET g:OpFunc1Args = []
normal! g@l
- call assert_equal([20, 'char'], g:OpFuncArgs)
+ call assert_equal([20, 'char'], g:OpFunc1Args)
#" Try to use 'operatorfunc' after the function is deleted
- func g:TmpOpFunc(type)
- LET g:OpFuncArgs = [21, a:type]
+ func g:TmpOpFunc1(type)
+ let g:TmpOpFunc1Args = [21, a:type]
endfunc
- LET &opfunc = function('g:TmpOpFunc')
- delfunc g:TmpOpFunc
+ LET &opfunc = function('g:TmpOpFunc1')
+ delfunc g:TmpOpFunc1
call test_garbagecollect_now()
- LET g:OpFuncArgs = []
+ LET g:TmpOpFunc1Args = []
call assert_fails('normal! g@l', 'E117:')
- call assert_equal([], g:OpFuncArgs)
+ call assert_equal([], g:TmpOpFunc1Args)
#" Try to use a function with two arguments for 'operatorfunc'
- func MyopFunc2(x, y)
- LET g:OpFuncArgs = [a:x, a:y]
+ func g:TmpOpFunc2(x, y)
+ let g:TmpOpFunc2Args = [a:x, a:y]
endfunc
- set opfunc=MyopFunc2
- LET g:OpFuncArgs = []
+ set opfunc=TmpOpFunc2
+ LET g:TmpOpFunc2Args = []
call assert_fails('normal! g@l', 'E119:')
- call assert_equal([], g:OpFuncArgs)
+ call assert_equal([], g:TmpOpFunc2Args)
+ delfunc TmpOpFunc2
#" Try to use a lambda function with two arguments for 'operatorfunc'
- LET &opfunc = LSTART a, b LMIDDLE MyopFunc(22, b) LEND
- LET g:OpFuncArgs = []
+ LET &opfunc = LSTART a, b LMIDDLE OpFunc1(22, b) LEND
+ LET g:OpFunc1Args = []
call assert_fails('normal! g@l', 'E119:')
- call assert_equal([], g:OpFuncArgs)
+ call assert_equal([], g:OpFunc1Args)
#" Test for clearing the 'operatorfunc' option
set opfunc=''
@@ -556,20 +566,20 @@ func Test_opfunc_callback()
call assert_fails("set opfunc=funcref('abc')", "E700:")
#" set 'operatorfunc' to a non-existing function
- LET &opfunc = function('g:MyopFunc', [23])
+ LET &opfunc = function('g:OpFunc1', [23])
call assert_fails("set opfunc=function('NonExistingFunc')", 'E700:')
call assert_fails("LET &opfunc = function('NonExistingFunc')", 'E700:')
- LET g:OpFuncArgs = []
+ LET g:OpFunc1Args = []
normal! g@l
- call assert_equal([23, 'char'], g:OpFuncArgs)
+ call assert_equal([23, 'char'], g:OpFunc1Args)
END
call CheckTransLegacySuccess(lines)
" Using Vim9 lambda expression in legacy context should fail
- set opfunc=(a)\ =>\ MyopFunc(24,\ a)
- let g:OpFuncArgs = []
+ set opfunc=(a)\ =>\ OpFunc1(24,\ a)
+ let g:OpFunc1Args = []
call assert_fails('normal! g@l', 'E117:')
- call assert_equal([], g:OpFuncArgs)
+ call assert_equal([], g:OpFunc1Args)
" set 'operatorfunc' to a partial with dict. This used to cause a crash.
func SetOpFunc()
@@ -590,20 +600,20 @@ func Test_opfunc_callback()
# Test for using a def function with opfunc
def g:Vim9opFunc(val: number, type: string): void
- g:OpFuncArgs = [val, type]
+ g:OpFunc1Args = [val, type]
enddef
set opfunc=function('g:Vim9opFunc',\ [60])
- g:OpFuncArgs = []
+ g:OpFunc1Args = []
normal! g@l
- assert_equal([60, 'char'], g:OpFuncArgs)
+ assert_equal([60, 'char'], g:OpFunc1Args)
END
call CheckScriptSuccess(lines)
" cleanup
set opfunc&
- delfunc MyopFunc
- delfunc MyopFunc2
- unlet g:OpFuncArgs
+ delfunc OpFunc1
+ delfunc OpFunc2
+ unlet g:OpFunc1Args g:OpFunc2Args
%bw!
endfunc
diff --git a/src/testdir/test_quickfix.vim b/src/testdir/test_quickfix.vim
index c8e04d8ef..283e94379 100644
--- a/src/testdir/test_quickfix.vim
+++ b/src/testdir/test_quickfix.vim
@@ -5287,6 +5287,13 @@ func Test_qftextfunc_callback()
let lines =<< trim END
set efm=%f:%l:%c:%m
+ #" Test for using a function name
+ LET &qftf = 'g:Tqfexpr'
+ cexpr "F0:0:0:L0"
+ copen
+ call assert_equal('F0-L0C0-L0', getline(1))
+ cclose
+
#" Test for using a function()
set qftf=function('g:Tqfexpr')
cexpr "F1:1:1:L1"
diff --git a/src/testdir/test_tagfunc.vim b/src/testdir/test_tagfunc.vim
index 7248797ce..cdadbac5c 100644
--- a/src/testdir/test_tagfunc.vim
+++ b/src/testdir/test_tagfunc.vim
@@ -127,102 +127,126 @@ endfunc
" Test for different ways of setting the 'tagfunc' option
func Test_tagfunc_callback()
- func MytagFunc1(val, pat, flags, info)
- let g:MytagFunc1_args = [a:val, a:pat, a:flags, a:info]
+ func TagFunc1(callnr, pat, flags, info)
+ let g:TagFunc1Args = [a:callnr, a:pat, a:flags, a:info]
+ return v:null
+ endfunc
+ func TagFunc2(pat, flags, info)
+ let g:TagFunc2Args = [a:pat, a:flags, a:info]
return v:null
endfunc
let lines =<< trim END
+ #" Test for using a function name
+ LET &tagfunc = 'g:TagFunc2'
+ new
+ LET g:TagFunc2Args = []
+ call assert_fails('tag a10', 'E433:')
+ call assert_equal(['a10', '', {}], g:TagFunc2Args)
+ bw!
+
#" Test for using a function()
- set tagfunc=function('g:MytagFunc1',\ [10])
- new | only
- LET g:MytagFunc1_args = []
+ set tagfunc=function('g:TagFunc1',\ [10])
+ new
+ LET g:TagFunc1Args = []
call assert_fails('tag a11', 'E433:')
- call assert_equal([10, 'a11', '', {}], g:MytagFunc1_args)
+ call assert_equal([10, 'a11', '', {}], g:TagFunc1Args)
+ bw!
#" Using a funcref variable to set 'tagfunc'
- VAR Fn = function('g:MytagFunc1', [11])
+ VAR Fn = function('g:TagFunc1', [11])
LET &tagfunc = Fn
- new | only
- LET g:MytagFunc1_args = []
+ new
+ LET g:TagFunc1Args = []
call assert_fails('tag a12', 'E433:')
- call assert_equal([11, 'a12', '', {}], g:MytagFunc1_args)
+ call assert_equal([11, 'a12', '', {}], g:TagFunc1Args)
+ bw!
#" Using a string(funcref_variable) to set 'tagfunc'
- LET Fn = function('g:MytagFunc1', [12])
+ LET Fn = function('g:TagFunc1', [12])
LET &tagfunc = string(Fn)
- new | only
- LET g:MytagFunc1_args = []
+ new
+ LET g:TagFunc1Args = []
call assert_fails('tag a12', 'E433:')
- call assert_equal([12, 'a12', '', {}], g:MytagFunc1_args)
+ call assert_equal([12, 'a12', '', {}], g:TagFunc1Args)
+ bw!
#" Test for using a funcref()
- set tagfunc=funcref('g:MytagFunc1',\ [13])
- new | only
- LET g:MytagFunc1_args = []
+ set tagfunc=funcref('g:TagFunc1',\ [13])
+ new
+ LET g:TagFunc1Args = []
call assert_fails('tag a13', 'E433:')
- call assert_equal([13, 'a13', '', {}], g:MytagFunc1_args)
+ call assert_equal([13, 'a13', '', {}], g:TagFunc1Args)
+ bw!
#" Using a funcref variable to set 'tagfunc'
- LET Fn = funcref('g:MytagFunc1', [14])
+ LET Fn = funcref('g:TagFunc1', [14])
LET &tagfunc = Fn
- new | only
- LET g:MytagFunc1_args = []
+ new
+ LET g:TagFunc1Args = []
call assert_fails('tag a14', 'E433:')
- call assert_equal([14, 'a14', '', {}], g:MytagFunc1_args)
+ call assert_equal([14, 'a14', '', {}], g:TagFunc1Args)
+ bw!
#" Using a string(funcref_variable) to set 'tagfunc'
- LET Fn = funcref('g:MytagFunc1', [15])
+ LET Fn = funcref('g:TagFunc1', [15])
LET &tagfunc = string(Fn)
- new | only
- LET g:MytagFunc1_args = []
+ new
+ LET g:TagFunc1Args = []
call assert_fails('tag a14', 'E433:')
- call assert_equal([15, 'a14', '', {}], g:MytagFunc1_args)
+ call assert_equal([15, 'a14', '', {}], g:TagFunc1Args)
+ bw!
#" Test for using a lambda function
- VAR optval = "LSTART a, b, c LMIDDLE MytagFunc1(16, a, b, c) LEND"
+ VAR optval = "LSTART a, b, c LMIDDLE TagFunc1(16, a, b, c) LEND"
LET optval = substitute(optval, ' ', '\\ ', 'g')
exe "set tagfunc=" .. optval
- new | only
- LET g:MytagFunc1_args = []
+ new
+ LET g:TagFunc1Args = []
call assert_fails('tag a17', 'E433:')
- call assert_equal([16, 'a17', '', {}], g:MytagFunc1_args)
+ call assert_equal([16, 'a17', '', {}], g:TagFunc1Args)
+ bw!
#" Set 'tagfunc' to a lambda expression
- LET &tagfunc = LSTART a, b, c LMIDDLE MytagFunc1(17, a, b, c) LEND
- new | only
- LET g:MytagFunc1_args = []
+ LET &tagfunc = LSTART a, b, c LMIDDLE TagFunc1(17, a, b, c) LEND
+ new
+ LET g:TagFunc1Args = []
call assert_fails('tag a18', 'E433:')
- call assert_equal([17, 'a18', '', {}], g:MytagFunc1_args)
+ call assert_equal([17, 'a18', '', {}], g:TagFunc1Args)
+ bw!
#" Set 'tagfunc' to a string(lambda expression)
- LET &tagfunc = 'LSTART a, b, c LMIDDLE MytagFunc1(18, a, b, c) LEND'
- new | only
- LET g:MytagFunc1_args = []
+ LET &tagfunc = 'LSTART a, b, c LMIDDLE TagFunc1(18, a, b, c) LEND'
+ new
+ LET g:TagFunc1Args = []
call assert_fails('tag a18', 'E433:')
- call assert_equal([18, 'a18', '', {}], g:MytagFunc1_args)
+ call assert_equal([18, 'a18', '', {}], g:TagFunc1Args)
+ bw!
#" Set 'tagfunc' to a variable with a lambda expression
- VAR Lambda = LSTART a, b, c LMIDDLE MytagFunc1(19, a, b, c) LEND
+ VAR Lambda = LSTART a, b, c LMIDDLE TagFunc1(19, a, b, c) LEND
LET &tagfunc = Lambda
- new | only
- LET g:MytagFunc1_args = []
+ new
+ LET g:TagFunc1Args = []
call assert_fails("tag a19", "E433:")
- call assert_equal([19, 'a19', '', {}], g:MytagFunc1_args)
+ call assert_equal([19, 'a19', '', {}], g:TagFunc1Args)
+ bw!
#" Set 'tagfunc' to a string(variable with a lambda expression)
- LET Lambda = LSTART a, b, c LMIDDLE MytagFunc1(20, a, b, c) LEND
+ LET Lambda = LSTART a, b, c LMIDDLE TagFunc1(20, a, b, c) LEND
LET &tagfunc = string(Lambda)
- new | only
- LET g:MytagFunc1_args = []
+ new
+ LET g:TagFunc1Args = []
call assert_fails("tag a19", "E433:")
- call assert_equal([20, 'a19', '', {}], g:MytagFunc1_args)
+ call assert_equal([20, 'a19', '', {}], g:TagFunc1Args)
+ bw!
#" Test for using a lambda function with incorrect return value
LET Lambda = LSTART a, b, c LMIDDLE strlen(a) LEND
LET &tagfunc = string(Lambda)
- new | only
+ new
call assert_fails("tag a20", "E987:")
+ bw!
#" Test for clearing the 'tagfunc' option
set tagfunc=''
@@ -231,10 +255,13 @@ func Test_tagfunc_callback()
call assert_fails("set tagfunc=funcref('abc')", "E700:")
#" set 'tagfunc' to a non-existing function
- LET &tagfunc = function('g:MytagFunc1', [21])
+ LET &tagfunc = function('g:TagFunc2', [21])
+ LET g:TagFunc2Args = []
call assert_fails("set tagfunc=function('NonExistingFunc')", 'E700:')
call assert_fails("LET &tagfunc = function('NonExistingFunc')", 'E700:')
call assert_fails("tag axb123", 'E426:')
+ call assert_equal([], g:TagFunc2Args)
+ bw!
END
call CheckLegacyAndVim9Success(lines)
@@ -242,11 +269,11 @@ func Test_tagfunc_callback()
call assert_fails("echo taglist('a')", "E987:")
" Using Vim9 lambda expression in legacy context should fail
- set tagfunc=(a,\ b,\ c)\ =>\ g:MytagFunc1(21,\ a,\ b,\ c)
+ set tagfunc=(a,\ b,\ c)\ =>\ g:TagFunc1(21,\ a,\ b,\ c)
new | only
- let g:MytagFunc1_args = []
+ let g:TagFunc1Args = []
call assert_fails("tag a17", "E117:")
- call assert_equal([], g:MytagFunc1_args)
+ call assert_equal([], g:TagFunc1Args)
" Test for using a script local function
set tagfunc=<SID>ScriptLocalTagFunc
@@ -309,7 +336,8 @@ func Test_tagfunc_callback()
call CheckScriptSuccess(lines)
" cleanup
- delfunc MytagFunc1
+ delfunc TagFunc1
+ delfunc TagFunc2
set tagfunc&
%bw!
endfunc
diff --git a/src/version.c b/src/version.c
index c5e42883a..7ee0e170c 100644
--- a/src/version.c
+++ b/src/version.c
@@ -754,6 +754,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 3792,
+/**/
3791,
/**/
3790,