diff options
Diffstat (limited to 'src/nvim/testdir/test_startup.vim')
-rw-r--r-- | src/nvim/testdir/test_startup.vim | 150 |
1 files changed, 81 insertions, 69 deletions
diff --git a/src/nvim/testdir/test_startup.vim b/src/nvim/testdir/test_startup.vim index 1e70f28a00..a38625cca8 100644 --- a/src/nvim/testdir/test_startup.vim +++ b/src/nvim/testdir/test_startup.vim @@ -20,25 +20,27 @@ func Test_after_comes_later() if !has('packages') return endif - let before = [ - \ 'set nocp viminfo+=nviminfo', - \ 'set guioptions+=M', - \ 'let $HOME = "/does/not/exist"', - \ 'set loadplugins', - \ 'set rtp=Xhere,Xafter,Xanother', - \ 'set packpath=Xhere,Xafter', - \ 'set nomore', - \ 'let g:sequence = ""', - \ ] - let after = [ - \ 'redir! > Xtestout', - \ 'scriptnames', - \ 'redir END', - \ 'redir! > Xsequence', - \ 'echo g:sequence', - \ 'redir END', - \ 'quit', - \ ] + let before =<< trim [CODE] + set nocp viminfo+=nviminfo + set guioptions+=M + let $HOME = "/does/not/exist" + set loadplugins + set rtp=Xhere,Xafter,Xanother + set packpath=Xhere,Xafter + set nomore + let g:sequence = "" + [CODE] + + let after =<< trim [CODE] + redir! > Xtestout + scriptnames + redir END + redir! > Xsequence + echo g:sequence + redir END + quit + [CODE] + call mkdir('Xhere/plugin', 'p') call writefile(['let g:sequence .= "here "'], 'Xhere/plugin/here.vim') call mkdir('Xanother/plugin', 'p') @@ -77,15 +79,16 @@ func Test_pack_in_rtp_when_plugins_run() if !has('packages') return endif - let before = [ - \ 'set nocp viminfo+=nviminfo', - \ 'set guioptions+=M', - \ 'let $HOME = "/does/not/exist"', - \ 'set loadplugins', - \ 'set rtp=Xhere', - \ 'set packpath=Xhere', - \ 'set nomore', - \ ] + let before =<< trim [CODE] + set nocp viminfo+=nviminfo + set guioptions+=M + let $HOME = "/does/not/exist" + set loadplugins + set rtp=Xhere + set packpath=Xhere + set nomore + [CODE] + let after = [ \ 'quit', \ ] @@ -133,11 +136,12 @@ endfunc func Test_compatible_args() throw "skipped: Nvim is always 'nocompatible'" - let after = [ - \ 'call writefile([string(&compatible)], "Xtestout")', - \ 'set viminfo+=nviminfo', - \ 'quit', - \ ] + let after =<< trim [CODE] + call writefile([string(&compatible)], "Xtestout") + set viminfo+=nviminfo + quit + [CODE] + if RunVim([], after, '-C') let lines = readfile('Xtestout') call assert_equal('1', lines[0]) @@ -154,14 +158,15 @@ endfunc " Test the -o[N] and -O[N] arguments to open N windows split " horizontally or vertically. func Test_o_arg() - let after = [ - \ 'call writefile([winnr("$"), - \ winheight(1), winheight(2), &lines, - \ winwidth(1), winwidth(2), &columns, - \ bufname(winbufnr(1)), bufname(winbufnr(2))], - \ "Xtestout")', - \ 'qall', - \ ] + let after =<< trim [CODE] + call writefile([winnr("$"), + \ winheight(1), winheight(2), &lines, + \ winwidth(1), winwidth(2), &columns, + \ bufname(winbufnr(1)), bufname(winbufnr(2))], + \ "Xtestout") + qall + [CODE] + if RunVim([], after, '-o2') " Open 2 windows split horizontally. Expect: " - 2 windows @@ -230,10 +235,11 @@ endfunc " Test the -p[N] argument to open N tabpages. func Test_p_arg() - let after = [ - \ 'call writefile(split(execute("tabs"), "\n"), "Xtestout")', - \ 'qall', - \ ] + let after =<< trim [CODE] + call writefile(split(execute("tabs"), "\n"), "Xtestout") + qall + [CODE] + if RunVim([], after, '-p2') let lines = readfile('Xtestout') call assert_equal(4, len(lines)) @@ -290,10 +296,11 @@ endfunc " -M resets 'modifiable' and 'write' " -R sets 'readonly' func Test_m_M_R() - let after = [ - \ 'call writefile([&write, &modifiable, &readonly, &updatecount], "Xtestout")', - \ 'qall', - \ ] + let after =<< trim [CODE] + call writefile([&write, &modifiable, &readonly, &updatecount], "Xtestout") + qall + [CODE] + if RunVim([], after, '') let lines = readfile('Xtestout') call assert_equal(['1', '1', '0', '200'], lines) @@ -316,10 +323,11 @@ endfunc " Test the -A, -F and -H arguments (Arabic, Farsi and Hebrew modes). func Test_A_F_H_arg() - let after = [ - \ 'call writefile([&rightleft, &arabic, 0, &hkmap], "Xtestout")', - \ 'qall', - \ ] + let after =<< trim [CODE] + call writefile([&rightleft, &arabic, 0, &hkmap], "Xtestout") + qall + [CODE] + " Use silent Ex mode to avoid the hit-Enter prompt for the warning that " 'encoding' is not utf-8. if has('arabic') && &encoding == 'utf-8' && RunVim([], after, '-e -s -A') @@ -423,10 +431,11 @@ func Test_invalid_args() endfunc func Test_file_args() - let after = [ - \ 'call writefile(argv(), "Xtestout")', - \ 'qall', - \ ] + let after =<< trim [CODE] + call writefile(argv(), "Xtestout") + qall + [CODE] + if RunVim([], after, '') let lines = readfile('Xtestout') call assert_equal(0, len(lines)) @@ -487,10 +496,11 @@ func Test_startuptime() endfunc func Test_read_stdin() - let after = [ - \ 'write Xtestout', - \ 'quit!', - \ ] + let after =<< trim [CODE] + write Xtestout + quit! + [CODE] + if RunVimPiped([], after, '-', 'echo something | ') let lines = readfile('Xtestout') " MS-Windows adds a space after the word @@ -540,20 +550,22 @@ endfunc func Test_zzz_startinsert() " Test :startinsert call writefile(['123456'], 'Xtestout') - let after = [ - \ ':startinsert', - \ 'call feedkeys("foobar\<c-o>:wq\<cr>","t")' - \ ] + let after =<< trim [CODE] + :startinsert + call feedkeys("foobar\<c-o>:wq\<cr>","t") + [CODE] + if RunVim([], after, 'Xtestout') let lines = readfile('Xtestout') call assert_equal(['foobar123456'], lines) endif " Test :startinsert! call writefile(['123456'], 'Xtestout') - let after = [ - \ ':startinsert!', - \ 'call feedkeys("foobar\<c-o>:wq\<cr>","t")' - \ ] + let after =<< trim [CODE] + :startinsert! + call feedkeys("foobar\<c-o>:wq\<cr>","t") + [CODE] + if RunVim([], after, 'Xtestout') let lines = readfile('Xtestout') call assert_equal(['123456foobar'], lines) |