annotate src/testdir/test_tagfunc.vim @ 26362:dbe615b75f15 v8.2.3712

patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc' Commit: https://github.com/vim/vim/commit/05e59e3a9ffddbf93c7af02cd2ba1d0f822d4625 Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Wed Dec 1 10:30:07 2021 +0000 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc' Problem: Cannot use Vim9 lambda for 'tagfunc'. Solution: Make it work, add more tests. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/9250)
author Bram Moolenaar <Bram@vim.org>
date Wed, 01 Dec 2021 11:45:02 +0100
parents 3aa48d4e3dc8
children 8aba638e91eb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16447
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 " Test 'tagfunc'
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2
26362
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
3 source vim9.vim
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
4
16447
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5 func TagFunc(pat, flag, info)
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
6 let g:tagfunc_args = [a:pat, a:flag, a:info]
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7 let tags = []
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8 for num in range(1,10)
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9 let tags += [{
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10 \ 'cmd': '2', 'name': 'nothing'.num, 'kind': 'm',
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11 \ 'filename': 'Xfile1', 'user_data': 'somedata'.num,
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
12 \}]
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
13 endfor
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
14 return tags
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15 endfunc
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
16
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
17 func Test_tagfunc()
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
18 set tagfunc=TagFunc
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
19 new Xfile1
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20 call setline(1, ['empty', 'one()', 'empty'])
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 write
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
23 call assert_equal({'cmd': '2', 'static': 0,
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
24 \ 'name': 'nothing2', 'user_data': 'somedata2',
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25 \ 'kind': 'm', 'filename': 'Xfile1'}, taglist('.')[1])
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
26
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
27 call settagstack(win_getid(), {'items': []})
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
28
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29 tag arbitrary
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30 call assert_equal('arbitrary', g:tagfunc_args[0])
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31 call assert_equal('', g:tagfunc_args[1])
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32 call assert_equal('somedata1', gettagstack().items[0].user_data)
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33 5tag arbitrary
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34 call assert_equal('arbitrary', g:tagfunc_args[0])
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35 call assert_equal('', g:tagfunc_args[1])
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 call assert_equal('somedata5', gettagstack().items[1].user_data)
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37 pop
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38 tag
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39 call assert_equal('arbitrary', g:tagfunc_args[0])
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40 call assert_equal('', g:tagfunc_args[1])
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41 call assert_equal('somedata5', gettagstack().items[1].user_data)
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
42
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
43 let g:tagfunc_args=[]
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
44 execute "normal! \<c-]>"
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 call assert_equal('one', g:tagfunc_args[0])
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46 call assert_equal('c', g:tagfunc_args[1])
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47
24186
4902263c302e patch 8.2.2634: 'tagfunc' does not indicate using a pattern
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
48 let g:tagfunc_args=[]
4902263c302e patch 8.2.2634: 'tagfunc' does not indicate using a pattern
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
49 execute "tag /foo$"
4902263c302e patch 8.2.2634: 'tagfunc' does not indicate using a pattern
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
50 call assert_equal('foo$', g:tagfunc_args[0])
4902263c302e patch 8.2.2634: 'tagfunc' does not indicate using a pattern
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
51 call assert_equal('r', g:tagfunc_args[1])
4902263c302e patch 8.2.2634: 'tagfunc' does not indicate using a pattern
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
52
16447
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
53 set cpt=t
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
54 let g:tagfunc_args=[]
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
55 execute "normal! i\<c-n>\<c-y>"
24186
4902263c302e patch 8.2.2634: 'tagfunc' does not indicate using a pattern
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
56 call assert_equal('\<\k\k', g:tagfunc_args[0])
4902263c302e patch 8.2.2634: 'tagfunc' does not indicate using a pattern
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
57 call assert_equal('cir', g:tagfunc_args[1])
16447
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
58 call assert_equal('nothing1', getline('.')[0:7])
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
59
24186
4902263c302e patch 8.2.2634: 'tagfunc' does not indicate using a pattern
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
60 let g:tagfunc_args=[]
4902263c302e patch 8.2.2634: 'tagfunc' does not indicate using a pattern
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
61 execute "normal! ono\<c-n>\<c-n>\<c-y>"
4902263c302e patch 8.2.2634: 'tagfunc' does not indicate using a pattern
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
62 call assert_equal('\<no', g:tagfunc_args[0])
4902263c302e patch 8.2.2634: 'tagfunc' does not indicate using a pattern
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
63 call assert_equal('cir', g:tagfunc_args[1])
4902263c302e patch 8.2.2634: 'tagfunc' does not indicate using a pattern
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
64 call assert_equal('nothing2', getline('.')[0:7])
4902263c302e patch 8.2.2634: 'tagfunc' does not indicate using a pattern
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
65
16447
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
66 func BadTagFunc1(...)
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
67 return 0
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
68 endfunc
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
69 func BadTagFunc2(...)
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
70 return [1]
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
71 endfunc
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
72 func BadTagFunc3(...)
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
73 return [{'name': 'foo'}]
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
74 endfunc
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
75
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
76 for &tagfunc in ['BadTagFunc1', 'BadTagFunc2', 'BadTagFunc3']
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
77 try
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
78 tag nothing
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
79 call assert_false(1, 'tag command should have failed')
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
80 catch
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
81 call assert_exception('E987:')
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
82 endtry
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
83 exe 'delf' &tagfunc
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
84 endfor
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
85
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
86 func NullTagFunc(...)
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
87 return v:null
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
88 endfunc
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
89 set tags= tfu=NullTagFunc
22087
ff21e2962490 patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
90 call assert_fails('tag nothing', 'E433:')
16447
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
91 delf NullTagFunc
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
92
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
93 bwipe!
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
94 set tags& tfu& cpt&
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
95 call delete('Xfile1')
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
96 endfunc
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
97
19055
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 16447
diff changeset
98 " Test for modifying the tag stack from a tag function and jumping to a tag
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 16447
diff changeset
99 " from a tag function
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 16447
diff changeset
100 func Test_tagfunc_settagstack()
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 16447
diff changeset
101 func Mytagfunc1(pat, flags, info)
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 16447
diff changeset
102 call settagstack(1, {'tagname' : 'mytag', 'from' : [0, 10, 1, 0]})
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 16447
diff changeset
103 return [{'name' : 'mytag', 'filename' : 'Xtest', 'cmd' : '1'}]
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 16447
diff changeset
104 endfunc
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 16447
diff changeset
105 set tagfunc=Mytagfunc1
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 16447
diff changeset
106 call writefile([''], 'Xtest')
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 16447
diff changeset
107 call assert_fails('tag xyz', 'E986:')
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 16447
diff changeset
108
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 16447
diff changeset
109 func Mytagfunc2(pat, flags, info)
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 16447
diff changeset
110 tag test_tag
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 16447
diff changeset
111 return [{'name' : 'mytag', 'filename' : 'Xtest', 'cmd' : '1'}]
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 16447
diff changeset
112 endfunc
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 16447
diff changeset
113 set tagfunc=Mytagfunc2
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 16447
diff changeset
114 call assert_fails('tag xyz', 'E986:')
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 16447
diff changeset
115
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 16447
diff changeset
116 call delete('Xtest')
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 16447
diff changeset
117 set tagfunc&
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 16447
diff changeset
118 delfunc Mytagfunc1
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 16447
diff changeset
119 delfunc Mytagfunc2
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 16447
diff changeset
120 endfunc
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 16447
diff changeset
121
26268
3aa48d4e3dc8 patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 24186
diff changeset
122 " Test for different ways of setting the 'tagfunc' option
3aa48d4e3dc8 patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 24186
diff changeset
123 func Test_tagfunc_callback()
3aa48d4e3dc8 patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 24186
diff changeset
124 " Test for using a function()
3aa48d4e3dc8 patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 24186
diff changeset
125 func MytagFunc1(pat, flags, info)
3aa48d4e3dc8 patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 24186
diff changeset
126 let g:MytagFunc1_args = [a:pat, a:flags, a:info]
3aa48d4e3dc8 patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 24186
diff changeset
127 return v:null
3aa48d4e3dc8 patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 24186
diff changeset
128 endfunc
26362
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
129 set tagfunc=function('MytagFunc1')
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
130 new | only
26268
3aa48d4e3dc8 patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 24186
diff changeset
131 let g:MytagFunc1_args = []
26362
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
132 call assert_fails('tag a11', 'E433:')
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
133 call assert_equal(['a11', '', {}], g:MytagFunc1_args)
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
134
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
135 " Using a funcref variable to set 'tagfunc'
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
136 let Fn = function('MytagFunc1')
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
137 let &tagfunc = string(Fn)
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
138 new | only
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
139 let g:MytagFunc1_args = []
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
140 call assert_fails('tag a12', 'E433:')
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
141 call assert_equal(['a12', '', {}], g:MytagFunc1_args)
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
142 call assert_fails('let &tagfunc = Fn', 'E729:')
26268
3aa48d4e3dc8 patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 24186
diff changeset
143
3aa48d4e3dc8 patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 24186
diff changeset
144 " Test for using a funcref()
3aa48d4e3dc8 patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 24186
diff changeset
145 func MytagFunc2(pat, flags, info)
3aa48d4e3dc8 patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 24186
diff changeset
146 let g:MytagFunc2_args = [a:pat, a:flags, a:info]
3aa48d4e3dc8 patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 24186
diff changeset
147 return v:null
3aa48d4e3dc8 patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 24186
diff changeset
148 endfunc
26362
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
149 set tagfunc=funcref('MytagFunc2')
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
150 new | only
26268
3aa48d4e3dc8 patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 24186
diff changeset
151 let g:MytagFunc2_args = []
26362
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
152 call assert_fails('tag a13', 'E433:')
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
153 call assert_equal(['a13', '', {}], g:MytagFunc2_args)
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
154
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
155 " Using a funcref variable to set 'tagfunc'
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
156 let Fn = funcref('MytagFunc2')
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
157 let &tagfunc = string(Fn)
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
158 new | only
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
159 let g:MytagFunc2_args = []
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
160 call assert_fails('tag a14', 'E433:')
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
161 call assert_equal(['a14', '', {}], g:MytagFunc2_args)
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
162 call assert_fails('let &tagfunc = Fn', 'E729:')
26268
3aa48d4e3dc8 patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 24186
diff changeset
163
3aa48d4e3dc8 patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 24186
diff changeset
164 " Test for using a lambda function
3aa48d4e3dc8 patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 24186
diff changeset
165 func MytagFunc3(pat, flags, info)
3aa48d4e3dc8 patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 24186
diff changeset
166 let g:MytagFunc3_args = [a:pat, a:flags, a:info]
3aa48d4e3dc8 patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 24186
diff changeset
167 return v:null
3aa48d4e3dc8 patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 24186
diff changeset
168 endfunc
26362
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
169 set tagfunc={a,\ b,\ c\ ->\ MytagFunc3(a,\ b,\ c)}
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
170 new | only
26268
3aa48d4e3dc8 patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 24186
diff changeset
171 let g:MytagFunc3_args = []
26362
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
172 call assert_fails('tag a15', 'E433:')
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
173 call assert_equal(['a15', '', {}], g:MytagFunc3_args)
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
174
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
175 " Set 'tagfunc' to a lambda expression
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
176 let &tagfunc = '{a, b, c -> MytagFunc3(a, b, c)}'
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
177 new | only
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
178 let g:MytagFunc3_args = []
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
179 call assert_fails('tag a16', 'E433:')
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
180 call assert_equal(['a16', '', {}], g:MytagFunc3_args)
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
181
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
182 " Set 'tagfunc' to a variable with a lambda expression
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
183 let Lambda = {a, b, c -> MytagFunc3(a, b, c)}
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
184 let &tagfunc = string(Lambda)
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
185 new | only
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
186 let g:MytagFunc3_args = []
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
187 call assert_fails("tag a17", "E433:")
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
188 call assert_equal(['a17', '', {}], g:MytagFunc3_args)
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
189 call assert_fails('let &tagfunc = Lambda', 'E729:')
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
190
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
191 " Test for using a lambda function with incorrect return value
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
192 let Lambda = {s -> strlen(s)}
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
193 let &tagfunc = string(Lambda)
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
194 new | only
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
195 call assert_fails("tag a17", "E987:")
26268
3aa48d4e3dc8 patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 24186
diff changeset
196
3aa48d4e3dc8 patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 24186
diff changeset
197 " Test for clearing the 'tagfunc' option
3aa48d4e3dc8 patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 24186
diff changeset
198 set tagfunc=''
3aa48d4e3dc8 patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 24186
diff changeset
199 set tagfunc&
3aa48d4e3dc8 patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 24186
diff changeset
200
3aa48d4e3dc8 patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 24186
diff changeset
201 call assert_fails("set tagfunc=function('abc')", "E700:")
3aa48d4e3dc8 patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 24186
diff changeset
202 call assert_fails("set tagfunc=funcref('abc')", "E700:")
3aa48d4e3dc8 patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 24186
diff changeset
203 let &tagfunc = "{a -> 'abc'}"
3aa48d4e3dc8 patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 24186
diff changeset
204 call assert_fails("echo taglist('a')", "E987:")
3aa48d4e3dc8 patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 24186
diff changeset
205
26362
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
206 " Vim9 tests
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
207 let lines =<< trim END
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
208 vim9script
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
209
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
210 # Test for using function()
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
211 def MytagFunc1(pat: string, flags: string, info: dict<any>): any
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
212 g:MytagFunc1_args = [pat, flags, info]
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
213 return null
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
214 enddef
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
215 set tagfunc=function('MytagFunc1')
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
216 new | only
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
217 g:MytagFunc1_args = []
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
218 assert_fails('tag a10', 'E433:')
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
219 assert_equal(['a10', '', {}], g:MytagFunc1_args)
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
220
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
221 # Test for using a lambda
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
222 def MytagFunc2(pat: string, flags: string, info: dict<any>): any
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
223 g:MytagFunc2_args = [pat, flags, info]
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
224 return null
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
225 enddef
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
226 &tagfunc = '(a, b, c) => MytagFunc2(a, b, c)'
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
227 new | only
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
228 g:MytagFunc2_args = []
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
229 assert_fails('tag a20', 'E433:')
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
230 assert_equal(['a20', '', {}], g:MytagFunc2_args)
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
231
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
232 # Test for using a variable with a lambda expression
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
233 var Fn: func = (a, b, c) => MytagFunc2(a, b, c)
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
234 &tagfunc = string(Fn)
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
235 new | only
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
236 g:MytagFunc2_args = []
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
237 assert_fails('tag a30', 'E433:')
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
238 assert_equal(['a30', '', {}], g:MytagFunc2_args)
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
239 END
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
240 call CheckScriptSuccess(lines)
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
241
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
242 " Using Vim9 lambda expression in legacy context should fail
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
243 set tagfunc=(a,\ b,\ c)\ =>\ g:MytagFunc2(a,\ b,\ c)
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
244 new | only
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
245 let g:MytagFunc3_args = []
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
246 call assert_fails("tag a17", "E117:")
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
247 call assert_equal([], g:MytagFunc3_args)
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
248
26268
3aa48d4e3dc8 patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 24186
diff changeset
249 " cleanup
3aa48d4e3dc8 patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 24186
diff changeset
250 delfunc MytagFunc1
3aa48d4e3dc8 patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 24186
diff changeset
251 delfunc MytagFunc2
3aa48d4e3dc8 patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 24186
diff changeset
252 delfunc MytagFunc3
26362
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26268
diff changeset
253 set tagfunc&
26268
3aa48d4e3dc8 patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 24186
diff changeset
254 %bw!
3aa48d4e3dc8 patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 24186
diff changeset
255 endfunc
3aa48d4e3dc8 patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 24186
diff changeset
256
16447
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
257 " vim: shiftwidth=2 sts=2 expandtab