1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
|
" Tests for :help! {subject}
func Test_help_tagjump()
help
call assert_equal("help", &filetype)
call assert_true(getline('.') =~ '\*help.txt\*')
helpclose
help |
call assert_equal("help", &filetype)
call assert_true(getline('.') =~ '\*bar\*')
helpclose
help "*
call assert_equal("help", &filetype)
call assert_true(getline('.') =~ '\*quotestar\*')
helpclose
help sm?le
call assert_equal("help", &filetype)
call assert_true(getline('.') =~ '\*:smile\*')
helpclose
help :?
call assert_equal("help", &filetype)
call assert_true(getline('.') =~ '\*:?\*')
helpclose
help -?
call assert_equal("help", &filetype)
call assert_true(getline('.') =~ '\*-?\*')
helpclose
help FileW*Post
call assert_equal("help", &filetype)
call assert_true(getline('.') =~ '\*FileWritePost\*')
helpclose
help `ls`
call assert_equal("help", &filetype)
call assert_true(getline('.') =~ '\*:ls\*')
helpclose
help ^X
call assert_equal("help", &filetype)
call assert_true(getline('.') =~ '\*CTRL-X\*')
helpclose
help i_^_CTRL-D
call assert_equal("help", &filetype)
call assert_true(getline('.') =~ '\*i_^_CTRL-D\*')
helpclose
exec "help \<C-V>"
call assert_equal("help", &filetype)
call assert_true(getline('.') =~ '\*CTRL-V\*')
helpclose
exec "help! ('textwidth'"
call assert_equal("help", &filetype)
call assert_true(getline('.') =~ "\\*'textwidth'\\*")
helpclose
exec "help! ('buflisted'),"
call assert_equal("help", &filetype)
call assert_true(getline('.') =~ "\\*'buflisted'\\*")
helpclose
exec "help! abs({expr})"
call assert_equal("help", &filetype)
call assert_true(getline('.') =~ '\*abs()\*')
helpclose
exec "help! arglistid([{winnr}"
call assert_equal("help", &filetype)
call assert_true(getline('.') =~ '\*arglistid()\*')
helpclose
exec "help! 'autoindent'."
call assert_equal("help", &filetype)
call assert_true(getline('.') =~ "\\*'autoindent'\\*")
helpclose
exec "help! {address}."
call assert_equal("help", &filetype)
call assert_true(getline('.') =~ '\*{address}\*')
helpclose
exusage
call assert_equal("help", &filetype)
call assert_true(getline('.') =~ '\*:index\*')
helpclose
viusage
call assert_equal("help", &filetype)
call assert_true(getline('.') =~ '\*normal-index\*')
helpclose
endfunc
let s:langs = ['en', 'ab', 'ja']
func s:doc_config_setup()
let s:helpfile_save = &helpfile
let &helpfile="Xdir1/doc-en/doc/testdoc.txt"
let s:rtp_save = &rtp
let &rtp="Xdir1/doc-en"
if has('multi_lang')
let s:helplang_save=&helplang
endif
call delete('Xdir1', 'rf')
for lang in s:langs
if lang ==# 'en'
let tagfname = 'tags'
let docfname = 'testdoc.txt'
else
let tagfname = 'tags-' . lang
let docfname = 'testdoc.' . lang . 'x'
endif
let docdir = "Xdir1/doc-" . lang . "/doc"
call mkdir(docdir, "p")
call writefile(["\t*test-char*", "\t*test-col*"], docdir . '/' . docfname)
call writefile(["test-char\t" . docfname . "\t/*test-char*",
\ "test-col\t" . docfname . "\t/*test-col*"],
\ docdir . '/' . tagfname)
endfor
endfunc
func s:doc_config_teardown()
call delete('Xdir1', 'rf')
let &helpfile = s:helpfile_save
let &rtp = s:rtp_save
if has('multi_lang')
let &helplang = s:helplang_save
endif
endfunc
func s:get_help_compl_list(cmd)
return getcompletion(a:cmd, 'help')
endfunc
func Test_help_complete()
try
let list = []
call s:doc_config_setup()
" 'helplang=' and help file lang is 'en'
if has('multi_lang')
set helplang=
endif
let list = s:get_help_compl_list("test")
call assert_equal(['test-col', 'test-char'], list)
if has('multi_lang')
" 'helplang=ab' and help file lang is 'en'
set helplang=ab
let list = s:get_help_compl_list("test")
call assert_equal(['test-col', 'test-char'], list)
" 'helplang=' and help file lang is 'en' and 'ab'
set rtp+=Xdir1/doc-ab
set helplang=
let list = s:get_help_compl_list("test")
call assert_equal(sort(['test-col@en', 'test-col@ab',
\ 'test-char@en', 'test-char@ab']), sort(list))
" 'helplang=ab' and help file lang is 'en' and 'ab'
set helplang=ab
let list = s:get_help_compl_list("test")
call assert_equal(sort(['test-col', 'test-col@en',
\ 'test-char', 'test-char@en']), sort(list))
" 'helplang=' and help file lang is 'en', 'ab' and 'ja'
set rtp+=Xdir1/doc-ja
set helplang=
let list = s:get_help_compl_list("test")
call assert_equal(sort(['test-col@en', 'test-col@ab',
\ 'test-col@ja', 'test-char@en',
\ 'test-char@ab', 'test-char@ja']), sort(list))
" 'helplang=ab' and help file lang is 'en', 'ab' and 'ja'
set helplang=ab
let list = s:get_help_compl_list("test")
call assert_equal(sort(['test-col', 'test-col@en',
\ 'test-col@ja', 'test-char',
\ 'test-char@en', 'test-char@ja']), sort(list))
" 'helplang=ab,ja' and help file lang is 'en', 'ab' and 'ja'
set helplang=ab,ja
let list = s:get_help_compl_list("test")
call assert_equal(sort(['test-col', 'test-col@ja',
\ 'test-col@en', 'test-char',
\ 'test-char@ja', 'test-char@en']), sort(list))
endif
catch
call assert_exception('X')
finally
call s:doc_config_teardown()
endtry
endfunc
func Test_help_respect_current_file_lang()
try
let list = []
call s:doc_config_setup()
if has('multi_lang')
function s:check_help_file_ext(help_keyword, ext)
exec 'help ' . a:help_keyword
call assert_equal(a:ext, expand('%:e'))
call feedkeys("\<C-]>", 'tx')
call assert_equal(a:ext, expand('%:e'))
pop
helpclose
endfunc
set rtp+=Xdir1/doc-ab
set rtp+=Xdir1/doc-ja
set helplang=ab
call s:check_help_file_ext('test-char', 'abx')
call s:check_help_file_ext('test-char@ja', 'jax')
set helplang=ab,ja
call s:check_help_file_ext('test-char@ja', 'jax')
call s:check_help_file_ext('test-char@en', 'txt')
endif
catch
call assert_exception('X')
finally
call s:doc_config_teardown()
endtry
endfunc
" vim: shiftwidth=2 sts=2 expandtab
|