annotate src/testdir/test_tagfunc.vim @ 24895:e61a2085c89b v8.2.2985

patch 8.2.2985: Vim9: a compiled function cannot be debugged Commit: https://github.com/vim/vim/commit/e99d422bbd3e47620915bf89671673f0711671b4 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jun 13 14:01:26 2021 +0200 patch 8.2.2985: Vim9: a compiled function cannot be debugged Problem: Vim9: a compiled function cannot be debugged. Solution: Add initial debugging support.
author Bram Moolenaar <Bram@vim.org>
date Sun, 13 Jun 2021 14:15:04 +0200
parents 4902263c302e
children 3aa48d4e3dc8
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
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3 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
4 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
5 let tags = []
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
6 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
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 \ '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
9 \ '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
10 \}]
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11 endfor
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
12 return tags
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
13 endfunc
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 func Test_tagfunc()
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
16 set tagfunc=TagFunc
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
17 new Xfile1
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
18 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
19 write
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 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
22 \ '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
23 \ '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
24
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25 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
26
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
27 tag arbitrary
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
28 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
29 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
30 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
31 5tag 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('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
35 pop
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 tag
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('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
38 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
39 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
40
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41 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
42 execute "normal! \<c-]>"
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('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
44 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
45
24186
4902263c302e patch 8.2.2634: 'tagfunc' does not indicate using a pattern
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
46 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
47 execute "tag /foo$"
4902263c302e patch 8.2.2634: 'tagfunc' does not indicate using a pattern
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
48 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
49 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
50
16447
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
51 set cpt=t
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
52 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
53 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
54 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
55 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
56 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
57
24186
4902263c302e patch 8.2.2634: 'tagfunc' does not indicate using a pattern
Bram Moolenaar <Bram@vim.org>
parents: 22087
diff changeset
58 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
59 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
60 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
61 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
62 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
63
16447
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
64 func BadTagFunc1(...)
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
65 return 0
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
66 endfunc
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
67 func BadTagFunc2(...)
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
68 return [1]
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
69 endfunc
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
70 func BadTagFunc3(...)
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
71 return [{'name': 'foo'}]
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
72 endfunc
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
73
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
74 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
75 try
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
76 tag nothing
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
77 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
78 catch
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
79 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
80 endtry
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
81 exe 'delf' &tagfunc
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
82 endfor
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
83
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
84 func NullTagFunc(...)
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
85 return v:null
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
86 endfunc
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
87 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
88 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
89 delf NullTagFunc
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
90
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
91 bwipe!
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
92 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
93 call delete('Xfile1')
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
94 endfunc
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
95
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
96 " 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
97 " 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
98 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
99 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
100 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
101 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
102 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
103 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
104 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
105 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
106
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 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
108 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
109 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
110 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
111 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
112 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
113
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 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
115 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
116 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
117 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
118 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
119
16447
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
120 " vim: shiftwidth=2 sts=2 expandtab