Mercurial > vim
annotate src/testdir/test_tagfunc.vim @ 29543:b679513dc17c
Added tag v9.0.0112 for changeset 61b400b5e1a81aa992a50aeefcb5c5ab45a53e9e
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 30 Jul 2022 16:45:04 +0200 |
parents | 19367412787c |
children | 1aec47ab35f0 |
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 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26618
diff
changeset
|
3 import './vim9.vim' as v9 |
26600
6fed1f1bc282
patch 8.2.3829: no error when setting a func option to script-local function
Bram Moolenaar <Bram@vim.org>
parents:
26526
diff
changeset
|
4 source check.vim |
6fed1f1bc282
patch 8.2.3829: no error when setting a func option to script-local function
Bram Moolenaar <Bram@vim.org>
parents:
26526
diff
changeset
|
5 source screendump.vim |
26362
dbe615b75f15
patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
26268
diff
changeset
|
6 |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7 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
|
8 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
|
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 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
|
11 let tags += [{ |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
12 \ '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
|
13 \ '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
|
14 \}] |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
15 endfor |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
16 return tags |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
17 endfunc |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
18 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
19 func Test_tagfunc() |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
20 set tagfunc=TagFunc |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
21 new Xfile1 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
22 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
|
23 write |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
24 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
25 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
|
26 \ '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
|
27 \ '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
|
28 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
29 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
|
30 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
31 tag arbitrary |
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('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
|
33 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
|
34 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
|
35 5tag arbitrary |
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('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
|
37 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
|
38 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
|
39 pop |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
40 tag |
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('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
|
42 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
|
43 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
|
44 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
45 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
|
46 execute "normal! \<c-]>" |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
47 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
|
48 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
|
49 |
24186
4902263c302e
patch 8.2.2634: 'tagfunc' does not indicate using a pattern
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
50 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
|
51 execute "tag /foo$" |
4902263c302e
patch 8.2.2634: 'tagfunc' does not indicate using a pattern
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
52 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
|
53 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
|
54 |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
55 set cpt=t |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
56 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
|
57 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
|
58 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
|
59 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
|
60 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
|
61 |
24186
4902263c302e
patch 8.2.2634: 'tagfunc' does not indicate using a pattern
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
62 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
|
63 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
|
64 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
|
65 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
|
66 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
|
67 |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
68 func BadTagFunc1(...) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
69 return 0 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
70 endfunc |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
71 func BadTagFunc2(...) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
72 return [1] |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
73 endfunc |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
74 func BadTagFunc3(...) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
75 return [{'name': 'foo'}] |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
76 endfunc |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
77 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
78 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
|
79 try |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
80 tag nothing |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
81 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
|
82 catch |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
83 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
|
84 endtry |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
85 exe 'delf' &tagfunc |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
86 endfor |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
87 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
88 func NullTagFunc(...) |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
89 return v:null |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
90 endfunc |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
91 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
|
92 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
|
93 delf NullTagFunc |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
94 |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
95 bwipe! |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
96 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
|
97 call delete('Xfile1') |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
98 endfunc |
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
99 |
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
|
100 " 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
|
101 " 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
|
102 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
|
103 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
|
104 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
|
105 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
|
106 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
|
107 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
|
108 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
|
109 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
|
110 |
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 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
|
112 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
|
113 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
|
114 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
|
115 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
|
116 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
|
117 |
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 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
|
119 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
|
120 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
|
121 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
|
122 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
|
123 |
26388
8aba638e91eb
patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents:
26362
diff
changeset
|
124 " Script local tagfunc callback function |
8aba638e91eb
patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents:
26362
diff
changeset
|
125 func s:ScriptLocalTagFunc(pat, flags, info) |
8aba638e91eb
patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents:
26362
diff
changeset
|
126 let g:ScriptLocalFuncArgs = [a:pat, a:flags, a:info] |
8aba638e91eb
patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents:
26362
diff
changeset
|
127 return v:null |
8aba638e91eb
patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents:
26362
diff
changeset
|
128 endfunc |
8aba638e91eb
patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents:
26362
diff
changeset
|
129 |
26268
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
24186
diff
changeset
|
130 " 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
|
131 func Test_tagfunc_callback() |
26526
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
132 func TagFunc1(callnr, pat, flags, info) |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
133 let g:TagFunc1Args = [a:callnr, a:pat, a:flags, a:info] |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
134 return v:null |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
135 endfunc |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
136 func TagFunc2(pat, flags, info) |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
137 let g:TagFunc2Args = [a:pat, a:flags, a:info] |
26268
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
24186
diff
changeset
|
138 return v:null |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
24186
diff
changeset
|
139 endfunc |
26456
7eaf61a67d18
patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
140 |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
141 let lines =<< trim END |
26526
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
142 #" Test for using a function name |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
143 LET &tagfunc = 'g:TagFunc2' |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
144 new |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
145 LET g:TagFunc2Args = [] |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
146 call assert_fails('tag a10', 'E433:') |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
147 call assert_equal(['a10', '', {}], g:TagFunc2Args) |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
148 bw! |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
149 |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
150 #" Test for using a function() |
26526
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
151 set tagfunc=function('g:TagFunc1',\ [10]) |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
152 new |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
153 LET g:TagFunc1Args = [] |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
154 call assert_fails('tag a11', 'E433:') |
26526
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
155 call assert_equal([10, 'a11', '', {}], g:TagFunc1Args) |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
156 bw! |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
157 |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
158 #" Using a funcref variable to set 'tagfunc' |
26526
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
159 VAR Fn = function('g:TagFunc1', [11]) |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
160 LET &tagfunc = Fn |
26526
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
161 new |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
162 LET g:TagFunc1Args = [] |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
163 call assert_fails('tag a12', 'E433:') |
26526
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
164 call assert_equal([11, 'a12', '', {}], g:TagFunc1Args) |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
165 bw! |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
166 |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
167 #" Using a string(funcref_variable) to set 'tagfunc' |
26526
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
168 LET Fn = function('g:TagFunc1', [12]) |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
169 LET &tagfunc = string(Fn) |
26526
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
170 new |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
171 LET g:TagFunc1Args = [] |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
172 call assert_fails('tag a12', 'E433:') |
26526
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
173 call assert_equal([12, 'a12', '', {}], g:TagFunc1Args) |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
174 bw! |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
175 |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
176 #" Test for using a funcref() |
26526
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
177 set tagfunc=funcref('g:TagFunc1',\ [13]) |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
178 new |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
179 LET g:TagFunc1Args = [] |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
180 call assert_fails('tag a13', 'E433:') |
26526
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
181 call assert_equal([13, 'a13', '', {}], g:TagFunc1Args) |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
182 bw! |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
183 |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
184 #" Using a funcref variable to set 'tagfunc' |
26526
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
185 LET Fn = funcref('g:TagFunc1', [14]) |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
186 LET &tagfunc = Fn |
26526
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
187 new |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
188 LET g:TagFunc1Args = [] |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
189 call assert_fails('tag a14', 'E433:') |
26526
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
190 call assert_equal([14, 'a14', '', {}], g:TagFunc1Args) |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
191 bw! |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
192 |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
193 #" Using a string(funcref_variable) to set 'tagfunc' |
26526
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
194 LET Fn = funcref('g:TagFunc1', [15]) |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
195 LET &tagfunc = string(Fn) |
26526
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
196 new |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
197 LET g:TagFunc1Args = [] |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
198 call assert_fails('tag a14', 'E433:') |
26526
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
199 call assert_equal([15, 'a14', '', {}], g:TagFunc1Args) |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
200 bw! |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
201 |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
202 #" Test for using a lambda function |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26618
diff
changeset
|
203 VAR optval = "LSTART a, b, c LMIDDLE g:TagFunc1(16, a, b, c) LEND" |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
204 LET optval = substitute(optval, ' ', '\\ ', 'g') |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
205 exe "set tagfunc=" .. optval |
26526
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
206 new |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
207 LET g:TagFunc1Args = [] |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
208 call assert_fails('tag a17', 'E433:') |
26526
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
209 call assert_equal([16, 'a17', '', {}], g:TagFunc1Args) |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
210 bw! |
26362
dbe615b75f15
patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
26268
diff
changeset
|
211 |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
212 #" Set 'tagfunc' to a lambda expression |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26618
diff
changeset
|
213 LET &tagfunc = LSTART a, b, c LMIDDLE g:TagFunc1(17, a, b, c) LEND |
26526
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
214 new |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
215 LET g:TagFunc1Args = [] |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
216 call assert_fails('tag a18', 'E433:') |
26526
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
217 call assert_equal([17, 'a18', '', {}], g:TagFunc1Args) |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
218 bw! |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
219 |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
220 #" Set 'tagfunc' to a string(lambda expression) |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26618
diff
changeset
|
221 LET &tagfunc = 'LSTART a, b, c LMIDDLE g:TagFunc1(18, a, b, c) LEND' |
26526
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
222 new |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
223 LET g:TagFunc1Args = [] |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
224 call assert_fails('tag a18', 'E433:') |
26526
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
225 call assert_equal([18, 'a18', '', {}], g:TagFunc1Args) |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
226 bw! |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
227 |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
228 #" Set 'tagfunc' to a variable with a lambda expression |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26618
diff
changeset
|
229 VAR Lambda = LSTART a, b, c LMIDDLE g:TagFunc1(19, a, b, c) LEND |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
230 LET &tagfunc = Lambda |
26526
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
231 new |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
232 LET g:TagFunc1Args = [] |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
233 call assert_fails("tag a19", "E433:") |
26526
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
234 call assert_equal([19, 'a19', '', {}], g:TagFunc1Args) |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
235 bw! |
26441
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26388
diff
changeset
|
236 |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
237 #" Set 'tagfunc' to a string(variable with a lambda expression) |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26618
diff
changeset
|
238 LET Lambda = LSTART a, b, c LMIDDLE g:TagFunc1(20, a, b, c) LEND |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
239 LET &tagfunc = string(Lambda) |
26526
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
240 new |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
241 LET g:TagFunc1Args = [] |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
242 call assert_fails("tag a19", "E433:") |
26526
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
243 call assert_equal([20, 'a19', '', {}], g:TagFunc1Args) |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
244 bw! |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
245 |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
246 #" Test for using a lambda function with incorrect return value |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
247 LET Lambda = LSTART a, b, c LMIDDLE strlen(a) LEND |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
248 LET &tagfunc = string(Lambda) |
26526
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
249 new |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
250 call assert_fails("tag a20", "E987:") |
26526
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
251 bw! |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
252 |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
253 #" Test for clearing the 'tagfunc' option |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
254 set tagfunc='' |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
255 set tagfunc& |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
256 call assert_fails("set tagfunc=function('abc')", "E700:") |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
257 call assert_fails("set tagfunc=funcref('abc')", "E700:") |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
258 |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
259 #" set 'tagfunc' to a non-existing function |
26526
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
260 LET &tagfunc = function('g:TagFunc2', [21]) |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
261 LET g:TagFunc2Args = [] |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
262 call assert_fails("set tagfunc=function('NonExistingFunc')", 'E700:') |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
263 call assert_fails("LET &tagfunc = function('NonExistingFunc')", 'E700:') |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
264 call assert_fails("tag axb123", 'E426:') |
26526
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
265 call assert_equal([], g:TagFunc2Args) |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
266 bw! |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
267 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26618
diff
changeset
|
268 call v9.CheckLegacyAndVim9Success(lines) |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
269 |
26618
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
270 " Test for using a script-local function name |
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
271 func s:TagFunc3(pat, flags, info) |
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
272 let g:TagFunc3Args = [a:pat, a:flags, a:info] |
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
273 return v:null |
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
274 endfunc |
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
275 set tagfunc=s:TagFunc3 |
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
276 new |
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
277 let g:TagFunc3Args = [] |
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
278 call assert_fails('tag a21', 'E433:') |
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
279 call assert_equal(['a21', '', {}], g:TagFunc3Args) |
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
280 bw! |
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
281 let &tagfunc = 's:TagFunc3' |
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
282 new |
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
283 let g:TagFunc3Args = [] |
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
284 call assert_fails('tag a22', 'E433:') |
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
285 call assert_equal(['a22', '', {}], g:TagFunc3Args) |
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
286 bw! |
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
287 delfunc s:TagFunc3 |
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
288 |
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
289 " invalid return value |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
290 let &tagfunc = "{a -> 'abc'}" |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
291 call assert_fails("echo taglist('a')", "E987:") |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
292 |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
293 " Using Vim9 lambda expression in legacy context should fail |
26526
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
294 set tagfunc=(a,\ b,\ c)\ =>\ g:TagFunc1(21,\ a,\ b,\ c) |
26618
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
295 new |
26526
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
296 let g:TagFunc1Args = [] |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
297 call assert_fails("tag a17", "E117:") |
26526
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
298 call assert_equal([], g:TagFunc1Args) |
26618
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
299 bw! |
26268
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
24186
diff
changeset
|
300 |
26388
8aba638e91eb
patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents:
26362
diff
changeset
|
301 " Test for using a script local function |
8aba638e91eb
patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents:
26362
diff
changeset
|
302 set tagfunc=<SID>ScriptLocalTagFunc |
26618
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
303 new |
26388
8aba638e91eb
patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents:
26362
diff
changeset
|
304 let g:ScriptLocalFuncArgs = [] |
8aba638e91eb
patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents:
26362
diff
changeset
|
305 call assert_fails('tag a15', 'E433:') |
8aba638e91eb
patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents:
26362
diff
changeset
|
306 call assert_equal(['a15', '', {}], g:ScriptLocalFuncArgs) |
26618
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
307 bw! |
26388
8aba638e91eb
patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents:
26362
diff
changeset
|
308 |
8aba638e91eb
patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents:
26362
diff
changeset
|
309 " Test for using a script local funcref variable |
8aba638e91eb
patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents:
26362
diff
changeset
|
310 let Fn = function("s:ScriptLocalTagFunc") |
26441
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26388
diff
changeset
|
311 let &tagfunc= Fn |
26618
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
312 new |
26441
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26388
diff
changeset
|
313 let g:ScriptLocalFuncArgs = [] |
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26388
diff
changeset
|
314 call assert_fails('tag a16', 'E433:') |
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26388
diff
changeset
|
315 call assert_equal(['a16', '', {}], g:ScriptLocalFuncArgs) |
26618
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
316 bw! |
26441
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26388
diff
changeset
|
317 |
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26388
diff
changeset
|
318 " Test for using a string(script local funcref variable) |
65ab0b035dd8
patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents:
26388
diff
changeset
|
319 let Fn = function("s:ScriptLocalTagFunc") |
26388
8aba638e91eb
patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents:
26362
diff
changeset
|
320 let &tagfunc= string(Fn) |
26618
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
321 new |
26388
8aba638e91eb
patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents:
26362
diff
changeset
|
322 let g:ScriptLocalFuncArgs = [] |
8aba638e91eb
patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents:
26362
diff
changeset
|
323 call assert_fails('tag a16', 'E433:') |
8aba638e91eb
patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents:
26362
diff
changeset
|
324 call assert_equal(['a16', '', {}], g:ScriptLocalFuncArgs) |
26618
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
325 bw! |
26388
8aba638e91eb
patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents:
26362
diff
changeset
|
326 |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
327 " set 'tagfunc' to a partial with dict. This used to cause a crash. |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
328 func SetTagFunc() |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
329 let params = {'tagfn': function('g:DictTagFunc')} |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
330 let &tagfunc = params.tagfn |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
331 endfunc |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
332 func g:DictTagFunc(_) dict |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
333 endfunc |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
334 call SetTagFunc() |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
335 new |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
336 call SetTagFunc() |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
337 bw |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
338 call test_garbagecollect_now() |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
339 new |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
340 set tagfunc= |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
341 wincmd w |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
342 set tagfunc= |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
343 :%bw! |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
344 delfunc g:DictTagFunc |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
26456
diff
changeset
|
345 delfunc SetTagFunc |
26456
7eaf61a67d18
patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
346 |
26362
dbe615b75f15
patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
26268
diff
changeset
|
347 " Vim9 tests |
dbe615b75f15
patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
26268
diff
changeset
|
348 let lines =<< trim END |
dbe615b75f15
patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
26268
diff
changeset
|
349 vim9script |
dbe615b75f15
patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
26268
diff
changeset
|
350 |
26618
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
351 def Vim9tagFunc(callnr: number, pat: string, flags: string, info: dict<any>): any |
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
352 g:Vim9tagFuncArgs = [callnr, pat, flags, info] |
26362
dbe615b75f15
patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
26268
diff
changeset
|
353 return null |
dbe615b75f15
patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
26268
diff
changeset
|
354 enddef |
26618
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
355 |
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
356 # Test for using a def function with completefunc |
26456
7eaf61a67d18
patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
357 set tagfunc=function('Vim9tagFunc',\ [60]) |
26618
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
358 new |
26456
7eaf61a67d18
patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
359 g:Vim9tagFuncArgs = [] |
7eaf61a67d18
patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
360 assert_fails('tag a10', 'E433:') |
7eaf61a67d18
patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
361 assert_equal([60, 'a10', '', {}], g:Vim9tagFuncArgs) |
26618
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
362 |
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
363 # Test for using a global function name |
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
364 &tagfunc = g:TagFunc2 |
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
365 new |
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
366 g:TagFunc2Args = [] |
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
367 assert_fails('tag a11', 'E433:') |
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
368 assert_equal(['a11', '', {}], g:TagFunc2Args) |
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
369 bw! |
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
370 |
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
371 # Test for using a script-local function name |
27671
19367412787c
patch 8.2.4361: Vim9: some tests fail
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
372 def LocalTagFunc(pat: string, flags: string, info: dict<any> ): any |
26618
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
373 g:LocalTagFuncArgs = [pat, flags, info] |
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
374 return null |
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
375 enddef |
27671
19367412787c
patch 8.2.4361: Vim9: some tests fail
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
376 &tagfunc = LocalTagFunc |
26618
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
377 new |
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
378 g:LocalTagFuncArgs = [] |
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
379 assert_fails('tag a12', 'E433:') |
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
380 assert_equal(['a12', '', {}], g:LocalTagFuncArgs) |
b531c26f728b
patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents:
26600
diff
changeset
|
381 bw! |
26362
dbe615b75f15
patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
26268
diff
changeset
|
382 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26618
diff
changeset
|
383 call v9.CheckScriptSuccess(lines) |
26362
dbe615b75f15
patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
26268
diff
changeset
|
384 |
26268
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
24186
diff
changeset
|
385 " cleanup |
26526
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
386 delfunc TagFunc1 |
33d680d372aa
patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
387 delfunc TagFunc2 |
26362
dbe615b75f15
patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
26268
diff
changeset
|
388 set tagfunc& |
26268
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
24186
diff
changeset
|
389 %bw! |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
24186
diff
changeset
|
390 endfunc |
3aa48d4e3dc8
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents:
24186
diff
changeset
|
391 |
16447
54ffc82f38a8
patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
392 " vim: shiftwidth=2 sts=2 expandtab |