mirror of
				https://github.com/vim/vim.git
				synced 2025-10-30 09:47:20 -04:00 
			
		
		
		
	patch 8.2.0448: various functions not properly tested
Problem:    Various functions not properly tested.
Solution:   Add more tests, especially for failures. (Yegappan Lakshmanan,
            closes #5843)
			
			
This commit is contained in:
		| @@ -8802,6 +8802,7 @@ setqflist({list} [, {action} [, {what}]])		*setqflist()* | |||||||
| 							*setreg()* | 							*setreg()* | ||||||
| setreg({regname}, {value} [, {options}]) | setreg({regname}, {value} [, {options}]) | ||||||
| 		Set the register {regname} to {value}. | 		Set the register {regname} to {value}. | ||||||
|  | 		If {regname} is "" or "@", the unnamed register '"' is used. | ||||||
| 		{value} may be any value returned by |getreg()|, including | 		{value} may be any value returned by |getreg()|, including | ||||||
| 		a |List|. | 		a |List|. | ||||||
| 		If {options} contains "a" or {regname} is upper case, | 		If {options} contains "a" or {regname} is upper case, | ||||||
|   | |||||||
| @@ -286,6 +286,8 @@ func Test_blob_index() | |||||||
|   call assert_equal(3, 0z11110111->index(0x11, 2)) |   call assert_equal(3, 0z11110111->index(0x11, 2)) | ||||||
|   call assert_equal(2, index(0z11111111, 0x11, -2)) |   call assert_equal(2, index(0z11111111, 0x11, -2)) | ||||||
|   call assert_equal(3, index(0z11110111, 0x11, -2)) |   call assert_equal(3, index(0z11110111, 0x11, -2)) | ||||||
|  |   call assert_equal(0, index(0z11110111, 0x11, -10)) | ||||||
|  |   call assert_fails("echo index(0z11110111, 0x11, [])", 'E745:') | ||||||
|  |  | ||||||
|   call assert_fails('call index("asdf", 0)', 'E897:') |   call assert_fails('call index("asdf", 0)', 'E897:') | ||||||
| endfunc | endfunc | ||||||
| @@ -331,3 +333,5 @@ func Test_blob_sort() | |||||||
|     call assert_fails('call sort(["abc", 0z11], "f")', 'E702:') |     call assert_fails('call sort(["abc", 0z11], "f")', 'E702:') | ||||||
|   endif |   endif | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
|  | " vim: shiftwidth=2 sts=2 expandtab | ||||||
|   | |||||||
| @@ -417,6 +417,7 @@ func Test_breakindent11() | |||||||
|   let width = strlen(text[1:]) + indent(2) + strlen(&sbr) * 3 " text wraps 3 times |   let width = strlen(text[1:]) + indent(2) + strlen(&sbr) * 3 " text wraps 3 times | ||||||
|   call assert_equal(width, strdisplaywidth(text)) |   call assert_equal(width, strdisplaywidth(text)) | ||||||
|   call s:close_windows('set sbr=') |   call s:close_windows('set sbr=') | ||||||
|  |   call assert_equal(4, strdisplaywidth("\t", 4)) | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
| func Test_breakindent11_vartabs() | func Test_breakindent11_vartabs() | ||||||
| @@ -694,3 +695,5 @@ func Test_breakindent19_sbr_nextpage() | |||||||
|   call s:compare_lines(expect, lines) |   call s:compare_lines(expect, lines) | ||||||
|   call s:close_windows('set breakindent& briopt& sbr&') |   call s:close_windows('set breakindent& briopt& sbr&') | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
|  | " vim: shiftwidth=2 sts=2 expandtab | ||||||
|   | |||||||
| @@ -29,6 +29,8 @@ func Test_charsearch() | |||||||
|   set cpo-=; |   set cpo-=; | ||||||
|   normal! ;;p |   normal! ;;p | ||||||
|   call assert_equal('ZabcdeZfghijkZZemnokqretkZvwxyz', getline(3)) |   call assert_equal('ZabcdeZfghijkZZemnokqretkZvwxyz', getline(3)) | ||||||
|  |  | ||||||
|  |   call assert_fails("call setcharsearch([])", 'E715:') | ||||||
|   enew! |   enew! | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
|   | |||||||
| @@ -98,7 +98,11 @@ func Test_client_server() | |||||||
|       call job_stop(job, 'kill') |       call job_stop(job, 'kill') | ||||||
|     endif |     endif | ||||||
|   endtry |   endtry | ||||||
|  |  | ||||||
|  |   call assert_fails("let x=remote_peek([])", 'E730:') | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
| " Uncomment this line to get a debugging log | " Uncomment this line to get a debugging log | ||||||
| " call ch_logfile('channellog', 'w') | " call ch_logfile('channellog', 'w') | ||||||
|  |  | ||||||
|  | " vim: shiftwidth=2 sts=2 expandtab | ||||||
|   | |||||||
| @@ -68,6 +68,11 @@ func Test_complete_wildmenu() | |||||||
|   call assert_equal('"e Xtestfile3 Xtestfile4', @:) |   call assert_equal('"e Xtestfile3 Xtestfile4', @:) | ||||||
|   cd - |   cd - | ||||||
|  |  | ||||||
|  |   cnoremap <expr> <F2> wildmenumode() | ||||||
|  |   call feedkeys(":cd Xdir\<Tab>\<F2>\<C-B>\"\<CR>", 'tx') | ||||||
|  |   call assert_equal('"cd Xdir1/1', @:) | ||||||
|  |   cunmap <F2> | ||||||
|  |  | ||||||
|   " cleanup |   " cleanup | ||||||
|   %bwipe |   %bwipe | ||||||
|   call delete('Xdir1/Xdir2/Xtestfile4') |   call delete('Xdir1/Xdir2/Xtestfile4') | ||||||
|   | |||||||
| @@ -68,6 +68,10 @@ func Test_exists() | |||||||
|   " Existing environment variable |   " Existing environment variable | ||||||
|   let $EDITOR_NAME = 'Vim Editor' |   let $EDITOR_NAME = 'Vim Editor' | ||||||
|   call assert_equal(1, exists('$EDITOR_NAME')) |   call assert_equal(1, exists('$EDITOR_NAME')) | ||||||
|  |   if has('unix') | ||||||
|  |     " ${name} environment variables are supported only on Unix-like systems | ||||||
|  |     call assert_equal(1, exists('${VIM}')) | ||||||
|  |   endif | ||||||
|   " Non-existing environment variable |   " Non-existing environment variable | ||||||
|   call assert_equal(0, exists('$NON_ENV_VAR')) |   call assert_equal(0, exists('$NON_ENV_VAR')) | ||||||
|  |  | ||||||
| @@ -323,3 +327,5 @@ endfunc | |||||||
| func Test_exists_funcarg() | func Test_exists_funcarg() | ||||||
|   call FuncArg_Tests("arg1", "arg2") |   call FuncArg_Tests("arg1", "arg2") | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
|  | " vim: shiftwidth=2 sts=2 expandtab | ||||||
|   | |||||||
| @@ -83,6 +83,7 @@ func Test_expand_wildignore() | |||||||
|   call assert_equal('test_expand_func.vim', expand('test_expand_func.vim', 1)) |   call assert_equal('test_expand_func.vim', expand('test_expand_func.vim', 1)) | ||||||
|   call assert_equal(['test_expand_func.vim'], |   call assert_equal(['test_expand_func.vim'], | ||||||
|         \ expand('test_expand_func.vim', 1, 1)) |         \ expand('test_expand_func.vim', 1, 1)) | ||||||
|  |   call assert_fails("call expand('*', [])", 'E745:') | ||||||
|   set wildignore& |   set wildignore& | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
|   | |||||||
| @@ -59,6 +59,8 @@ func Test_strgetchar() | |||||||
|   call assert_equal(-1, strgetchar('axb', -1)) |   call assert_equal(-1, strgetchar('axb', -1)) | ||||||
|   call assert_equal(-1, strgetchar('axb', 3)) |   call assert_equal(-1, strgetchar('axb', 3)) | ||||||
|   call assert_equal(-1, strgetchar('', 0)) |   call assert_equal(-1, strgetchar('', 0)) | ||||||
|  |   call assert_fails("let c=strgetchar([], 1)", 'E730:') | ||||||
|  |   call assert_fails("let c=strgetchar('axb', [])", 'E745:') | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
| func Test_strcharpart() | func Test_strcharpart() | ||||||
| @@ -444,6 +446,9 @@ func Test_substitute_expr() | |||||||
|   endfunc |   endfunc | ||||||
|   " recursive call works |   " recursive call works | ||||||
|   call assert_equal('-y-x-', substitute('xxx', 'x\(.\)x', {-> '-' . Recurse() . '-' . submatch(1) . '-'}, '')) |   call assert_equal('-y-x-', substitute('xxx', 'x\(.\)x', {-> '-' . Recurse() . '-' . submatch(1) . '-'}, '')) | ||||||
|  |  | ||||||
|  |   call assert_fails("let s=submatch([])", 'E745:') | ||||||
|  |   call assert_fails("let s=submatch(2, [])", 'E745:') | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
| func Test_invalid_submatch() | func Test_invalid_submatch() | ||||||
|   | |||||||
| @@ -21,4 +21,10 @@ func Test_file_perm() | |||||||
|  |  | ||||||
|   call assert_equal(1, setfperm('Xtest', 'rwx------')) |   call assert_equal(1, setfperm('Xtest', 'rwx------')) | ||||||
|   call delete('Xtest') |   call delete('Xtest') | ||||||
|  |  | ||||||
|  |   call assert_fails("call setfperm(['Xfile'], 'rw-rw-rw-')", 'E730:') | ||||||
|  |   call assert_fails("call setfperm('Xfile', [])", 'E730:') | ||||||
|  |   call assert_fails("call setfperm('Xfile', 'rwxrwxrwxrw')", 'E475:') | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
|  | " vim: shiftwidth=2 sts=2 expandtab | ||||||
|   | |||||||
| @@ -24,8 +24,18 @@ func Test_has() | |||||||
|   call assert_equal(1, has('eval')) |   call assert_equal(1, has('eval')) | ||||||
|   call assert_equal(1, has('eval', 1)) |   call assert_equal(1, has('eval', 1)) | ||||||
|  |  | ||||||
|  |   if has('unix') | ||||||
|  |     call assert_equal(1, or(has('ttyin'), 1)) | ||||||
|  |     call assert_equal(0, and(has('ttyout'), 0)) | ||||||
|  |     call assert_equal(1, has('multi_byte_encoding')) | ||||||
|  |   endif | ||||||
|  |  | ||||||
|   call assert_equal(0, has('nonexistent')) |   call assert_equal(0, has('nonexistent')) | ||||||
|   call assert_equal(0, has('nonexistent', 1)) |   call assert_equal(0, has('nonexistent', 1)) | ||||||
|  |  | ||||||
|  |   " Will we ever have patch 9999? | ||||||
|  |   let ver = 'patch-' .. v:version / 100 .. '.' .. v:version % 100 .. '.9999' | ||||||
|  |   call assert_equal(0, has(ver)) | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
| func Test_empty() | func Test_empty() | ||||||
| @@ -476,6 +486,8 @@ func Test_strpart() | |||||||
|   call assert_equal('abcdefg', 'abcdefg'->strpart(-2)) |   call assert_equal('abcdefg', 'abcdefg'->strpart(-2)) | ||||||
|   call assert_equal('fg', strpart('abcdefg', 5, 4)) |   call assert_equal('fg', strpart('abcdefg', 5, 4)) | ||||||
|   call assert_equal('defg', strpart('abcdefg', 3)) |   call assert_equal('defg', strpart('abcdefg', 3)) | ||||||
|  |   call assert_equal('', strpart('abcdefg', 10)) | ||||||
|  |   call assert_fails("let s=strpart('abcdef', [])", 'E745:') | ||||||
|  |  | ||||||
|   call assert_equal('lép', strpart('éléphant', 2, 4)) |   call assert_equal('lép', strpart('éléphant', 2, 4)) | ||||||
|   call assert_equal('léphant', strpart('éléphant', 2)) |   call assert_equal('léphant', strpart('éléphant', 2)) | ||||||
| @@ -629,6 +641,15 @@ endfunc | |||||||
| func Test_tr() | func Test_tr() | ||||||
|   call assert_equal('foo', tr('bar', 'bar', 'foo')) |   call assert_equal('foo', tr('bar', 'bar', 'foo')) | ||||||
|   call assert_equal('zxy', 'cab'->tr('abc', 'xyz')) |   call assert_equal('zxy', 'cab'->tr('abc', 'xyz')) | ||||||
|  |   call assert_fails("let s=tr([], 'abc', 'def')", 'E730:') | ||||||
|  |   call assert_fails("let s=tr('abc', [], 'def')", 'E730:') | ||||||
|  |   call assert_fails("let s=tr('abc', 'abc', [])", 'E730:') | ||||||
|  |   call assert_fails("let s=tr('abcd', 'abcd', 'def')", 'E475:') | ||||||
|  |   set encoding=latin1 | ||||||
|  |   call assert_fails("let s=tr('abcd', 'abcd', 'def')", 'E475:') | ||||||
|  |   call assert_equal('hEllO', tr('hello', 'eo', 'EO')) | ||||||
|  |   call assert_equal('hello', tr('hello', 'xy', 'ab')) | ||||||
|  |   set encoding=utf8 | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
| " Tests for the mode() function | " Tests for the mode() function | ||||||
| @@ -840,6 +861,8 @@ func Test_stridx() | |||||||
|   call assert_equal(-1, stridx('hello', 'l', 10)) |   call assert_equal(-1, stridx('hello', 'l', 10)) | ||||||
|   call assert_equal(2,  stridx('hello', 'll')) |   call assert_equal(2,  stridx('hello', 'll')) | ||||||
|   call assert_equal(-1, stridx('hello', 'hello world')) |   call assert_equal(-1, stridx('hello', 'hello world')) | ||||||
|  |   call assert_fails("let n=stridx('hello', [])", 'E730:') | ||||||
|  |   call assert_fails("let n=stridx([], 'l')", 'E730:') | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
| func Test_strridx() | func Test_strridx() | ||||||
| @@ -856,6 +879,8 @@ func Test_strridx() | |||||||
|   call assert_equal(-1, strridx('hello', 'l', -1)) |   call assert_equal(-1, strridx('hello', 'l', -1)) | ||||||
|   call assert_equal(2,  strridx('hello', 'll')) |   call assert_equal(2,  strridx('hello', 'll')) | ||||||
|   call assert_equal(-1, strridx('hello', 'hello world')) |   call assert_equal(-1, strridx('hello', 'hello world')) | ||||||
|  |   call assert_fails("let n=strridx('hello', [])", 'E730:') | ||||||
|  |   call assert_fails("let n=strridx([], 'l')", 'E730:') | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
| func Test_match_func() | func Test_match_func() | ||||||
| @@ -865,6 +890,11 @@ func Test_match_func() | |||||||
|   call assert_equal(-1, match('testing', 'ing', 8)) |   call assert_equal(-1, match('testing', 'ing', 8)) | ||||||
|   call assert_equal(1, match(['vim', 'testing', 'execute'], 'ing')) |   call assert_equal(1, match(['vim', 'testing', 'execute'], 'ing')) | ||||||
|   call assert_equal(-1, match(['vim', 'testing', 'execute'], 'img')) |   call assert_equal(-1, match(['vim', 'testing', 'execute'], 'img')) | ||||||
|  |   call assert_fails("let x=match('vim', [])", 'E730:') | ||||||
|  |   call assert_equal(3, match(['a', 'b', 'c', 'a'], 'a', 1)) | ||||||
|  |   call assert_equal(-1, match(['a', 'b', 'c', 'a'], 'a', 5)) | ||||||
|  |   call assert_equal(4,  match('testing', 'ing', -1)) | ||||||
|  |   call assert_fails("let x=match('testing', 'ing', 0, [])", 'E745:') | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
| func Test_matchend() | func Test_matchend() | ||||||
| @@ -971,6 +1001,7 @@ func Test_byte2line_line2byte() | |||||||
|   bw! |   bw! | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
|  | " Test for byteidx() and byteidxcomp() functions | ||||||
| func Test_byteidx() | func Test_byteidx() | ||||||
|   let a = '.é.' " one char of two bytes |   let a = '.é.' " one char of two bytes | ||||||
|   call assert_equal(0, byteidx(a, 0)) |   call assert_equal(0, byteidx(a, 0)) | ||||||
| @@ -990,6 +1021,7 @@ func Test_byteidx() | |||||||
|   call assert_equal(4, b->byteidx(2)) |   call assert_equal(4, b->byteidx(2)) | ||||||
|   call assert_equal(5, b->byteidx(3)) |   call assert_equal(5, b->byteidx(3)) | ||||||
|   call assert_equal(-1, b->byteidx(4)) |   call assert_equal(-1, b->byteidx(4)) | ||||||
|  |   call assert_fails("call byteidx([], 0)", 'E730:') | ||||||
|  |  | ||||||
|   call assert_equal(0, b->byteidxcomp(0)) |   call assert_equal(0, b->byteidxcomp(0)) | ||||||
|   call assert_equal(1, b->byteidxcomp(1)) |   call assert_equal(1, b->byteidxcomp(1)) | ||||||
| @@ -997,6 +1029,7 @@ func Test_byteidx() | |||||||
|   call assert_equal(4, b->byteidxcomp(3)) |   call assert_equal(4, b->byteidxcomp(3)) | ||||||
|   call assert_equal(5, b->byteidxcomp(4)) |   call assert_equal(5, b->byteidxcomp(4)) | ||||||
|   call assert_equal(-1, b->byteidxcomp(5)) |   call assert_equal(-1, b->byteidxcomp(5)) | ||||||
|  |   call assert_fails("call byteidxcomp([], 0)", 'E730:') | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
| func Test_count() | func Test_count() | ||||||
| @@ -1177,6 +1210,22 @@ func Test_col() | |||||||
|   xunmap <F2> |   xunmap <F2> | ||||||
|   delfunc T |   delfunc T | ||||||
|  |  | ||||||
|  |   " Test for the visual line start and end marks '< and '> | ||||||
|  |   call setline(1, ['one', 'one two', 'one two three']) | ||||||
|  |   "normal! ggVG | ||||||
|  |   call feedkeys("ggVG\<Esc>", 'xt') | ||||||
|  |   call assert_equal(1, col("'<")) | ||||||
|  |   call assert_equal(14, col("'>")) | ||||||
|  |   " Delete the last line of the visually selected region | ||||||
|  |   $d | ||||||
|  |   call assert_notequal(14, col("'>")) | ||||||
|  |  | ||||||
|  |   " Test with 'virtualedit' | ||||||
|  |   set virtualedit=all | ||||||
|  |   call cursor(1, 10) | ||||||
|  |   call assert_equal(4, col('.')) | ||||||
|  |   set virtualedit& | ||||||
|  |  | ||||||
|   bw! |   bw! | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
| @@ -1343,6 +1392,8 @@ func Test_trim() | |||||||
|  |  | ||||||
|   let chars = join(map(range(1, 0x20) + [0xa0], {n -> n->nr2char()}), '') |   let chars = join(map(range(1, 0x20) + [0xa0], {n -> n->nr2char()}), '') | ||||||
|   call assert_equal("x", trim(chars . "x" . chars)) |   call assert_equal("x", trim(chars . "x" . chars)) | ||||||
|  |  | ||||||
|  |   call assert_fails('let c=trim([])', 'E730:') | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
| " Test for reg_recording() and reg_executing() | " Test for reg_recording() and reg_executing() | ||||||
| @@ -1726,6 +1777,9 @@ endfunc | |||||||
| func Test_char2nr() | func Test_char2nr() | ||||||
|   call assert_equal(12354, char2nr('あ', 1)) |   call assert_equal(12354, char2nr('あ', 1)) | ||||||
|   call assert_equal(120, 'x'->char2nr()) |   call assert_equal(120, 'x'->char2nr()) | ||||||
|  |   set encoding=latin1 | ||||||
|  |   call assert_equal(120, 'x'->char2nr()) | ||||||
|  |   set encoding=utf-8 | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
| func Test_eventhandler() | func Test_eventhandler() | ||||||
| @@ -1931,6 +1985,7 @@ func Test_range() | |||||||
|  |  | ||||||
|   " index() |   " index() | ||||||
|   call assert_equal(1, index(range(1, 5), 2)) |   call assert_equal(1, index(range(1, 5), 2)) | ||||||
|  |   call assert_fails("echo index([1, 2], 1, [])", 'E745:') | ||||||
|  |  | ||||||
|   " inputlist() |   " inputlist() | ||||||
|   call feedkeys(":let result = inputlist(range(10))\<CR>1\<CR>", 'x') |   call feedkeys(":let result = inputlist(range(10))\<CR>1\<CR>", 'x') | ||||||
| @@ -2089,6 +2144,11 @@ func Test_range() | |||||||
|  |  | ||||||
|   " uniq() |   " uniq() | ||||||
|   call assert_equal([0, 1, 2, 3, 4], uniq(range(5))) |   call assert_equal([0, 1, 2, 3, 4], uniq(range(5))) | ||||||
|  |  | ||||||
|  |   " errors | ||||||
|  |   call assert_fails('let x=range(2, 8, 0)', 'E726:') | ||||||
|  |   call assert_fails('let x=range(3, 1)', 'E727:') | ||||||
|  |   call assert_fails('let x=range(1, 3, -2)', 'E727:') | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
| func Test_echoraw() | func Test_echoraw() | ||||||
| @@ -2107,4 +2167,25 @@ func Test_echoraw() | |||||||
|   call delete('XTest_echoraw') |   call delete('XTest_echoraw') | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
|  | " Test for the eval() function | ||||||
|  | func Test_eval() | ||||||
|  |   call assert_fails("call eval('5 a')", 'E488:') | ||||||
|  | endfunc | ||||||
|  |  | ||||||
|  | " Test for the nr2char() function | ||||||
|  | func Test_nr2char() | ||||||
|  |   set encoding=latin1 | ||||||
|  |   call assert_equal('@', nr2char(64)) | ||||||
|  |   set encoding=utf8 | ||||||
|  |   call assert_equal('a', nr2char(97, 1)) | ||||||
|  |   call assert_equal('a', nr2char(97, 0)) | ||||||
|  | endfunc | ||||||
|  |  | ||||||
|  | " Test for screenattr(), screenchar() and screenchars() functions | ||||||
|  | func Test_screen_functions() | ||||||
|  |   call assert_equal(-1, screenattr(-1, -1)) | ||||||
|  |   call assert_equal(-1, screenchar(-1, -1)) | ||||||
|  |   call assert_equal([], screenchars(-1, -1)) | ||||||
|  | endfunc | ||||||
|  |  | ||||||
| " vim: shiftwidth=2 sts=2 expandtab | " vim: shiftwidth=2 sts=2 expandtab | ||||||
|   | |||||||
| @@ -75,6 +75,7 @@ func Test_getfontname_with_arg() | |||||||
|   elseif has('gui_gtk2') || has('gui_gnome') || has('gui_gtk3') |   elseif has('gui_gtk2') || has('gui_gnome') || has('gui_gtk3') | ||||||
|     " Invalid font name. The result should be the name plus the default size. |     " Invalid font name. The result should be the name plus the default size. | ||||||
|     call assert_equal('notexist 10', getfontname('notexist')) |     call assert_equal('notexist 10', getfontname('notexist')) | ||||||
|  |     call assert_equal('', getfontname('*')) | ||||||
|  |  | ||||||
|     " Valid font name. This is usually the real name of Monospace by default. |     " Valid font name. This is usually the real name of Monospace by default. | ||||||
|     let fname = 'Bitstream Vera Sans Mono 12' |     let fname = 'Bitstream Vera Sans Mono 12' | ||||||
| @@ -825,3 +826,5 @@ func Test_gui_dash_y() | |||||||
|   call delete('Xscriptgui') |   call delete('Xscriptgui') | ||||||
|   call delete('Xtestgui') |   call delete('Xtestgui') | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
|  | " vim: shiftwidth=2 sts=2 expandtab | ||||||
|   | |||||||
| @@ -302,6 +302,7 @@ func Test_dict_deepcopy() | |||||||
|   let l[1] = l2 |   let l[1] = l2 | ||||||
|   let l3 = deepcopy(l2) |   let l3 = deepcopy(l2) | ||||||
|   call assert_true(l3[1] is l3[2]) |   call assert_true(l3[1] is l3[2]) | ||||||
|  |   call assert_fails("call deepcopy([1, 2], 2)", 'E474:') | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
| " Locked variables | " Locked variables | ||||||
| @@ -381,6 +382,11 @@ func Test_list_locked_var() | |||||||
|       call assert_equal(expected[depth][u][1], ps) |       call assert_equal(expected[depth][u][1], ps) | ||||||
|     endfor |     endfor | ||||||
|   endfor |   endfor | ||||||
|  |   call assert_fails("let x=islocked('a b')", 'E488:') | ||||||
|  |   let mylist = [1, 2, 3] | ||||||
|  |   call assert_fails("let x = islocked('mylist[1:2]')", 'E786:') | ||||||
|  |   let mydict = {'k' : 'v'} | ||||||
|  |   call assert_fails("let x = islocked('mydict.a')", 'E716:') | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
| " Unletting locked variables | " Unletting locked variables | ||||||
| @@ -629,7 +635,7 @@ func Test_reverse_sort_uniq() | |||||||
|   call assert_fails('call reverse("")', 'E899:') |   call assert_fails('call reverse("")', 'E899:') | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
| " splitting a string to a List | " splitting a string to a List using split() | ||||||
| func Test_str_split() | func Test_str_split() | ||||||
|   call assert_equal(['aa', 'bb'], split('  aa  bb ')) |   call assert_equal(['aa', 'bb'], split('  aa  bb ')) | ||||||
|   call assert_equal(['aa', 'bb'], split('  aa  bb  ', '\W\+', 0)) |   call assert_equal(['aa', 'bb'], split('  aa  bb  ', '\W\+', 0)) | ||||||
| @@ -640,6 +646,8 @@ func Test_str_split() | |||||||
|   call assert_equal(['aa', '', 'bb', 'cc', ''], split('aa,,bb, cc,', ',\s*', 1)) |   call assert_equal(['aa', '', 'bb', 'cc', ''], split('aa,,bb, cc,', ',\s*', 1)) | ||||||
|   call assert_equal(['a', 'b', 'c'], split('abc', '\zs')) |   call assert_equal(['a', 'b', 'c'], split('abc', '\zs')) | ||||||
|   call assert_equal(['', 'a', '', 'b', '', 'c', ''], split('abc', '\zs', 1)) |   call assert_equal(['', 'a', '', 'b', '', 'c', ''], split('abc', '\zs', 1)) | ||||||
|  |   call assert_fails("call split('abc', [])", 'E730:') | ||||||
|  |   call assert_fails("call split('abc', 'b', [])", 'E745:') | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
| " compare recursively linked list and dict | " compare recursively linked list and dict | ||||||
|   | |||||||
| @@ -90,6 +90,8 @@ func Test_setpos() | |||||||
|   call setpos('.', [0, 1, -1, 0]) |   call setpos('.', [0, 1, -1, 0]) | ||||||
|   call assert_equal([2, 2], [line('.'), col('.')]) |   call assert_equal([2, 2], [line('.'), col('.')]) | ||||||
|  |  | ||||||
|  |   call assert_fails("call setpos('ab', [0, 1, 1, 0])", 'E474:') | ||||||
|  |  | ||||||
|   bwipe! |   bwipe! | ||||||
|   call win_gotoid(twowin) |   call win_gotoid(twowin) | ||||||
|   bwipe! |   bwipe! | ||||||
|   | |||||||
| @@ -83,6 +83,9 @@ func Test_partial_dict() | |||||||
|  |  | ||||||
|   let dict = {"tr": function('tr', ['hello', 'h', 'H'])} |   let dict = {"tr": function('tr', ['hello', 'h', 'H'])} | ||||||
|   call assert_equal("Hello", dict.tr()) |   call assert_equal("Hello", dict.tr()) | ||||||
|  |  | ||||||
|  |   call assert_fails("let F=function('setloclist', 10)", "E923:") | ||||||
|  |   call assert_fails("let F=function('setloclist', [], [])", "E922:") | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
| func Test_partial_implicit() | func Test_partial_implicit() | ||||||
| @@ -389,3 +392,5 @@ func Test_compare_partials() | |||||||
|   call assert_true(F1 isnot# F1d1)  " Partial /= non-partial |   call assert_true(F1 isnot# F1d1)  " Partial /= non-partial | ||||||
|   call assert_true(d1.f1 isnot# d1.f1)  " handle_subscript creates new partial each time |   call assert_true(d1.f1 isnot# d1.f1)  " handle_subscript creates new partial each time | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
|  | " vim: shiftwidth=2 sts=2 expandtab | ||||||
|   | |||||||
| @@ -235,8 +235,16 @@ func Test_get_register() | |||||||
|   call assert_equal('', getreg("\<C-F>")) |   call assert_equal('', getreg("\<C-F>")) | ||||||
|   call assert_equal('', getreg("\<C-W>")) |   call assert_equal('', getreg("\<C-W>")) | ||||||
|   call assert_equal('', getreg("\<C-L>")) |   call assert_equal('', getreg("\<C-L>")) | ||||||
|  |   " Change the last used register to '"' for the next test | ||||||
|  |   normal! ""yy | ||||||
|  |   let @" = 'happy' | ||||||
|  |   call assert_equal('happy', getreg()) | ||||||
|  |   call assert_equal('happy', getreg('')) | ||||||
|  |  | ||||||
|   call assert_equal('', getregtype('!')) |   call assert_equal('', getregtype('!')) | ||||||
|  |   call assert_fails('echo getregtype([])', 'E730:') | ||||||
|  |   call assert_equal('v', getregtype()) | ||||||
|  |   call assert_equal('v', getregtype('')) | ||||||
|  |  | ||||||
|   " Test for inserting an invalid register content |   " Test for inserting an invalid register content | ||||||
|   call assert_beeps('exe "normal i\<C-R>!"') |   call assert_beeps('exe "normal i\<C-R>!"') | ||||||
| @@ -316,6 +324,12 @@ func Test_set_register() | |||||||
|   normal 0".gP |   normal 0".gP | ||||||
|   call assert_equal('abcabcabc', getline(1)) |   call assert_equal('abcabcabc', getline(1)) | ||||||
|  |  | ||||||
|  |   let @"='' | ||||||
|  |   call setreg('', '1') | ||||||
|  |   call assert_equal('1', @") | ||||||
|  |   call setreg('@', '2') | ||||||
|  |   call assert_equal('2', @") | ||||||
|  |  | ||||||
|   enew! |   enew! | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1385,6 +1385,15 @@ func Test_search_match_at_curpos() | |||||||
|   close! |   close! | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
|  | " Test for error cases with the search() function | ||||||
|  | func Test_search_errors() | ||||||
|  |   call assert_fails("call search('pat', [])", 'E730:') | ||||||
|  |   call assert_fails("call search('pat', 'b', {})", 'E728:') | ||||||
|  |   call assert_fails("call search('pat', 'b', 1, [])", 'E745:') | ||||||
|  |   call assert_fails("call search('pat', 'ns')", 'E475:') | ||||||
|  |   call assert_fails("call search('pat', 'mr')", 'E475:') | ||||||
|  | endfunc | ||||||
|  |  | ||||||
| func Test_search_display_pattern() | func Test_search_display_pattern() | ||||||
|   new |   new | ||||||
|   call setline(1, ['foo', 'bar', 'foobar']) |   call setline(1, ['foo', 'bar', 'foobar']) | ||||||
|   | |||||||
| @@ -160,6 +160,9 @@ func Test_spellsuggest() | |||||||
|   call assert_equal(['Third'], spellsuggest('THird', 1)) |   call assert_equal(['Third'], spellsuggest('THird', 1)) | ||||||
|   call assert_equal(['All'],      spellsuggest('ALl', 1)) |   call assert_equal(['All'],      spellsuggest('ALl', 1)) | ||||||
|  |  | ||||||
|  |   call assert_fails("call spellsuggest('maxch', [])", 'E745:') | ||||||
|  |   call assert_fails("call spellsuggest('maxch', 2, [])", 'E745:') | ||||||
|  |  | ||||||
|   set spell& |   set spell& | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
| @@ -1164,3 +1167,5 @@ let g:test_data_aff_sal = [ | |||||||
|       \"SAL ZZ-                  _", |       \"SAL ZZ-                  _", | ||||||
|       \"SAL Z                    S", |       \"SAL Z                    S", | ||||||
|       \ ] |       \ ] | ||||||
|  |  | ||||||
|  | " vim: shiftwidth=2 sts=2 expandtab | ||||||
|   | |||||||
| @@ -242,6 +242,11 @@ func Test_substitute_errors() | |||||||
|   setl nomodifiable |   setl nomodifiable | ||||||
|   call assert_fails('s/foo/bar/', 'E21:') |   call assert_fails('s/foo/bar/', 'E21:') | ||||||
|  |  | ||||||
|  |   call assert_fails("let s=substitute([], 'a', 'A', 'g')", 'E730:') | ||||||
|  |   call assert_fails("let s=substitute('abcda', [], 'A', 'g')", 'E730:') | ||||||
|  |   call assert_fails("let s=substitute('abcda', 'a', [], 'g')", 'E730:') | ||||||
|  |   call assert_fails("let s=substitute('abcda', 'a', 'A', [])", 'E730:') | ||||||
|  |  | ||||||
|   bwipe! |   bwipe! | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
|   | |||||||
| @@ -4,6 +4,8 @@ func Test_missing_attr() | |||||||
|   hi Mine term=bold cterm=italic |   hi Mine term=bold cterm=italic | ||||||
|   call assert_equal('Mine', synIDattr(hlID("Mine"), "name")) |   call assert_equal('Mine', synIDattr(hlID("Mine"), "name")) | ||||||
|   call assert_equal('', synIDattr("Mine"->hlID(), "bg", 'term')) |   call assert_equal('', synIDattr("Mine"->hlID(), "bg", 'term')) | ||||||
|  |   call assert_equal('', synIDattr("Mine"->hlID(), "fg", 'term')) | ||||||
|  |   call assert_equal('', synIDattr("Mine"->hlID(), "sp", 'term')) | ||||||
|   call assert_equal('1', synIDattr(hlID("Mine"), "bold", 'term')) |   call assert_equal('1', synIDattr(hlID("Mine"), "bold", 'term')) | ||||||
|   call assert_equal('1', synIDattr(hlID("Mine"), "italic", 'cterm')) |   call assert_equal('1', synIDattr(hlID("Mine"), "italic", 'cterm')) | ||||||
|   hi Mine term=reverse cterm=inverse |   hi Mine term=reverse cterm=inverse | ||||||
| @@ -819,3 +821,5 @@ func Test_color_names() | |||||||
|   hi Mine guifg=blanchedalmond |   hi Mine guifg=blanchedalmond | ||||||
|   hi Mine guifg=BLANCHEDALMOND |   hi Mine guifg=BLANCHEDALMOND | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
|  | " vim: shiftwidth=2 sts=2 expandtab | ||||||
|   | |||||||
| @@ -532,6 +532,8 @@ func Test_synstack_synIDtrans() | |||||||
|   call assert_equal(['cComment', 'cTodo'], map(synstack(line("."), col(".")), 'synIDattr(v:val, "name")')) |   call assert_equal(['cComment', 'cTodo'], map(synstack(line("."), col(".")), 'synIDattr(v:val, "name")')) | ||||||
|   call assert_equal(['Comment', 'Todo'],   map(synstack(line("."), col(".")), 'synIDattr(synIDtrans(v:val), "name")')) |   call assert_equal(['Comment', 'Todo'],   map(synstack(line("."), col(".")), 'synIDattr(synIDtrans(v:val), "name")')) | ||||||
|  |  | ||||||
|  |   call assert_fails("let n=synIDtrans([])", 'E745:') | ||||||
|  |  | ||||||
|   syn clear |   syn clear | ||||||
|   bw! |   bw! | ||||||
| endfunc | endfunc | ||||||
| @@ -631,3 +633,5 @@ func Test_syntax_after_bufdo() | |||||||
|   call delete('Xccc.c') |   call delete('Xccc.c') | ||||||
|   call delete('Xddd.c') |   call delete('Xddd.c') | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
|  | " vim: shiftwidth=2 sts=2 expandtab | ||||||
|   | |||||||
| @@ -36,6 +36,8 @@ func Test_taglist() | |||||||
|   call assert_equal('d', cmd[0]['kind']) |   call assert_equal('d', cmd[0]['kind']) | ||||||
|   call assert_equal('call cursor(3, 4)', cmd[0]['cmd']) |   call assert_equal('call cursor(3, 4)', cmd[0]['cmd']) | ||||||
|  |  | ||||||
|  |   call assert_fails("let l=taglist([])", 'E730:') | ||||||
|  |  | ||||||
|   call delete('Xtags') |   call delete('Xtags') | ||||||
|   set tags& |   set tags& | ||||||
|   bwipe |   bwipe | ||||||
|   | |||||||
| @@ -20,6 +20,8 @@ func Test_strchars() | |||||||
|     call assert_equal(exp[i][1], inp[i]->strchars(0)) |     call assert_equal(exp[i][1], inp[i]->strchars(0)) | ||||||
|     call assert_equal(exp[i][2], strchars(inp[i], 1)) |     call assert_equal(exp[i][2], strchars(inp[i], 1)) | ||||||
|   endfor |   endfor | ||||||
|  |   call assert_fails("let v=strchars('abc', [])", 'E474:') | ||||||
|  |   call assert_fails("let v=strchars('abc', 2)", 'E474:') | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
| " Test for customlist completion | " Test for customlist completion | ||||||
| @@ -99,6 +101,7 @@ func Test_list2str_str2list_latin1() | |||||||
|    |    | ||||||
|   let lres = str2list(s, 1) |   let lres = str2list(s, 1) | ||||||
|   let sres = list2str(l, 1) |   let sres = list2str(l, 1) | ||||||
|  |   call assert_equal([65, 66, 67], str2list("ABC")) | ||||||
|  |  | ||||||
|   let &encoding = save_encoding |   let &encoding = save_encoding | ||||||
|   call assert_equal(l, lres) |   call assert_equal(l, lres) | ||||||
| @@ -138,3 +141,5 @@ func Test_screenchar_utf8() | |||||||
|  |  | ||||||
|   bwipe! |   bwipe! | ||||||
| endfunc | endfunc | ||||||
|  |  | ||||||
|  | " vim: shiftwidth=2 sts=2 expandtab | ||||||
|   | |||||||
| @@ -369,6 +369,8 @@ func Test_vartabs_shiftwidth() | |||||||
|   let lines = ScreenLines([1, 3], winwidth(0)) |   let lines = ScreenLines([1, 3], winwidth(0)) | ||||||
|   call s:compare_lines(expect4, lines) |   call s:compare_lines(expect4, lines) | ||||||
|  |  | ||||||
|  |   call assert_fails('call shiftwidth([])', 'E745:') | ||||||
|  |  | ||||||
|   " cleanup |   " cleanup | ||||||
|   bw! |   bw! | ||||||
|   bw! |   bw! | ||||||
|   | |||||||
| @@ -525,6 +525,7 @@ func Test_window_newtab() | |||||||
|   call assert_equal(2, tabpagenr('$')) |   call assert_equal(2, tabpagenr('$')) | ||||||
|   call assert_equal(['Xb', 'Xa'], map(tabpagebuflist(1), 'bufname(v:val)')) |   call assert_equal(['Xb', 'Xa'], map(tabpagebuflist(1), 'bufname(v:val)')) | ||||||
|   call assert_equal(['Xc'      ], map(2->tabpagebuflist(), 'bufname(v:val)')) |   call assert_equal(['Xc'      ], map(2->tabpagebuflist(), 'bufname(v:val)')) | ||||||
|  |   call assert_equal(['Xc'      ], map(tabpagebuflist(), 'bufname(v:val)')) | ||||||
|  |  | ||||||
|   %bw! |   %bw! | ||||||
| endfunc | endfunc | ||||||
|   | |||||||
| @@ -738,6 +738,8 @@ static char *(features[]) = | |||||||
|  |  | ||||||
| static int included_patches[] = | static int included_patches[] = | ||||||
| {   /* Add new patch number below this line */ | {   /* Add new patch number below this line */ | ||||||
|  | /**/ | ||||||
|  |     448, | ||||||
| /**/ | /**/ | ||||||
|     447, |     447, | ||||||
| /**/ | /**/ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user