aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir/test_startup.vim
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/testdir/test_startup.vim')
-rw-r--r--src/nvim/testdir/test_startup.vim165
1 files changed, 93 insertions, 72 deletions
diff --git a/src/nvim/testdir/test_startup.vim b/src/nvim/testdir/test_startup.vim
index 1e70f28a00..9abaca5957 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,17 +235,18 @@ 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))
call assert_equal('Tab page 1', lines[0])
call assert_equal('> [No Name]', lines[1])
call assert_equal('Tab page 2', lines[2])
- call assert_equal(' [No Name]', lines[3])
+ call assert_equal('# [No Name]', lines[3])
endif
if RunVim([], after, '-p foo bar')
@@ -249,7 +255,7 @@ func Test_p_arg()
call assert_equal('Tab page 1', lines[0])
call assert_equal('> foo', lines[1])
call assert_equal('Tab page 2', lines[2])
- call assert_equal(' bar', lines[3])
+ call assert_equal('# bar', lines[3])
endif
call delete('Xtestout')
@@ -265,7 +271,7 @@ func Test_V_arg()
call assert_equal(" verbose=0\n", out)
let out = system(GetVimCommand() . ' --clean -es -X -V2 -c "set verbose?" -cq')
- " call assert_match("sourcing \"$VIMRUNTIME[\\/]defaults\.vim\"\r\nSearching for \"filetype\.vim\".*\n", out)
+ " call assert_match("sourcing \"$VIMRUNTIME[\\/]defaults\.vim\"\r\nline \\d\\+: sourcing \"[^\"]*runtime[\\/]filetype\.vim\".*\n", out)
call assert_match(" verbose=2\n", out)
let out = system(GetVimCommand() . ' --clean -es -X -V15 -c "set verbose?" -cq')
@@ -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)
@@ -572,3 +584,12 @@ func Test_start_with_tabs()
" clean up
call StopVimInTerminal(buf)
endfunc
+
+func Test_v_argv()
+ let out = system(GetVimCommand() . ' -es -V1 -X arg1 --cmd "echo v:argv" --cmd q')
+ let list = split(out, "', '")
+ call assert_match('vim', list[0])
+ let idx = index(list, 'arg1')
+ call assert_true(idx > 2)
+ call assert_equal(['arg1', '--cmd', 'echo v:argv', '--cmd', 'q'']'], list[idx:])
+endfunc