1" Tests for :help 2 3func Test_help_restore_snapshot() 4 help 5 set buftype= 6 help 7 edit x 8 help 9 helpclose 10endfunc 11 12func Test_help_errors() 13 call assert_fails('help doesnotexist', 'E149:') 14 call assert_fails('help!', 'E478:') 15 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:') 27 28 new 29 set keywordprg=:help 30 call setline(1, " ") 31 call assert_fails('normal VK', 'E349:') 32 bwipe! 33endfunc 34 35func Test_help_expr() 36 help expr-!~? 37 call assert_equal('eval.txt', expand('%:t')) 38 close 39endfunc 40 41func 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! 50endfunc 51 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 70 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 75 76" Test for the :helptags command 77func Test_helptag_cmd() 78 call mkdir('Xdir/a/doc', 'p') 79 80 " No help file to process in the directory 81 call assert_fails('helptags Xdir', 'E151:') 82 83 call writefile([], 'Xdir/a/doc/sample.txt') 84 85 " Test for ++t argument 86 helptags ++t Xdir 87 call assert_equal(["help-tags\ttags\t1"], readfile('Xdir/tags')) 88 call delete('Xdir/tags') 89 90 " The following tests fail on FreeBSD for some reason 91 if has('unix') && !has('bsd') 92 " Read-only tags file 93 call mkdir('Xdir/doc', 'p') 94 call writefile([''], 'Xdir/doc/tags') 95 call writefile([], 'Xdir/doc/sample.txt') 96 call setfperm('Xdir/doc/tags', 'r-xr--r--') 97 call assert_fails('helptags Xdir/doc', 'E152:', getfperm('Xdir/doc/tags')) 98 99 let rtp = &rtp 100 let &rtp = 'Xdir' 101 helptags ALL 102 let &rtp = rtp 103 104 call delete('Xdir/doc/tags') 105 106 " No permission to read the help file 107 call setfperm('Xdir/a/doc/sample.txt', '-w-------') 108 call assert_fails('helptags Xdir', 'E153:', getfperm('Xdir/a/doc/sample.txt')) 109 call delete('Xdir/a/doc/sample.txt') 110 call delete('Xdir/tags') 111 endif 112 113 " Duplicate tags in the help file 114 call writefile(['*tag1*', '*tag1*', '*tag2*'], 'Xdir/a/doc/sample.txt') 115 call assert_fails('helptags Xdir', 'E154:') 116 117 call delete('Xdir', 'rf') 118endfunc 119 120" vim: shiftwidth=2 sts=2 expandtab 121