blob: ee5ace8f74d287413975fa42a42aa4995b3c43a6 [file] [log] [blame]
Bram Moolenaar343b8c02017-02-17 12:04:56 +01001" Tests for :help
2
3func Test_help_restore_snapshot()
4 help
5 set buftype=
6 help
7 edit x
8 help
9 helpclose
10endfunc
Bram Moolenaar751ba612017-03-16 22:26:44 +010011
12func Test_help_errors()
13 call assert_fails('help doesnotexist', 'E149:')
14 call assert_fails('help!', 'E478:')
Bram Moolenaarea3db912020-02-02 15:32:13 +010015 if has('multi_lang')
16 call assert_fails('help help@xy', 'E661:')
17 endif
18
19 let save_hf = &helpfile
20 set helpfile=help_missing
21 help
22 call assert_equal(1, winnr('$'))
23 call assert_notequal('help', &buftype)
24 let &helpfile = save_hf
25
26 call assert_fails('help ' . repeat('a', 1048), 'E149:')
Bram Moolenaara4f99f52017-08-26 16:25:32 +020027
28 new
29 set keywordprg=:help
30 call setline(1, " ")
31 call assert_fails('normal VK', 'E349:')
32 bwipe!
33endfunc
34
Bram Moolenaar9ca25082019-10-05 11:30:09 +020035func Test_help_expr()
36 help expr-!~?
37 call assert_equal('eval.txt', expand('%:t'))
38 close
39endfunc
40
Bram Moolenaara4f99f52017-08-26 16:25:32 +020041func Test_help_keyword()
42 new
43 set keywordprg=:help
44 call setline(1, " Visual ")
45 normal VK
46 call assert_match('^Visual mode', getline('.'))
47 call assert_equal('help', &ft)
48 close
49 bwipe!
Bram Moolenaar751ba612017-03-16 22:26:44 +010050endfunc
Bram Moolenaar35c5e812017-12-09 21:10:13 +010051
52func Test_help_local_additions()
53 call mkdir('Xruntime/doc', 'p')
54 call writefile(['*mydoc.txt* my awesome doc'], 'Xruntime/doc/mydoc.txt')
55 call writefile(['*mydoc-ext.txt* my extended awesome doc'], 'Xruntime/doc/mydoc-ext.txt')
56 let rtp_save = &rtp
57 set rtp+=./Xruntime
58 help
59 1
60 call search('mydoc.txt')
61 call assert_equal('|mydoc.txt| my awesome doc', getline('.'))
62 1
63 call search('mydoc-ext.txt')
64 call assert_equal('|mydoc-ext.txt| my extended awesome doc', getline('.'))
65 close
66
67 call delete('Xruntime', 'rf')
68 let &rtp = rtp_save
69endfunc
Bram Moolenaar297610b2019-12-27 17:20:55 +010070
71func Test_help_completion()
72 call feedkeys(":help :undo\<C-A>\<C-B>\"\<CR>", 'tx')
73 call assert_equal('"help :undo :undoj :undol :undojoin :undolist', @:)
74endfunc