summaryrefslogtreecommitdiffstats
path: root/src/testdir
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-08-07 22:02:30 +0200
committerBram Moolenaar <Bram@vim.org>2017-08-07 22:02:30 +0200
commit75373f38087dd756babdbbf9f14fd4711712c5de (patch)
tree91a9bd88aa98480b99dd750424d6622cc99f1594 /src/testdir
parente20b3eba731bafb97c609dd20a4c378c105acc0d (diff)
patch 8.0.0890: still many old style testsv8.0.0890
Problem: Still many old style tests. Solution: Convert several tests to new style. (Yegappan Lakshmanan)
Diffstat (limited to 'src/testdir')
-rw-r--r--src/testdir/Make_all.mak6
-rw-r--r--src/testdir/Make_vms.mms7
-rw-r--r--src/testdir/test103.in38
-rw-r--r--src/testdir/test103.ok2
-rw-r--r--src/testdir/test107.in38
-rw-r--r--src/testdir/test107.ok4
-rw-r--r--src/testdir/test51.in36
-rw-r--r--src/testdir/test51.ok20
-rw-r--r--src/testdir/test91.in89
-rw-r--r--src/testdir/test91.ok36
-rw-r--r--src/testdir/test_getvar.vim88
-rw-r--r--src/testdir/test_highlight.vim36
-rw-r--r--src/testdir/test_visual.vim31
-rw-r--r--src/testdir/test_window_cmd.vim38
14 files changed, 198 insertions, 271 deletions
diff --git a/src/testdir/Make_all.mak b/src/testdir/Make_all.mak
index f8ce3faf8b..678fc80000 100644
--- a/src/testdir/Make_all.mak
+++ b/src/testdir/Make_all.mak
@@ -38,7 +38,6 @@ SCRIPTS_ALL = \
test44.out \
test45.out \
test48.out \
- test51.out \
test53.out \
test55.out \
test56.out \
@@ -53,12 +52,9 @@ SCRIPTS_ALL = \
test79.out \
test80.out \
test88.out \
- test91.out \
test94.out \
test95.out \
test99.out \
- test103.out \
- test107.out \
test108.out \
test_autoformat_join.out \
test_changelist.out \
@@ -140,6 +136,7 @@ NEW_TESTS = test_arabic.res \
test_file_size.res \
test_fnameescape.res \
test_fold.res \
+ test_getvar.res \
test_gf.res \
test_gn.res \
test_gui.res \
@@ -147,6 +144,7 @@ NEW_TESTS = test_arabic.res \
test_hardcopy.res \
test_help.res \
test_hide.res \
+ test_highlight.res \
test_history.res \
test_hlsearch.res \
test_increment.res \
diff --git a/src/testdir/Make_vms.mms b/src/testdir/Make_vms.mms
index 41b05a0c8d..4181e0b3bc 100644
--- a/src/testdir/Make_vms.mms
+++ b/src/testdir/Make_vms.mms
@@ -81,17 +81,16 @@ SCRIPT = test1.out test3.out test4.out test5.out \
test33.out test34.out test36.out test37.out \
test38.out test39.out test40.out test41.out test42.out \
test43.out test44.out test45.out \
- test48.out test49.out test51.out test53.out test54.out \
+ test48.out test49.out test53.out test54.out \
test55.out test56.out test57.out test60.out \
test64.out \
test66.out test68.out test69.out \
test72.out \
test77a.out test78.out test79.out test80.out \
test88.out \
- test91.out test94.out \
+ test94.out \
test95.out test99.out \
- test103.out \
- test107.out test108.out\
+ test108.out\
test_autocmd_option.out \
test_autoformat_join.out \
test_breakindent.out \
diff --git a/src/testdir/test103.in b/src/testdir/test103.in
deleted file mode 100644
index a4c80844a6..0000000000
--- a/src/testdir/test103.in
+++ /dev/null
@@ -1,38 +0,0 @@
-Test for visual mode not being reset causing E315 error.
-STARTTEST
-:so small.vim
-:set belloff=all
-:enew
-:let g:msg="Everything's fine."
-:function! TriggerTheProblem()
-: " At this point there is no visual selection because :call reset it.
-: " Let's restore the selection:
-: normal gv
-: '<,'>del _
-: try
-: exe "normal \<Esc>"
-: catch /^Vim\%((\a\+)\)\=:E315/
-: echom 'Snap! E315 error!'
-: let g:msg='Snap! E315 error!'
-: endtry
-:endfunction
-:enew
-:setl buftype=nofile
-:call append(line('$'), 'Delete this line.')
-:"
-:"
-:" NOTE: this has to be done by a call to a function because executing :del the
-:" ex-way will require the colon operator which resets the visual mode thus
-:" preventing the problem:
-:"
-GV:call TriggerTheProblem()
-:%del _
-:call append(line('$'), g:msg)
-:w! test.out
-:brewind
-ENDTEST
-
-STARTTEST
-:qa!
-ENDTEST
-
diff --git a/src/testdir/test103.ok b/src/testdir/test103.ok
deleted file mode 100644
index 9ea6dd6eea..0000000000
--- a/src/testdir/test103.ok
+++ /dev/null
@@ -1,2 +0,0 @@
-
-Everything's fine.
diff --git a/src/testdir/test107.in b/src/testdir/test107.in
deleted file mode 100644
index 9143380f18..0000000000
--- a/src/testdir/test107.in
+++ /dev/null
@@ -1,38 +0,0 @@
-Tests for adjusting window and contents vim: set ft=vim :
-
-STARTTEST
-:so small.vim
-:new
-:call setline(1, range(1,256))
-:let r=[]
-:func! GetScreenStr(row)
-: let str = ""
-: for c in range(1,3)
-: let str .= nr2char(screenchar(a:row, c))
-: endfor
-: return str
-:endfunc
-:
-:exe ":norm! \<C-W>t\<C-W>=1Gzt\<C-W>w\<C-W>+"
-:let s3=GetScreenStr(1)
-:wincmd p
-:call add(r, [line("w0"), s3])
-:
-:exe ":norm! \<C-W>t\<C-W>=50Gzt\<C-W>w\<C-W>+"
-:let s3=GetScreenStr(1)
-:wincmd p
-:call add(r, [line("w0"), s3])
-:
-:exe ":norm! \<C-W>t\<C-W>=59Gzt\<C-W>w\<C-W>+"
-:let s3=GetScreenStr(1)
-::wincmd p
-:call add(r, [line("w0"), s3])
-:
-:bwipeout!
-:$put=r
-:call garbagecollect(1)
-:"
-:/^start:/,$wq! test.out
-ENDTEST
-
-start:
diff --git a/src/testdir/test107.ok b/src/testdir/test107.ok
deleted file mode 100644
index 3e0eda1fe7..0000000000
--- a/src/testdir/test107.ok
+++ /dev/null
@@ -1,4 +0,0 @@
-start:
-[1, '1 ']
-[50, '50 ']
-[59, '59 ']
diff --git a/src/testdir/test51.in b/src/testdir/test51.in
deleted file mode 100644
index b66befb05f..0000000000
--- a/src/testdir/test51.in
+++ /dev/null
@@ -1,36 +0,0 @@
-Tests for ":highlight". vim: set ft=vim :
-
-STARTTEST
-:so small.vim
-:" basic test if ":highlight" doesn't crash
-:highlight
-:hi Search
-:" test setting colors.
-:" test clearing one color and all doesn't generate error or warning
-:hi NewGroup term=bold cterm=italic ctermfg=DarkBlue ctermbg=Grey gui= guifg=#00ff00 guibg=Cyan
-:hi Group2 term= cterm=
-:hi Group3 term=underline cterm=bold
-:redir! >test.out
-:hi NewGroup
-:hi Group2
-:hi Group3
-:hi clear NewGroup
-:hi NewGroup
-:hi Group2
-:hi Group2 NONE
-:hi Group2
-:hi clear
-:hi Group3
-:hi Crash term='asdf
-:redir END
-:" filter ctermfg and ctermbg, the numbers depend on the terminal
-:e! test.out
-:%s/ctermfg=\d*/ctermfg=2/
-:%s/ctermbg=\d*/ctermbg=3/
-:" filter out possibly translated error message
-:%s/E475: [^:]*:/E475:/
-:" fix the fileformat
-:set ff&
-:wq!
-ENDTEST
-
diff --git a/src/testdir/test51.ok b/src/testdir/test51.ok
deleted file mode 100644
index be9ff7862c..0000000000
--- a/src/testdir/test51.ok
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-NewGroup xxx term=bold cterm=italic ctermfg=2 ctermbg=3
-
-Group2 xxx cleared
-
-Group3 xxx term=underline cterm=bold
-
-
-NewGroup xxx cleared
-
-Group2 xxx cleared
-
-
-Group2 xxx cleared
-
-
-Group3 xxx cleared
-
-E475: term='asdf
diff --git a/src/testdir/test91.in b/src/testdir/test91.in
deleted file mode 100644
index c184ac3f7c..0000000000
--- a/src/testdir/test91.in
+++ /dev/null
@@ -1,89 +0,0 @@
-Tests for getwinvar(), gettabvar() and gettabwinvar().
-vim: set ft=vim :
-
-STARTTEST
-:so small.vim
-:so mbyte.vim
-:"
-:" Use strings to test for memory leaks.
-:" First, check that in an empty window, gettabvar() returns the correct value
-:let t:testvar='abcd'
-:$put =string(gettabvar(1,'testvar'))
-:$put =string(gettabvar(1,'testvar'))
-:"
-:" test for getwinvar()
-:let w:var_str = "Dance"
-:let def_str = "Chance"
-:$put =string(getwinvar(1, 'var_str'))
-:$put =string(getwinvar(1, 'var_str', def_str))
-:$put =string(getwinvar(1, ''))
-:$put =string(getwinvar(1, '', def_str))
-:unlet w:var_str
-:$put =string(getwinvar(1, 'var_str', def_str))
-:$put =string(getwinvar(1, ''))
-:$put =string(getwinvar(1, '', def_str))
-:$put =string(getwinvar(9, ''))
-:$put =string(getwinvar(9, '', def_str))
-:$put =string(getwinvar(1, '&nu'))
-:$put =string(getwinvar(1, '&nu', 1))
-:unlet def_str
-:"
-:" test for gettabvar()
-:tabnew
-:tabnew
-:let t:var_list = [1, 2, 3]
-:let t:other = 777
-:let def_list = [4, 5, 6, 7]
-:tabrewind
-:$put =string(gettabvar(3, 'var_list'))
-:$put =string(gettabvar(3, 'var_list', def_list))
-:$put =string(gettabvar(3, ''))
-:$put =string(gettabvar(3, '', def_list))
-:tablast
-:unlet t:var_list
-:tabrewind
-:$put =string(gettabvar(3, 'var_list', def_list))
-:$put =string(gettabvar(9, ''))
-:$put =string(gettabvar(9, '', def_list))
-:$put =string(gettabvar(3, '&nu'))
-:$put =string(gettabvar(3, '&nu', def_list))
-:unlet def_list
-:tabonly
-:"
-:" test for gettabwinvar()
-:tabnew
-:tabnew
-:tabprev
-:split
-:split
-:wincmd w
-:vert split
-:wincmd w
-:let w:var_dict = {'dict': 'tabwin'}
-:let def_dict = {'dict2': 'newval'}
-:wincmd b
-:tabrewind
-:$put =string(gettabwinvar(2, 3, 'var_dict'))
-:$put =string(gettabwinvar(2, 3, 'var_dict', def_dict))
-:$put =string(gettabwinvar(2, 3, ''))
-:$put =string(gettabwinvar(2, 3, '', def_dict))
-:tabnext
-:3wincmd w
-:unlet w:var_dict
-:tabrewind
-:$put =string(gettabwinvar(2, 3, 'var_dict', def_dict))
-:$put =string(gettabwinvar(2, 3, ''))
-:$put =string(gettabwinvar(2, 3, '', def_dict))
-:$put =string(gettabwinvar(2, 9, ''))
-:$put =string(gettabwinvar(2, 9, '', def_dict))
-:$put =string(gettabwinvar(9, 3, ''))
-:$put =string(gettabwinvar(9, 3, '', def_dict))
-:unlet def_dict
-:$put =string(gettabwinvar(2, 3, '&nux'))
-:$put =string(gettabwinvar(2, 3, '&nux', 1))
-:tabonly
-:"
-:/^start/,$wq! test.out
-ENDTEST
-
-start:
diff --git a/src/testdir/test91.ok b/src/testdir/test91.ok
deleted file mode 100644
index 2cdf2880ec..0000000000
--- a/src/testdir/test91.ok
+++ /dev/null
@@ -1,36 +0,0 @@
-start:
-'abcd'
-'abcd'
-'Dance'
-'Dance'
-{'var_str': 'Dance'}
-{'var_str': 'Dance'}
-'Chance'
-{}
-{}
-''
-'Chance'
-0
-0
-[1, 2, 3]
-[1, 2, 3]
-{'var_list': [1, 2, 3], 'other': 777}
-{'var_list': [1, 2, 3], 'other': 777}
-[4, 5, 6, 7]
-''
-[4, 5, 6, 7]
-''
-[4, 5, 6, 7]
-{'dict': 'tabwin'}
-{'dict': 'tabwin'}
-{'var_dict': {'dict': 'tabwin'}}
-{'var_dict': {'dict': 'tabwin'}}
-{'dict2': 'newval'}
-{}
-{}
-''
-{'dict2': 'newval'}
-''
-{'dict2': 'newval'}
-''
-1
diff --git a/src/testdir/test_getvar.vim b/src/testdir/test_getvar.vim
new file mode 100644
index 0000000000..0f5dff5d10
--- /dev/null
+++ b/src/testdir/test_getvar.vim
@@ -0,0 +1,88 @@
+" Tests for getwinvar(), gettabvar() and gettabwinvar().
+func Test_var()
+ " Use strings to test for memory leaks. First, check that in an empty
+ " window, gettabvar() returns the correct value
+ let t:testvar='abcd'
+ call assert_equal('abcd', gettabvar(1, 'testvar'))
+ call assert_equal('abcd', gettabvar(1, 'testvar'))
+
+ " test for getwinvar()
+ let w:var_str = "Dance"
+ let def_str = "Chance"
+ call assert_equal('Dance', getwinvar(1, 'var_str'))
+ call assert_equal('Dance', getwinvar(1, 'var_str', def_str))
+ call assert_equal({'var_str': 'Dance'}, getwinvar(1, ''))
+ call assert_equal({'var_str': 'Dance'}, getwinvar(1, '', def_str))
+ unlet w:var_str
+ call assert_equal('Chance', getwinvar(1, 'var_str', def_str))
+ call assert_equal({}, getwinvar(1, ''))
+ call assert_equal({}, getwinvar(1, '', def_str))
+ call assert_equal('', getwinvar(9, ''))
+ call assert_equal('Chance', getwinvar(9, '', def_str))
+ call assert_equal(0, getwinvar(1, '&nu'))
+ call assert_equal(0, getwinvar(1, '&nu', 1))
+ unlet def_str
+
+ " test for gettabvar()
+ tabnew
+ tabnew
+ let t:var_list = [1, 2, 3]
+ let t:other = 777
+ let def_list = [4, 5, 6, 7]
+ tabrewind
+ call assert_equal([1, 2, 3], gettabvar(3, 'var_list'))
+ call assert_equal([1, 2, 3], gettabvar(3, 'var_list', def_list))
+ call assert_equal({'var_list': [1, 2, 3], 'other': 777}, gettabvar(3, ''))
+ call assert_equal({'var_list': [1, 2, 3], 'other': 777},
+ \ gettabvar(3, '', def_list))
+
+ tablast
+ unlet t:var_list
+ tabrewind
+ call assert_equal([4, 5, 6, 7], gettabvar(3, 'var_list', def_list))
+ call assert_equal('', gettabvar(9, ''))
+ call assert_equal([4, 5, 6, 7], gettabvar(9, '', def_list))
+ call assert_equal('', gettabvar(3, '&nu'))
+ call assert_equal([4, 5, 6, 7], gettabvar(3, '&nu', def_list))
+ unlet def_list
+ tabonly
+
+ " test for gettabwinvar()
+ tabnew
+ tabnew
+ tabprev
+ split
+ split
+ wincmd w
+ vert split
+ wincmd w
+ let w:var_dict = {'dict': 'tabwin'}
+ let def_dict = {'dict2': 'newval'}
+ wincmd b
+ tabrewind
+ call assert_equal({'dict': 'tabwin'}, gettabwinvar(2, 3, 'var_dict'))
+ call assert_equal({'dict': 'tabwin'},
+ \ gettabwinvar(2, 3, 'var_dict', def_dict))
+ call assert_equal({'var_dict': {'dict': 'tabwin'}}, gettabwinvar(2, 3, ''))
+ call assert_equal({'var_dict': {'dict': 'tabwin'}},
+ \ gettabwinvar(2, 3, '', def_dict))
+
+ tabnext
+ 3wincmd w
+ unlet w:var_dict
+ tabrewind
+ call assert_equal({'dict2': 'newval'},
+ \ gettabwinvar(2, 3, 'var_dict', def_dict))
+ call assert_equal({}, gettabwinvar(2, 3, ''))
+ call assert_equal({}, gettabwinvar(2, 3, '', def_dict))
+ call assert_equal("", gettabwinvar(2, 9, ''))
+ call assert_equal({'dict2': 'newval'}, gettabwinvar(2, 9, '', def_dict))
+ call assert_equal('', gettabwinvar(9, 3, ''))
+ call assert_equal({'dict2': 'newval'}, gettabwinvar(9, 3, '', def_dict))
+
+ unlet def_dict
+
+ call assert_equal('', gettabwinvar(2, 3, '&nux'))
+ call assert_equal(1, gettabwinvar(2, 3, '&nux', 1))
+ tabonly
+endfunc
diff --git a/src/testdir/test_highlight.vim b/src/testdir/test_highlight.vim
new file mode 100644
index 0000000000..acc29e2f0a
--- /dev/null
+++ b/src/testdir/test_highlight.vim
@@ -0,0 +1,36 @@
+" Tests for ":highlight".
+func Test_highlight()
+ " basic test if ":highlight" doesn't crash
+ highlight
+ hi Search
+
+ " test setting colors.
+ " test clearing one color and all doesn't generate error or warning
+ silent! hi NewGroup term=bold cterm=italic ctermfg=DarkBlue ctermbg=Grey gui= guifg=#00ff00 guibg=Cyan
+ silent! hi Group2 term= cterm=
+ hi Group3 term=underline cterm=bold
+
+ let res = split(execute("hi NewGroup"), "\n")[0]
+ " filter ctermfg and ctermbg, the numbers depend on the terminal
+ let res = substitute(res, 'ctermfg=\d*', 'ctermfg=2', '')
+ let res = substitute(res, 'ctermbg=\d*', 'ctermbg=3', '')
+ call assert_equal("NewGroup xxx term=bold cterm=italic ctermfg=2 ctermbg=3",
+ \ res)
+ call assert_equal("Group2 xxx cleared",
+ \ split(execute("hi Group2"), "\n")[0])
+ call assert_equal("Group3 xxx term=underline cterm=bold",
+ \ split(execute("hi Group3"), "\n")[0])
+
+ hi clear NewGroup
+ call assert_equal("NewGroup xxx cleared",
+ \ split(execute("hi NewGroup"), "\n")[0])
+ call assert_equal("Group2 xxx cleared",
+ \ split(execute("hi Group2"), "\n")[0])
+ hi Group2 NONE
+ call assert_equal("Group2 xxx cleared",
+ \ split(execute("hi Group2"), "\n")[0])
+ hi clear
+ call assert_equal("Group3 xxx cleared",
+ \ split(execute("hi Group3"), "\n")[0])
+ call assert_fails("hi Crash term='asdf", "E475:")
+endfunc
diff --git a/src/testdir/test_visual.vim b/src/testdir/test_visual.vim
index 97b884fe0c..e4bd10079b 100644
--- a/src/testdir/test_visual.vim
+++ b/src/testdir/test_visual.vim
@@ -60,3 +60,34 @@ func Test_Visual_inner_quote()
normal vki'
bwipe!
endfunc
+
+" Test for Visual mode not being reset causing E315 error.
+func TriggerTheProblem()
+ " At this point there is no visual selection because :call reset it.
+ " Let's restore the selection:
+ normal gv
+ '<,'>del _
+ try
+ exe "normal \<Esc>"
+ catch /^Vim\%((\a\+)\)\=:E315/
+ echom 'Snap! E315 error!'
+ let g:msg='Snap! E315 error!'
+ endtry
+endfunc
+
+func Test_visual_mode_reset()
+ set belloff=all
+ enew
+ let g:msg="Everything's fine."
+ enew
+ setl buftype=nofile
+ call append(line('$'), 'Delete this line.')
+
+ " NOTE: this has to be done by a call to a function because executing :del
+ " the ex-way will require the colon operator which resets the visual mode
+ " thus preventing the problem:
+ exe "normal! GV:call TriggerTheProblem()\<CR>"
+ call assert_equal("Everything's fine.", g:msg)
+
+ set belloff&
+endfunc
diff --git a/src/testdir/test_window_cmd.vim b/src/testdir/test_window_cmd.vim
index 2402ecfe00..49bd9fa689 100644
--- a/src/testdir/test_window_cmd.vim
+++ b/src/testdir/test_window_cmd.vim
@@ -416,4 +416,42 @@ func Test_next_split_all()
bwipe!
endfunc
+" Tests for adjusting window and contents
+func GetScreenStr(row)
+ let str = ""
+ for c in range(1,3)
+ let str .= nr2char(screenchar(a:row, c))
+ endfor
+ return str
+endfunc
+
+func Test_window_contents()
+ enew! | only | new
+ call setline(1, range(1,256))
+
+ exe "norm! \<C-W>t\<C-W>=1Gzt\<C-W>w\<C-W>+"
+ redraw
+ let s3=GetScreenStr(1)
+ wincmd p
+ call assert_equal(1, line("w0"))
+ call assert_equal('1 ', s3)
+
+ exe "norm! \<C-W>t\<C-W>=50Gzt\<C-W>w\<C-W>+"
+ redraw
+ let s3=GetScreenStr(1)
+ wincmd p
+ call assert_equal(50, line("w0"))
+ call assert_equal('50 ', s3)
+
+ exe "norm! \<C-W>t\<C-W>=59Gzt\<C-W>w\<C-W>+"
+ redraw
+ let s3=GetScreenStr(1)
+ wincmd p
+ call assert_equal(59, line("w0"))
+ call assert_equal('59 ', s3)
+
+ bwipeout!
+ call test_garbagecollect_now()
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab