Mercurial > vim
view src/testdir/test_help.vim @ 27716:4097434c7c67 v8.2.4384
patch 8.2.4384: Vim9: error message not tested, some code not tested
Commit: https://github.com/vim/vim/commit/bc510064027da8024d59460c9c816aea4ffac096
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Feb 14 21:19:04 2022 +0000
patch 8.2.4384: Vim9: error message not tested, some code not tested
Problem: Vim9: error message not tested, some code not tested.
Solution: Add a couple of test cases. Give an error for a command modifier
without a command.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 14 Feb 2022 22:30:03 +0100 |
parents | 8ed815f061af |
children | 6ba17bf0f86a |
line wrap: on
line source
" Tests for :help source check.vim import './vim9.vim' as v9 func Test_help_restore_snapshot() help set buftype= help edit x help helpclose endfunc func Test_help_errors() call assert_fails('help doesnotexist', 'E149:') call assert_fails('help!', 'E478:') if has('multi_lang') call assert_fails('help help@xy', 'E661:') endif let save_hf = &helpfile set helpfile=help_missing help call assert_equal(1, winnr('$')) call assert_notequal('help', &buftype) let &helpfile = save_hf call assert_fails('help ' . repeat('a', 1048), 'E149:') new set keywordprg=:help call setline(1, " ") call assert_fails('normal VK', 'E349:') bwipe! endfunc func Test_help_expr() help expr-!~? call assert_equal('eval.txt', expand('%:t')) close endfunc func Test_help_keyword() new set keywordprg=:help call setline(1, " Visual ") normal VK call assert_match('^Visual mode', getline('.')) call assert_equal('help', &ft) close bwipe! endfunc func Test_help_local_additions() call mkdir('Xruntime/doc', 'p') call writefile(['*mydoc.txt* my awesome doc'], 'Xruntime/doc/mydoc.txt') call writefile(['*mydoc-ext.txt* my extended awesome doc'], 'Xruntime/doc/mydoc-ext.txt') let rtp_save = &rtp set rtp+=./Xruntime help local-additions let lines = getline(line(".") + 1, search("^$") - 1) call assert_equal([ \ '|mydoc-ext.txt| my extended awesome doc', \ '|mydoc.txt| my awesome doc' \ ], lines) call delete('Xruntime/doc/mydoc-ext.txt') close call mkdir('Xruntime-ja/doc', 'p') call writefile(["local-additions\thelp.jax\t/*local-additions*"], 'Xruntime-ja/doc/tags-ja') call writefile(['*help.txt* This is jax file', '', \ 'LOCAL ADDITIONS: *local-additions*', ''], 'Xruntime-ja/doc/help.jax') call writefile(['*work.txt* This is jax file'], 'Xruntime-ja/doc/work.jax') call writefile(['*work2.txt* This is jax file'], 'Xruntime-ja/doc/work2.jax') set rtp+=./Xruntime-ja help local-additions@en let lines = getline(line(".") + 1, search("^$") - 1) call assert_equal([ \ '|mydoc.txt| my awesome doc' \ ], lines) close help local-additions@ja let lines = getline(line(".") + 1, search("^$") - 1) call assert_equal([ \ '|mydoc.txt| my awesome doc', \ '|help.txt| This is jax file', \ '|work.txt| This is jax file', \ '|work2.txt| This is jax file', \ ], lines) close call delete('Xruntime', 'rf') call delete('Xruntime-ja', 'rf') let &rtp = rtp_save endfunc func Test_help_completion() call feedkeys(":help :undo\<C-A>\<C-B>\"\<CR>", 'tx') call assert_equal('"help :undo :undoj :undol :undojoin :undolist', @:) endfunc " Test for the :helptags command " NOTE: if you run tests as root this will fail. Don't run tests as root! func Test_helptag_cmd() call mkdir('Xdir/a/doc', 'p') " No help file to process in the directory call assert_fails('helptags Xdir', 'E151:') call writefile([], 'Xdir/a/doc/sample.txt') " Test for ++t argument helptags ++t Xdir call assert_equal(["help-tags\ttags\t1"], readfile('Xdir/tags')) call delete('Xdir/tags') " Duplicate tags in the help file call writefile(['*tag1*', '*tag1*', '*tag2*'], 'Xdir/a/doc/sample.txt') call assert_fails('helptags Xdir', 'E154:') call delete('Xdir', 'rf') endfunc func Test_helptag_cmd_readonly() CheckUnix CheckNotRoot " Read-only tags file call mkdir('Xdir/doc', 'p') call writefile([''], 'Xdir/doc/tags') call writefile([], 'Xdir/doc/sample.txt') call setfperm('Xdir/doc/tags', 'r-xr--r--') call assert_fails('helptags Xdir/doc', 'E152:', getfperm('Xdir/doc/tags')) let rtp = &rtp let &rtp = 'Xdir' helptags ALL let &rtp = rtp call delete('Xdir/doc/tags') " No permission to read the help file call mkdir('Xdir/b/doc', 'p') call writefile([], 'Xdir/b/doc/sample.txt') call setfperm('Xdir/b/doc/sample.txt', '-w-------') call assert_fails('helptags Xdir', 'E153:', getfperm('Xdir/b/doc/sample.txt')) call delete('Xdir', 'rf') endfunc " Test for setting the 'helpheight' option in the help window func Test_help_window_height() let &cmdheight = &lines - 24 set helpheight=10 help set helpheight=14 call assert_equal(14, winheight(0)) set helpheight& cmdheight=1 close endfunc func Test_help_long_argument() try exe 'help \%' .. repeat('0', 1021) catch call assert_match("E149:", v:exception) endtry endfunc func Test_help_using_visual_match() let lines =<< trim END call setline(1, ' ') /^ exe "normal \<C-V>\<C-V>" h5\%V] END call v9.CheckScriptFailure(lines, 'E149:') endfunc " vim: shiftwidth=2 sts=2 expandtab