vim-patch:9.0.1257: code style is not check in test scripts

Problem:    Code style is not check in test scripts.
Solution:   Add basic code style check for test files.

94722c5107

Use Test_test_files() from latest Vim.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
zeertzjq
2024-07-17 10:19:31 +08:00
parent f17d819330
commit 457ab65ff3
32 changed files with 225 additions and 172 deletions

View File

@@ -48,8 +48,18 @@
" call add(v:errors, "this happened") " call add(v:errors, "this happened")
" Without the +eval feature we can't run these tests, bail out.
silent! while 0
qa!
silent! endwhile
" In the GUI we can always change the screen size.
if has('gui_running')
set columns=80 lines=25
endif
" Check that the screen size is at least 24 x 80 characters. " Check that the screen size is at least 24 x 80 characters.
if &lines < 24 || &columns < 80 if &lines < 24 || &columns < 80
let error = 'Screen size too small! Tests require at least 24 lines with 80 characters, got ' .. &lines .. ' lines with ' .. &columns .. ' characters' let error = 'Screen size too small! Tests require at least 24 lines with 80 characters, got ' .. &lines .. ' lines with ' .. &columns .. ' characters'
echoerr error echoerr error
split test.log split test.log

View File

@@ -33,7 +33,7 @@ if 1
silent %s/^SKIPPED \zs.*/\=Count(submatch(0), 'skipped')/egn silent %s/^SKIPPED \zs.*/\=Count(submatch(0), 'skipped')/egn
silent %s/^\(\d\+\)\s\+FAILED:/\=Count(submatch(1), 'failed')/egn silent %s/^\(\d\+\)\s\+FAILED:/\=Count(submatch(1), 'failed')/egn
call extend(output, ["Skipped:"]) call extend(output, ["Skipped:"])
call extend(output, skipped_output) call extend(output, skipped_output)
call extend(output, [ call extend(output, [

View File

@@ -273,8 +273,8 @@ func Test_win_tab_autocmd()
augroup testing augroup testing
au WinNew * call add(g:record, 'WinNew') au WinNew * call add(g:record, 'WinNew')
au WinClosed * call add(g:record, 'WinClosed') au WinClosed * call add(g:record, 'WinClosed')
au WinEnter * call add(g:record, 'WinEnter') au WinEnter * call add(g:record, 'WinEnter')
au WinLeave * call add(g:record, 'WinLeave') au WinLeave * call add(g:record, 'WinLeave')
au TabNew * call add(g:record, 'TabNew') au TabNew * call add(g:record, 'TabNew')
au TabClosed * call add(g:record, 'TabClosed') au TabClosed * call add(g:record, 'TabClosed')
au TabEnter * call add(g:record, 'TabEnter') au TabEnter * call add(g:record, 'TabEnter')
@@ -3770,7 +3770,7 @@ endfunc
func Test_autocmd_split_dummy() func Test_autocmd_split_dummy()
" Autocommand trying to split a window containing a dummy buffer. " Autocommand trying to split a window containing a dummy buffer.
auto BufReadPre * exe "sbuf " .. expand("<abuf>") auto BufReadPre * exe "sbuf " .. expand("<abuf>")
" Avoid the "W11" prompt " Avoid the "W11" prompt
au FileChangedShell * let v:fcs_choice = 'reload' au FileChangedShell * let v:fcs_choice = 'reload'
func Xautocmd_changelist() func Xautocmd_changelist()

View File

@@ -850,7 +850,7 @@ func Test_indexof()
call assert_equal(-1, indexof(v:_null_blob, "v:val == 0xde")) call assert_equal(-1, indexof(v:_null_blob, "v:val == 0xde"))
call assert_equal(-1, indexof(b, v:_null_string)) call assert_equal(-1, indexof(b, v:_null_string))
" Nvim doesn't have null functions " Nvim doesn't have null functions
" call assert_equal(-1, indexof(b, test_null_function())) " call assert_equal(-1, indexof(b, test_null_function()))
let b = 0z01020102 let b = 0z01020102
call assert_equal(1, indexof(b, "v:val == 0x02", #{startidx: 0})) call assert_equal(1, indexof(b, "v:val == 0x02", #{startidx: 0}))

View File

@@ -53,7 +53,7 @@ func Test_blockinsert_autoindent()
let expected =<< trim END let expected =<< trim END
vim9script vim9script
var d = { var d = {
a: (): asdf => 0, a: (): asdf => 0,
b: (): asdf => 0, b: (): asdf => 0,
c: (): asdf => 0, c: (): asdf => 0,
} }

View File

@@ -6,6 +6,45 @@ func s:ReportError(fname, lnum, msg)
endif endif
endfunc endfunc
func Test_test_files()
for fname in glob('*.vim', 0, 1)
let g:ignoreSwapExists = 'e'
exe 'edit ' .. fname
" some files intentionally have misplaced white space
if fname =~ 'test_cindent.vim' || fname =~ 'test_join.vim'
continue
endif
" skip files that are known to have a space before a tab
if fname !~ 'test_comments.vim'
\ && fname !~ 'test_listchars.vim'
\ && fname !~ 'test_visual.vim'
call cursor(1, 1)
let skip = 'getline(".") =~ "codestyle: ignore"'
let lnum = search(fname =~ "test_regexp_latin" ? '[^á] \t' : ' \t', 'W', 0, 0, skip)
call s:ReportError('testdir/' .. fname, lnum, 'space before Tab')
endif
" skip files that are known to have trailing white space
if fname !~ 'test_cmdline.vim'
\ && fname !~ 'test_let.vim'
\ && fname !~ 'test_tagjump.vim'
\ && fname !~ 'test_vim9_cmd.vim'
call cursor(1, 1)
let lnum = search(
\ fname =~ 'test_vim9_assign.vim' ? '[^=]\s$'
\ : fname =~ 'test_vim9_class.vim' ? '[^)]\s$'
\ : fname =~ 'test_vim9_script.vim' ? '[^,:3]\s$'
\ : fname =~ 'test_visual.vim' ? '[^/]\s$'
\ : '[^\\]\s$')
call s:ReportError('testdir/' .. fname, lnum, 'trailing white space')
endif
endfor
bwipe!
endfunc
func Test_help_files() func Test_help_files()
set nowrapscan set nowrapscan

View File

@@ -1332,12 +1332,12 @@ endfunc
func Test_diff_and_scroll() func Test_diff_and_scroll()
" this was causing an ml_get error " this was causing an ml_get error
set ls=2 set ls=2
for i in range(winheight(0) * 2) for i in range(winheight(0) * 2)
call setline(i, i < winheight(0) - 10 ? i : i + 10) call setline(i, i < winheight(0) - 10 ? i : i + 10)
endfor endfor
vnew vnew
for i in range(winheight(0)*2 + 10) for i in range(winheight(0)*2 + 10)
call setline(i, i < winheight(0) - 10 ? 0 : i) call setline(i, i < winheight(0) - 10 ? 0 : i)
endfor endfor
diffthis diffthis
wincmd p wincmd p

View File

@@ -2112,7 +2112,7 @@ func Test_edit_overlong_file_name()
file %%%%%%%%%%%%%%%%%%%%%%%%%% file %%%%%%%%%%%%%%%%%%%%%%%%%%
file %%%%%% file %%%%%%
set readonly set readonly
set ls=2 set ls=2
redraw! redraw!
set noreadonly ls& set noreadonly ls&

View File

@@ -7,15 +7,15 @@ let s:slnum = str2nr(expand('<slnum>'))
let s:sflnum = str2nr(expand('<sflnum>')) let s:sflnum = str2nr(expand('<sflnum>'))
func s:expand_sfile() func s:expand_sfile()
return expand('<sfile>') return expand('<sfile>')
endfunc endfunc
func s:expand_slnum() func s:expand_slnum()
return str2nr(expand('<slnum>')) return str2nr(expand('<slnum>'))
endfunc endfunc
func s:expand_sflnum() func s:expand_sflnum()
return str2nr(expand('<sflnum>')) return str2nr(expand('<sflnum>'))
endfunc endfunc
" This test depends on the location in the test file, put it first. " This test depends on the location in the test file, put it first.

View File

@@ -499,7 +499,7 @@ func Test_move_folds_around_manual()
%foldopen! %foldopen!
13m7 13m7
call Check_foldlevels([1, 2, 2, 2, 1, 2, 2, 1, 1, 1, 2, 2, 2, 1, 0]) call Check_foldlevels([1, 2, 2, 2, 1, 2, 2, 1, 1, 1, 2, 2, 2, 1, 0])
bw! bw!
endfunc endfunc
@@ -748,7 +748,7 @@ func Test_fold_create_marker_in_C()
let content =<< trim [CODE] let content =<< trim [CODE]
/* /*
* comment * comment
* *
* *
*/ */
int f(int* p) { int f(int* p) {

View File

@@ -17,7 +17,7 @@ endfunc
func Test_gD() func Test_gD()
let lines =<< trim [CODE] let lines =<< trim [CODE]
int x; int x;
int func(void) int func(void)
{ {
return x; return x;
@@ -30,7 +30,7 @@ endfunc
func Test_gD_too() func Test_gD_too()
let lines =<< trim [CODE] let lines =<< trim [CODE]
Filename x; Filename x;
int Filename int Filename
int func() { int func() {
Filename x; Filename x;
@@ -44,7 +44,7 @@ func Test_gD_comment()
let lines =<< trim [CODE] let lines =<< trim [CODE]
/* int x; */ /* int x; */
int x; int x;
int func(void) int func(void)
{ {
return x; return x;
@@ -58,7 +58,7 @@ func Test_gD_inline_comment()
let lines =<< trim [CODE] let lines =<< trim [CODE]
int y /* , x */; int y /* , x */;
int x; int x;
int func(void) int func(void)
{ {
return x; return x;
@@ -72,7 +72,7 @@ func Test_gD_string()
let lines =<< trim [CODE] let lines =<< trim [CODE]
char *s[] = "x"; char *s[] = "x";
int x = 1; int x = 1;
int func(void) int func(void)
{ {
return x; return x;
@@ -85,7 +85,7 @@ endfunc
func Test_gD_string_same_line() func Test_gD_string_same_line()
let lines =<< trim [CODE] let lines =<< trim [CODE]
char *s[] = "x", int x = 1; char *s[] = "x", int x = 1;
int func(void) int func(void)
{ {
return x; return x;
@@ -99,7 +99,7 @@ func Test_gD_char()
let lines =<< trim [CODE] let lines =<< trim [CODE]
char c = 'x'; char c = 'x';
int x = 1; int x = 1;
int func(void) int func(void)
{ {
return x; return x;
@@ -112,7 +112,7 @@ endfunc
func Test_gd() func Test_gd()
let lines =<< trim [CODE] let lines =<< trim [CODE]
int x; int x;
int func(int x) int func(int x)
{ {
return x; return x;
@@ -146,7 +146,7 @@ func Test_gd_not_local()
{ {
return x; return x;
} }
int func2(int x) int func2(int x)
{ {
return x; return x;
@@ -173,9 +173,9 @@ func Test_gd_missing_braces()
def func1(a) def func1(a)
a + 1 a + 1
end end
a = 1 a = 1
def func2() def func2()
return a return a
end end
@@ -252,11 +252,11 @@ func Test_gd_inline_comment_body()
int func(void) int func(void)
{ {
int y /* , x */; int y /* , x */;
for (/* int x = 0 */; y < 2; y++); for (/* int x = 0 */; y < 2; y++);
int x = 0; int x = 0;
return x; return x;
} }
[CODE] [CODE]
@@ -292,7 +292,7 @@ func Test_gd_string()
{ {
char *s = "x"; char *s = "x";
int x = 1; int x = 1;
return x; return x;
} }
[CODE] [CODE]
@@ -305,7 +305,7 @@ func Test_gd_string_only()
int func(void) int func(void)
{ {
char *s = "x"; char *s = "x";
return x; return x;
} }
[CODE] [CODE]
@@ -347,7 +347,7 @@ func Test_gd_local_block()
char *b = "NULL"; char *b = "NULL";
return b; return b;
} }
return 0; return 0;
} }
[CODE] [CODE]

View File

@@ -705,7 +705,7 @@ endfunc
" Text: " Text:
" 1 23 " 1 23
" 4 56 " 4 56
" "
" Expected: " Expected:
" 1) f2 Ctrl-V jl <ctrl-a>, repeat twice afterwards with . " 1) f2 Ctrl-V jl <ctrl-a>, repeat twice afterwards with .
" 1 26 " 1 26

View File

@@ -176,7 +176,7 @@ func Test_modeline_indent_expr()
endfunc endfunc
func Test_indent_func_with_gq() func Test_indent_func_with_gq()
function GetTeXIndent() function GetTeXIndent()
" Sample indent expression for TeX files " Sample indent expression for TeX files
let lnum = prevnonblank(v:lnum - 1) let lnum = prevnonblank(v:lnum - 1)
@@ -187,7 +187,7 @@ func Test_indent_func_with_gq()
let line = getline(lnum) let line = getline(lnum)
let ind = indent(lnum) let ind = indent(lnum)
" Add a 'shiftwidth' after beginning of environments. " Add a 'shiftwidth' after beginning of environments.
if line =~ '\\begin{center}' if line =~ '\\begin{center}'
let ind = ind + shiftwidth() let ind = ind + shiftwidth()
endif endif
return ind return ind
@@ -249,7 +249,7 @@ func Test_indent_func_with_gq()
bwipe! bwipe!
delmark ab delmark ab
delfunction GetTeXIndent delfunction GetTeXIndent
endfu endfu
func Test_formatting_keeps_first_line_indent() func Test_formatting_keeps_first_line_indent()

View File

@@ -2382,7 +2382,7 @@ endfunc
func Test_ins_complete_end_of_line() func Test_ins_complete_end_of_line()
" this was reading past the end of the line " this was reading past the end of the line
new new
norm 8o€ý  norm 8o€ý 
sil! norm o sil! norm o

View File

@@ -20,7 +20,7 @@ func Test_maparg()
call assert_equal({'silent': 0, 'noremap': 0, 'script': 0, 'lhs': 'foo<C-V>', call assert_equal({'silent': 0, 'noremap': 0, 'script': 0, 'lhs': 'foo<C-V>',
\ 'lhsraw': "foo\x80\xfc\x04V", 'lhsrawalt': "foo\x16", \ 'lhsraw': "foo\x80\xfc\x04V", 'lhsrawalt': "foo\x16",
\ 'mode': ' ', 'nowait': 0, 'expr': 0, 'sid': sid, 'scriptversion': 1, \ 'mode': ' ', 'nowait': 0, 'expr': 0, 'sid': sid, 'scriptversion': 1,
\ 'lnum': lnum + 1, \ 'lnum': lnum + 1,
\ 'rhs': 'is<F4>foo', 'buffer': 0, 'abbr': 0, 'mode_bits': 0x47}, \ 'rhs': 'is<F4>foo', 'buffer': 0, 'abbr': 0, 'mode_bits': 0x47},
\ maparg('foo<C-V>', '', 0, 1)) \ maparg('foo<C-V>', '', 0, 1))
call assert_equal({'silent': 1, 'noremap': 1, 'script': 1, 'lhs': 'bar', call assert_equal({'silent': 1, 'noremap': 1, 'script': 1, 'lhs': 'bar',

View File

@@ -128,7 +128,7 @@ endfunc
func Test_method_syntax() func Test_method_syntax()
eval [1, 2, 3] ->sort( ) eval [1, 2, 3] ->sort( )
eval [1, 2, 3] eval [1, 2, 3]
\ ->sort( \ ->sort(
\ ) \ )
call assert_fails('eval [1, 2, 3]-> sort()', 'E15:') call assert_fails('eval [1, 2, 3]-> sort()', 'E15:')

View File

@@ -16,7 +16,7 @@ func ListMonths()
if !empty(entered) if !empty(entered)
let mth = filter(mth, 'v:val=~"^".entered') let mth = filter(mth, 'v:val=~"^".entered')
endif endif
call complete(1, mth) call complete(1, mth)
return '' return ''
endfunc endfunc
@@ -74,7 +74,7 @@ func Test_popup_complete()
call feedkeys("aJu\<f5>\<c-p>l\<c-y>", 'tx') call feedkeys("aJu\<f5>\<c-p>l\<c-y>", 'tx')
call assert_equal(["Jul"], getline(1,2)) call assert_equal(["Jul"], getline(1,2))
%d %d
" any-non printable, non-white character: Add this character and " any-non printable, non-white character: Add this character and
" reduce number of matches " reduce number of matches
call feedkeys("aJu\<f5>\<c-p>l\<c-n>\<c-y>", 'tx') call feedkeys("aJu\<f5>\<c-p>l\<c-n>\<c-y>", 'tx')
@@ -96,7 +96,7 @@ func Test_popup_complete()
call feedkeys("aJ\<f5>".repeat("\<c-n>",3)."\<c-l>\<esc>", 'tx') call feedkeys("aJ\<f5>".repeat("\<c-n>",3)."\<c-l>\<esc>", 'tx')
call assert_equal(["J "], getline(1,2)) call assert_equal(["J "], getline(1,2))
%d %d
" <c-l> - Insert one character from the current match " <c-l> - Insert one character from the current match
call feedkeys("aJ\<f5>".repeat("\<c-n>",4)."\<c-l>\<esc>", 'tx') call feedkeys("aJ\<f5>".repeat("\<c-n>",4)."\<c-l>\<esc>", 'tx')
call assert_equal(["January "], getline(1,2)) call assert_equal(["January "], getline(1,2))
@@ -857,7 +857,7 @@ func Test_popup_position()
call term_sendkeys(buf, "jI123456789_\<Esc>") call term_sendkeys(buf, "jI123456789_\<Esc>")
call term_sendkeys(buf, "GA\<C-N>") call term_sendkeys(buf, "GA\<C-N>")
call VerifyScreenDump(buf, 'Test_popup_position_04', {'rows': 10}) call VerifyScreenDump(buf, 'Test_popup_position_04', {'rows': 10})
call term_sendkeys(buf, "\<Esc>u") call term_sendkeys(buf, "\<Esc>u")
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('Xtest') call delete('Xtest')

View File

@@ -1020,52 +1020,50 @@ endfunc
" More tests for 'errorformat' " More tests for 'errorformat'
func Test_efm1() func Test_efm1()
if !has('unix') " The 'errorformat' setting is different on non-Unix systems.
" The 'errorformat' setting is different on non-Unix systems. " This test works only on Unix-like systems.
" This test works only on Unix-like systems. CheckUnix
return
endif
let l =<< trim [DATA] let l =<< trim [DATA]
"Xtestfile", line 4.12: 1506-045 (S) Undeclared identifier fd_set. "Xtestfile", line 4.12: 1506-045 (S) Undeclared identifier fd_set.
"Xtestfile", line 6 col 19; this is an error "Xtestfile", line 6 col 19; this is an error
gcc -c -DHAVE_CONFIsing-prototypes -I/usr/X11R6/include version.c gcc -c -DHAVE_CONFIsing-prototypes -I/usr/X11R6/include version.c
Xtestfile:9: parse error before `asd' Xtestfile:9: parse error before `asd'
make: *** [src/vim/testdir/Makefile:100: test_quickfix] Error 1 make: *** [src/vim/testdir/Makefile:100: test_quickfix] Error 1
in file "Xtestfile" linenr 10: there is an error in file "Xtestfile" linenr 10: there is an error
2 returned 2 returned
"Xtestfile", line 11 col 1; this is an error "Xtestfile", line 11 col 1; this is an error
"Xtestfile", line 12 col 2; this is another error "Xtestfile", line 12 col 2; this is another error
"Xtestfile", line 14:10; this is an error in column 10 "Xtestfile", line 14:10; this is an error in column 10
=Xtestfile=, line 15:10; this is another error, but in vcol 10 this time =Xtestfile=, line 15:10; this is another error, but in vcol 10 this time
"Xtestfile", linenr 16: yet another problem "Xtestfile", linenr 16: yet another problem
Error in "Xtestfile" at line 17: Error in "Xtestfile" at line 17:
x should be a dot x should be a dot
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 17 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 17
^ ^
Error in "Xtestfile" at line 18: Error in "Xtestfile" at line 18:
x should be a dot x should be a dot
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 18 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 18
.............^ .............^
Error in "Xtestfile" at line 19: Error in "Xtestfile" at line 19:
x should be a dot x should be a dot
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 19 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 19
--------------^ --------------^
Error in "Xtestfile" at line 20: Error in "Xtestfile" at line 20:
x should be a dot x should be a dot
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 20 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 20
^ ^
Does anyone know what is the problem and how to correction it? Does anyone know what is the problem and how to correction it?
"Xtestfile", line 21 col 9: What is the title of the quickfix window? "Xtestfile", line 21 col 9: What is the title of the quickfix window?
"Xtestfile", line 22 col 9: What is the title of the quickfix window? "Xtestfile", line 22 col 9: What is the title of the quickfix window?
[DATA] [DATA]
call writefile(l, 'Xerrorfile1') call writefile(l, 'Xerrorfile1')
call writefile(l[:-2], 'Xerrorfile2') call writefile(l[:-2], 'Xerrorfile2')
let m =<< [DATA] let m =<< [DATA]
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 2 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 2
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 3 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 3
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 4 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 4
@@ -1088,55 +1086,55 @@ func Test_efm1()
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 21 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 21
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 22 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 22
[DATA] [DATA]
call writefile(m, 'Xtestfile') call writefile(m, 'Xtestfile')
let save_efm = &efm let save_efm = &efm
set efm+==%f=\\,\ line\ %l%*\\D%v%*[^\ ]\ %m set efm+==%f=\\,\ line\ %l%*\\D%v%*[^\ ]\ %m
set efm^=%AError\ in\ \"%f\"\ at\ line\ %l:,%Z%p^,%C%m set efm^=%AError\ in\ \"%f\"\ at\ line\ %l:,%Z%p^,%C%m
exe 'cf Xerrorfile2' exe 'cf Xerrorfile2'
clast clast
copen copen
call assert_equal(':cf Xerrorfile2', w:quickfix_title) call assert_equal(':cf Xerrorfile2', w:quickfix_title)
wincmd p wincmd p
exe 'cf Xerrorfile1' exe 'cf Xerrorfile1'
call assert_equal([4, 12], [line('.'), col('.')]) call assert_equal([4, 12], [line('.'), col('.')])
cn cn
call assert_equal([6, 19], [line('.'), col('.')]) call assert_equal([6, 19], [line('.'), col('.')])
cn cn
call assert_equal([9, 2], [line('.'), col('.')]) call assert_equal([9, 2], [line('.'), col('.')])
cn cn
call assert_equal([10, 2], [line('.'), col('.')]) call assert_equal([10, 2], [line('.'), col('.')])
cn cn
call assert_equal([11, 1], [line('.'), col('.')]) call assert_equal([11, 1], [line('.'), col('.')])
cn cn
call assert_equal([12, 2], [line('.'), col('.')]) call assert_equal([12, 2], [line('.'), col('.')])
cn cn
call assert_equal([14, 10], [line('.'), col('.')]) call assert_equal([14, 10], [line('.'), col('.')])
cn cn
call assert_equal([15, 3, 10], [line('.'), col('.'), virtcol('.')]) call assert_equal([15, 3, 10], [line('.'), col('.'), virtcol('.')])
cn cn
call assert_equal([16, 2], [line('.'), col('.')]) call assert_equal([16, 2], [line('.'), col('.')])
cn cn
call assert_equal([17, 6], [line('.'), col('.')]) call assert_equal([17, 6], [line('.'), col('.')])
cn cn
call assert_equal([18, 7], [line('.'), col('.')]) call assert_equal([18, 7], [line('.'), col('.')])
cn cn
call assert_equal([19, 8], [line('.'), col('.')]) call assert_equal([19, 8], [line('.'), col('.')])
cn cn
call assert_equal([20, 9], [line('.'), col('.')]) call assert_equal([20, 9], [line('.'), col('.')])
clast clast
cprev cprev
cprev cprev
wincmd w wincmd w
call assert_equal(':cf Xerrorfile1', w:quickfix_title) call assert_equal(':cf Xerrorfile1', w:quickfix_title)
wincmd p wincmd p
let &efm = save_efm let &efm = save_efm
call delete('Xerrorfile1') call delete('Xerrorfile1')
call delete('Xerrorfile2') call delete('Xerrorfile2')
call delete('Xtestfile') call delete('Xtestfile')
endfunc endfunc
" Test for quickfix directory stack support " Test for quickfix directory stack support
@@ -1410,7 +1408,7 @@ func Test_efm2()
failUnlessEqual failUnlessEqual
raise self.failureException, \\ raise self.failureException, \\
W:AssertionError: 34 != 33 W:AssertionError: 34 != 33
-------------------------------------------------------------- --------------------------------------------------------------
Ran 27 tests in 0.063s Ran 27 tests in 0.063s
[DATA] [DATA]

View File

@@ -1164,7 +1164,7 @@ func Test_compare_column_matchstr()
" matchstr(). " matchstr().
enew enew
call setline(1, ['one', 'two', 'three']) call setline(1, ['one', 'two', 'three'])
:3 :3
:/ee :/ee
bwipe! bwipe!
set re=1 set re=1

View File

@@ -369,18 +369,18 @@ func Test_smoothscroll_wrap_long_line()
call term_sendkeys(buf, ":set scrolloff=1\<CR>") call term_sendkeys(buf, ":set scrolloff=1\<CR>")
call term_sendkeys(buf, "10|\<C-E>") call term_sendkeys(buf, "10|\<C-E>")
call VerifyScreenDump(buf, 'Test_smooth_long_6', {}) call VerifyScreenDump(buf, 'Test_smooth_long_6', {})
" 'scrolloff' set to 1, scrolling down, cursor moves screen line up " 'scrolloff' set to 1, scrolling down, cursor moves screen line up
call term_sendkeys(buf, "\<C-E>") call term_sendkeys(buf, "\<C-E>")
call term_sendkeys(buf, "gjgj") call term_sendkeys(buf, "gjgj")
call term_sendkeys(buf, "\<C-Y>") call term_sendkeys(buf, "\<C-Y>")
call VerifyScreenDump(buf, 'Test_smooth_long_7', {}) call VerifyScreenDump(buf, 'Test_smooth_long_7', {})
" 'scrolloff' set to 2, scrolling up, cursor moves screen line down " 'scrolloff' set to 2, scrolling up, cursor moves screen line down
call term_sendkeys(buf, ":set scrolloff=2\<CR>") call term_sendkeys(buf, ":set scrolloff=2\<CR>")
call term_sendkeys(buf, "10|\<C-E>") call term_sendkeys(buf, "10|\<C-E>")
call VerifyScreenDump(buf, 'Test_smooth_long_8', {}) call VerifyScreenDump(buf, 'Test_smooth_long_8', {})
" 'scrolloff' set to 2, scrolling down, cursor moves screen line up " 'scrolloff' set to 2, scrolling down, cursor moves screen line up
call term_sendkeys(buf, "\<C-E>") call term_sendkeys(buf, "\<C-E>")
call term_sendkeys(buf, "gj") call term_sendkeys(buf, "gj")
@@ -421,7 +421,7 @@ func Test_smoothscroll_wrap_long_line()
call term_sendkeys(buf, "3Gzt") call term_sendkeys(buf, "3Gzt")
call term_sendkeys(buf, "\<C-E>j") call term_sendkeys(buf, "\<C-E>j")
call VerifyScreenDump(buf, 'Test_smooth_long_16', {}) call VerifyScreenDump(buf, 'Test_smooth_long_16', {})
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
endfunc endfunc
@@ -436,7 +436,7 @@ func Test_smoothscroll_one_long_line()
call writefile(lines, 'XSmoothOneLong', 'D') call writefile(lines, 'XSmoothOneLong', 'D')
let buf = RunVimInTerminal('-S XSmoothOneLong', #{rows: 6, cols: 40}) let buf = RunVimInTerminal('-S XSmoothOneLong', #{rows: 6, cols: 40})
call VerifyScreenDump(buf, 'Test_smooth_one_long_1', {}) call VerifyScreenDump(buf, 'Test_smooth_one_long_1', {})
call term_sendkeys(buf, "\<C-E>") call term_sendkeys(buf, "\<C-E>")
call VerifyScreenDump(buf, 'Test_smooth_one_long_2', {}) call VerifyScreenDump(buf, 'Test_smooth_one_long_2', {})
@@ -458,7 +458,7 @@ func Test_smoothscroll_long_line_showbreak()
call writefile(lines, 'XSmoothLongShowbreak', 'D') call writefile(lines, 'XSmoothLongShowbreak', 'D')
let buf = RunVimInTerminal('-S XSmoothLongShowbreak', #{rows: 6, cols: 40}) let buf = RunVimInTerminal('-S XSmoothLongShowbreak', #{rows: 6, cols: 40})
call VerifyScreenDump(buf, 'Test_smooth_long_showbreak_1', {}) call VerifyScreenDump(buf, 'Test_smooth_long_showbreak_1', {})
call term_sendkeys(buf, "\<C-E>") call term_sendkeys(buf, "\<C-E>")
call VerifyScreenDump(buf, 'Test_smooth_long_showbreak_2', {}) call VerifyScreenDump(buf, 'Test_smooth_long_showbreak_2', {})
@@ -648,7 +648,7 @@ func Test_smoothscroll_cursor_scrolloff()
call NewWindow(10, 20) call NewWindow(10, 20)
setl smoothscroll wrap setl smoothscroll wrap
setl scrolloff=3 setl scrolloff=3
" 120 chars are 6 screen lines " 120 chars are 6 screen lines
call setline(1, "abcdefghijklmnopqrstABCDEFGHIJKLMNOPQRSTabcdefghijklmnopqrstABCDEFGHIJKLMNOPQRSTabcdefghijklmnopqrstABCDEFGHIJKLMNOPQRST") call setline(1, "abcdefghijklmnopqrstABCDEFGHIJKLMNOPQRSTabcdefghijklmnopqrstABCDEFGHIJKLMNOPQRSTabcdefghijklmnopqrstABCDEFGHIJKLMNOPQRST")
call setline(2, "below") call setline(2, "below")

View File

@@ -134,7 +134,7 @@ func Test_signal_TSTP()
sleep 100m sleep 100m
" We resume after the suspend. Sleep a bit for the signal to take effect, " We resume after the suspend. Sleep a bit for the signal to take effect,
" also when running under valgrind. " also when running under valgrind.
exe 'silent !kill -s CONT ' .. pid_vim exe 'silent !kill -s CONT ' .. pid_vim
call WaitForAssert({-> assert_true(filereadable('XautoOut2'))}) call WaitForAssert({-> assert_true(filereadable('XautoOut2'))})
sleep 10m sleep 10m

View File

@@ -1808,10 +1808,10 @@ func Test_sign_cursor_position()
let lines =<< trim END let lines =<< trim END
call setline(1, [repeat('x', 75), 'mmmm', 'yyyy']) call setline(1, [repeat('x', 75), 'mmmm', 'yyyy'])
call cursor(2,1) call cursor(2,1)
sign define s1 texthl=Search text==> sign define s1 texthl=Search text==>
sign define s2 linehl=Pmenu sign define s2 linehl=Pmenu
redraw redraw
sign place 10 line=2 name=s1 sign place 10 line=2 name=s1
END END
call writefile(lines, 'XtestSigncolumn', 'D') call writefile(lines, 'XtestSigncolumn', 'D')
let buf = RunVimInTerminal('-S XtestSigncolumn', {'rows': 6}) let buf = RunVimInTerminal('-S XtestSigncolumn', {'rows': 6})

View File

@@ -417,7 +417,7 @@ func Test_statusline()
" Test statusline works with 80+ items " Test statusline works with 80+ items
function! StatusLabel() function! StatusLabel()
redrawstatus redrawstatus
return '[label]' return '[label]'
endfunc endfunc
let statusline = '%{StatusLabel()}' let statusline = '%{StatusLabel()}'
for i in range(150) for i in range(150)

View File

@@ -743,7 +743,7 @@ func Test_sub_highlight_zero_match()
endfunc endfunc
func Test_nocatch_sub_failure_handling() func Test_nocatch_sub_failure_handling()
" normal error results in all replacements " normal error results in all replacements
func Foo() func Foo()
foobar foobar
endfunc endfunc

View File

@@ -89,11 +89,11 @@ func Test_tagfunc()
return v:null return v:null
endfunc endfunc
set tags= tfu=NullTagFunc set tags= tfu=NullTagFunc
call assert_fails('tag nothing', 'E433') call assert_fails('tag nothing', 'E433:')
delf NullTagFunc delf NullTagFunc
bwipe! bwipe!
set tags& tfu& cpt& set tags& tfu& cpt&
call delete('Xfile1') call delete('Xfile1')
endfunc endfunc

View File

@@ -777,7 +777,7 @@ func Test_tag_guess()
let code =<< trim [CODE] let code =<< trim [CODE]
int FUNC1 (int x) { } int FUNC1 (int x) { }
int int
func2 (int y) { } func2 (int y) { }
int * func3 () { } int * func3 () { }

View File

@@ -348,8 +348,15 @@ endfunc
" Test that the garbage collector isn't triggered if a timer callback invokes " Test that the garbage collector isn't triggered if a timer callback invokes
" vgetc(). " vgetc().
func Test_nocatch_timer_garbage_collect() func Test_nocatch_timer_garbage_collect()
" skipped: Nvim does not support test_garbagecollect_soon(), test_override() " FIXME: why does this fail only on MacOS M1?
return try
CheckNotMacM1
throw 'Skipped: Nvim does not support test_garbagecollect_soon(), test_override()'
catch /Skipped/
let g:skipped_reason = v:exception
return
endtry
" 'uptimetime. must be bigger than the timer timeout " 'uptimetime. must be bigger than the timer timeout
set ut=200 set ut=200
call test_garbagecollect_soon() call test_garbagecollect_soon()

View File

@@ -49,11 +49,11 @@ func Test_if()
endfunc endfunc
function Try_arg_true_false(expr, false_val, true_val) function Try_arg_true_false(expr, false_val, true_val)
for v in ['v:false', '0', '"0"', '"foo"', '" "'] for v in ['v:false', '0', '"0"', '"foo"', '" "']
let r = eval(substitute(a:expr, '%v%', v, '')) let r = eval(substitute(a:expr, '%v%', v, ''))
call assert_equal(a:false_val, r, 'result for ' . v . ' is not ' . string(a:false_val) . ' but ' . string(r)) call assert_equal(a:false_val, r, 'result for ' . v . ' is not ' . string(a:false_val) . ' but ' . string(r))
endfor endfor
for v in ['v:true', '1', '"1"', '"1foo"'] for v in ['v:true', '1', '"1"', '"1foo"']
let r = eval(substitute(a:expr, '%v%', v, '')) let r = eval(substitute(a:expr, '%v%', v, ''))
call assert_equal(a:true_val, r, 'result for ' . v . ' is not ' . string(a:true_val) . ' but ' . string(r)) call assert_equal(a:true_val, r, 'result for ' . v . ' is not ' . string(a:true_val) . ' but ' . string(r))
endfor endfor
@@ -117,12 +117,11 @@ func Test_true_false_arg()
endfunc endfunc
function Try_arg_non_zero(expr, false_val, true_val) function Try_arg_non_zero(expr, false_val, true_val)
CheckFeature float for v in ['v:false', '0', '[1]', '{2:3}', '3.4']
for v in ['v:false', '0', '[1]', '{2:3}', '3.4']
let r = eval(substitute(a:expr, '%v%', v, '')) let r = eval(substitute(a:expr, '%v%', v, ''))
call assert_equal(a:false_val, r, 'result for ' . v . ' is not ' . a:false_val . ' but ' . r) call assert_equal(a:false_val, r, 'result for ' . v . ' is not ' . a:false_val . ' but ' . r)
endfor endfor
for v in ['v:true', '1', '" "', '"0"'] for v in ['v:true', '1', '" "', '"0"']
let r = eval(substitute(a:expr, '%v%', v, '')) let r = eval(substitute(a:expr, '%v%', v, ''))
call assert_equal(a:true_val, r, 'result for ' . v . ' is not ' . a:true_val . ' but ' . r) call assert_equal(a:true_val, r, 'result for ' . v . ' is not ' . a:true_val . ' but ' . r)
endfor endfor
@@ -138,14 +137,14 @@ func Test_non_zero_arg()
call Try_arg_non_zero("shellescape('foo%', %v%)", "'foo%'", "'foo\\%'") call Try_arg_non_zero("shellescape('foo%', %v%)", "'foo%'", "'foo\\%'")
" visualmode() needs to be called twice to check " visualmode() needs to be called twice to check
for v in [v:false, 0, [1], {2:3}, 3.4] for v in [v:false, 0, [1], {2:3}, 3.4]
normal vv normal vv
let r = visualmode(v) let r = visualmode(v)
call assert_equal('v', r, 'result for ' . string(v) . ' is not "v" but ' . r) call assert_equal('v', r, 'result for ' . string(v) . ' is not "v" but ' . r)
let r = visualmode(v) let r = visualmode(v)
call assert_equal('v', r, 'result for ' . string(v) . ' is not "v" but ' . r) call assert_equal('v', r, 'result for ' . string(v) . ' is not "v" but ' . r)
endfor endfor
for v in [v:true, 1, " ", "0"] for v in [v:true, 1, " ", "0"]
normal vv normal vv
let r = visualmode(v) let r = visualmode(v)
call assert_equal('v', r, 'result for ' . v . ' is not "v" but ' . r) call assert_equal('v', r, 'result for ' . v . ' is not "v" but ' . r)

View File

@@ -1,5 +1,5 @@
" Tests for Unicode manipulations " Tests for Unicode manipulations
source check.vim source check.vim
source view_util.vim source view_util.vim
source screendump.vim source screendump.vim
@@ -112,7 +112,7 @@ func Test_list2str_str2list_latin1()
let save_encoding = &encoding let save_encoding = &encoding
" set encoding=latin1 " set encoding=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")) call assert_equal([65, 66, 67], str2list("ABC"))

View File

@@ -696,14 +696,14 @@ func Test_virtualedit_mouse()
set virtualedit& set virtualedit&
endfunc endfunc
" this was replacing the NUL at the end of the line " this was replacing the NUL at the end of the line
func Test_virtualedit_replace_after_tab() func Test_virtualedit_replace_after_tab()
new new
s/\v/ 0 s/\v/ 0
set ve=all set ve=all
let @" = '' let @" = ''
sil! norm vPvr0 sil! norm vPvr0
call assert_equal("\t0", getline(1)) call assert_equal("\t0", getline(1))
set ve& set ve&
bwipe! bwipe!

View File

@@ -1170,8 +1170,8 @@ endfunc
func Test_visual_put_in_block_using_zp() func Test_visual_put_in_block_using_zp()
new new
" paste using zP " paste using zP
call setline(1, ['/path;text', '/path;text', '/path;text', '', call setline(1, ['/path;text', '/path;text', '/path;text', '',
\ '/subdir', \ '/subdir',
\ '/longsubdir', \ '/longsubdir',
\ '/longlongsubdir']) \ '/longlongsubdir'])
exe "normal! 5G\<c-v>2j$y" exe "normal! 5G\<c-v>2j$y"
@@ -1179,8 +1179,8 @@ func Test_visual_put_in_block_using_zp()
call assert_equal(['/path/subdir;text', '/path/longsubdir;text', '/path/longlongsubdir;text'], getline(1, 3)) call assert_equal(['/path/subdir;text', '/path/longsubdir;text', '/path/longlongsubdir;text'], getline(1, 3))
%d %d
" paste using zP " paste using zP
call setline(1, ['/path;text', '/path;text', '/path;text', '', call setline(1, ['/path;text', '/path;text', '/path;text', '',
\ '/subdir', \ '/subdir',
\ '/longsubdir', \ '/longsubdir',
\ '/longlongsubdir']) \ '/longlongsubdir'])
exe "normal! 5G\<c-v>2j$y" exe "normal! 5G\<c-v>2j$y"
@@ -1193,7 +1193,7 @@ func Test_visual_put_in_block_using_zy_and_zp()
new new
" Test 1) Paste using zp - after the cursor without trailing spaces " Test 1) Paste using zp - after the cursor without trailing spaces
call setline(1, ['/path;text', '/path;text', '/path;text', '', call setline(1, ['/path;text', '/path;text', '/path;text', '',
\ 'texttext /subdir columntext', \ 'texttext /subdir columntext',
\ 'texttext /longsubdir columntext', \ 'texttext /longsubdir columntext',
\ 'texttext /longlongsubdir columntext']) \ 'texttext /longlongsubdir columntext'])
@@ -1203,7 +1203,7 @@ func Test_visual_put_in_block_using_zy_and_zp()
" Test 2) Paste using zP - in front of the cursor without trailing spaces " Test 2) Paste using zP - in front of the cursor without trailing spaces
%d %d
call setline(1, ['/path;text', '/path;text', '/path;text', '', call setline(1, ['/path;text', '/path;text', '/path;text', '',
\ 'texttext /subdir columntext', \ 'texttext /subdir columntext',
\ 'texttext /longsubdir columntext', \ 'texttext /longsubdir columntext',
\ 'texttext /longlongsubdir columntext']) \ 'texttext /longlongsubdir columntext'])
@@ -1213,7 +1213,7 @@ func Test_visual_put_in_block_using_zy_and_zp()
" Test 3) Paste using p - with trailing spaces " Test 3) Paste using p - with trailing spaces
%d %d
call setline(1, ['/path;text', '/path;text', '/path;text', '', call setline(1, ['/path;text', '/path;text', '/path;text', '',
\ 'texttext /subdir columntext', \ 'texttext /subdir columntext',
\ 'texttext /longsubdir columntext', \ 'texttext /longsubdir columntext',
\ 'texttext /longlongsubdir columntext']) \ 'texttext /longlongsubdir columntext'])
@@ -1223,7 +1223,7 @@ func Test_visual_put_in_block_using_zy_and_zp()
" Test 4) Paste using P - with trailing spaces " Test 4) Paste using P - with trailing spaces
%d %d
call setline(1, ['/path;text', '/path;text', '/path;text', '', call setline(1, ['/path;text', '/path;text', '/path;text', '',
\ 'texttext /subdir columntext', \ 'texttext /subdir columntext',
\ 'texttext /longsubdir columntext', \ 'texttext /longsubdir columntext',
\ 'texttext /longlongsubdir columntext']) \ 'texttext /longlongsubdir columntext'])
@@ -1233,7 +1233,7 @@ func Test_visual_put_in_block_using_zy_and_zp()
" Test 5) Yank with spaces inside the block " Test 5) Yank with spaces inside the block
%d %d
call setline(1, ['/path;text', '/path;text', '/path;text', '', call setline(1, ['/path;text', '/path;text', '/path;text', '',
\ 'texttext /sub dir/ columntext', \ 'texttext /sub dir/ columntext',
\ 'texttext /lon gsubdir/ columntext', \ 'texttext /lon gsubdir/ columntext',
\ 'texttext /lon glongsubdir/ columntext']) \ 'texttext /lon glongsubdir/ columntext'])

View File

@@ -223,7 +223,7 @@ func Test_window_close_splitright_noequalalways()
execute "normal \<c-w>b" execute "normal \<c-w>b"
let h = winheight(0) let h = winheight(0)
let w = win_getid() let w = win_getid()
new new
q q
call assert_equal(h, winheight(0), "Window height does not match eight before opening and closing another window") call assert_equal(h, winheight(0), "Window height does not match eight before opening and closing another window")
call assert_equal(w, win_getid(), "Did not return to original window after opening and closing a window") call assert_equal(w, win_getid(), "Did not return to original window after opening and closing a window")