blob: 5dd937a935cd7303866d8790069d456b4b637f4d [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 Moolenaara4f99f52017-08-26 16:25:32 +020015
16 new
17 set keywordprg=:help
18 call setline(1, " ")
19 call assert_fails('normal VK', 'E349:')
20 bwipe!
21endfunc
22
Bram Moolenaar9ca25082019-10-05 11:30:09 +020023func Test_help_expr()
24 help expr-!~?
25 call assert_equal('eval.txt', expand('%:t'))
26 close
27endfunc
28
Bram Moolenaara4f99f52017-08-26 16:25:32 +020029func Test_help_keyword()
30 new
31 set keywordprg=:help
32 call setline(1, " Visual ")
33 normal VK
34 call assert_match('^Visual mode', getline('.'))
35 call assert_equal('help', &ft)
36 close
37 bwipe!
Bram Moolenaar751ba612017-03-16 22:26:44 +010038endfunc
Bram Moolenaar35c5e812017-12-09 21:10:13 +010039
40func Test_help_local_additions()
41 call mkdir('Xruntime/doc', 'p')
42 call writefile(['*mydoc.txt* my awesome doc'], 'Xruntime/doc/mydoc.txt')
43 call writefile(['*mydoc-ext.txt* my extended awesome doc'], 'Xruntime/doc/mydoc-ext.txt')
44 let rtp_save = &rtp
45 set rtp+=./Xruntime
46 help
47 1
48 call search('mydoc.txt')
49 call assert_equal('|mydoc.txt| my awesome doc', getline('.'))
50 1
51 call search('mydoc-ext.txt')
52 call assert_equal('|mydoc-ext.txt| my extended awesome doc', getline('.'))
53 close
54
55 call delete('Xruntime', 'rf')
56 let &rtp = rtp_save
57endfunc