0
0
mirror of https://github.com/vim/vim.git synced 2025-10-04 05:25:06 -04:00

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.
This commit is contained in:
Bram Moolenaar
2023-01-28 19:19:03 +00:00
parent 04e4f1d985
commit 94722c5107
56 changed files with 247 additions and 208 deletions

View File

@@ -4,8 +4,8 @@ vim9script
#
# Usage: vim -u NONE -S keycode_check.vim
#
# Author: Bram Moolenaar
# Last Update: 2022 Nov 15
# Author: Bram Moolenaar
# Last Update: 2022 Nov 15
#
# The codes are stored in the file "keycode_check.json", so that you can
# compare the results of various terminals.
@@ -449,7 +449,7 @@ enddef
# The main loop
while true
var action = inputlist(['Select operation:',
'1. List results',
'1. List results',
'2. Add results for a new terminal',
'3. Replace results',
'4. Clear results',

View File

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

View File

@@ -41,5 +41,42 @@ def Test_source_files()
bwipe!
enddef
def Test_test_files()
for fname in glob('*.vim', 0, 1)
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'
cursor(1, 1)
var lnum = search(fname =~ "test_regexp_latin" ? '[^á] \t' : ' \t')
assert_equal(0, lnum, 'testdir/' .. fname .. ': 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'
cursor(1, 1)
var 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$')
assert_equal(0, lnum, 'testdir/' .. fname .. ': trailing white space')
endif
endfor
bwipe!
enddef
" vim: shiftwidth=2 sts=2 expandtab

View File

@@ -1113,7 +1113,7 @@ func Test_diff_with_syntax()
CheckScreendump
let lines =<< trim END
void doNothing() {
void doNothing() {
int x = 0;
char *s = "hello";
return 5;
@@ -1121,7 +1121,7 @@ func Test_diff_with_syntax()
END
call writefile(lines, 'Xprogram1.c', 'D')
let lines =<< trim END
void doSomething() {
void doSomething() {
int x = 0;
char *s = "there";
return 5;
@@ -1130,7 +1130,7 @@ func Test_diff_with_syntax()
call writefile(lines, 'Xprogram2.c', 'D')
let lines =<< trim END
edit Xprogram1.c
edit Xprogram1.c
diffsplit Xprogram2.c
END
call writefile(lines, 'Xtest_diff_syntax', 'D')

View File

@@ -1211,20 +1211,20 @@ func Test_efm1()
"Xtestfile", linenr 16: yet another problem
Error in "Xtestfile" at line 17:
x should be a dot
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 17
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 17
^
Error in "Xtestfile" at line 18:
x should be a dot
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 18
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 18
.............^
Error in "Xtestfile" at line 19:
x should be a dot
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 19
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 19
--------------^
Error in "Xtestfile" at line 20:
x should be a dot
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 20
^
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 20
^
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?

View File

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

View File

@@ -74,7 +74,7 @@ def Test_expr1_ternary_vimscript()
# check line continuation
var lines =<< trim END
var name = 1
? 'yes'
? 'yes'
: 'no'
assert_equal('yes', name)
END
@@ -82,7 +82,7 @@ def Test_expr1_ternary_vimscript()
lines =<< trim END
var name = v:false
? 'yes'
? 'yes'
: 'no'
assert_equal('no', name)
END
@@ -90,7 +90,7 @@ def Test_expr1_ternary_vimscript()
lines =<< trim END
var name = v:false ?
'yes' :
'yes' :
'no'
assert_equal('no', name)
END
@@ -98,7 +98,7 @@ def Test_expr1_ternary_vimscript()
lines =<< trim END
var name = v:false ? # comment
'yes' :
'yes' :
# comment
'no' # comment
assert_equal('no', name)
@@ -317,22 +317,22 @@ def Test_expr2_vimscript()
# check line continuation
var lines =<< trim END
var name = 0
|| 1
|| 1
assert_equal(true, name)
END
v9.CheckDefAndScriptSuccess(lines)
lines =<< trim END
var name = v:false
|| v:true
|| v:false
|| v:true
|| v:false
assert_equal(v:true, name)
END
v9.CheckDefAndScriptSuccess(lines)
lines =<< trim END
var name = v:false ||
v:true ||
v:true ||
v:false
assert_equal(v:true, name)
END
@@ -341,7 +341,7 @@ def Test_expr2_vimscript()
lines =<< trim END
var name = v:false || # comment
# comment
v:true ||
v:true ||
# comment
v:false # comment
assert_equal(v:true, name)
@@ -456,23 +456,23 @@ def Test_expr3_vimscript()
# check line continuation
var lines =<< trim END
var name = 0
&& 1
&& 1
assert_equal(false, name)
END
v9.CheckDefAndScriptSuccess(lines)
lines =<< trim END
var name = v:true
&& v:true
&& v:true
&& v:true
&& v:true
assert_equal(v:true, name)
END
v9.CheckDefAndScriptSuccess(lines)
lines =<< trim END
var name = v:true &&
v:true &&
v:true
v:true &&
v:true
assert_equal(v:true, name)
END
v9.CheckDefAndScriptSuccess(lines)
@@ -480,9 +480,9 @@ def Test_expr3_vimscript()
lines =<< trim END
var name = v:true && # comment
# comment
v:true &&
v:true &&
# comment
v:true
v:true
assert_equal(v:true, name)
END
v9.CheckDefAndScriptSuccess(lines)
@@ -1274,7 +1274,7 @@ def Test_expr4_vim9script()
# check line continuation
var lines =<< trim END
var name = 0
< 1
< 1
assert_equal(true, name)
END
v9.CheckDefAndScriptSuccess(lines)
@@ -1282,14 +1282,14 @@ def Test_expr4_vim9script()
lines =<< trim END
var name = 123
# comment
!= 123
!= 123
assert_equal(false, name)
END
v9.CheckDefAndScriptSuccess(lines)
lines =<< trim END
var name = 123 ==
123
123
assert_equal(true, name)
END
v9.CheckDefAndScriptSuccess(lines)
@@ -1297,7 +1297,7 @@ def Test_expr4_vim9script()
lines =<< trim END
var list = [1, 2, 3]
var name = list
is list
is list
assert_equal(true, name)
END
v9.CheckDefAndScriptSuccess(lines)
@@ -1306,7 +1306,7 @@ def Test_expr4_vim9script()
var list = [1, 2, 3]
var name = list # comment
# comment
is list
is list
assert_equal(true, name)
END
v9.CheckDefAndScriptSuccess(lines)
@@ -1314,7 +1314,7 @@ def Test_expr4_vim9script()
lines =<< trim END
var myblob = 0z1234
var name = myblob
isnot 0z11
isnot 0z11
assert_equal(true, name)
END
v9.CheckDefAndScriptSuccess(lines)
@@ -1526,7 +1526,7 @@ def Test_expr6_vim9script()
# check line continuation
var lines =<< trim END
var name = 11
+ 77
+ 77
- 22
assert_equal(66, name)
END
@@ -1551,7 +1551,7 @@ def Test_expr6_vim9script()
lines =<< trim END
var name = 'one'
.. 'two'
.. 'two'
assert_equal('onetwo', name)
END
v9.CheckDefAndScriptSuccess(lines)
@@ -1859,7 +1859,7 @@ def Test_expr7_vim9script()
# check line continuation
var lines =<< trim END
var name = 11
* 22
* 22
/ 3
assert_equal(80, name)
END
@@ -1867,7 +1867,7 @@ def Test_expr7_vim9script()
lines =<< trim END
var name = 25
% 10
% 10
assert_equal(5, name)
END
v9.CheckDefAndScriptSuccess(lines)
@@ -1877,14 +1877,14 @@ def Test_expr7_vim9script()
# comment
# comment
% 10
% 10
assert_equal(5, name)
END
v9.CheckDefAndScriptSuccess(lines)
lines =<< trim END
var name = 11 *
22 /
22 /
3
assert_equal(80, name)
END
@@ -3206,7 +3206,7 @@ enddef
def Test_expr_member_vim9script()
var lines =<< trim END
var d = {one:
'one',
'one',
two: 'two',
1: 1,
_: 2}

View File

@@ -2176,7 +2176,7 @@ def Test_error_in_function_args()
# Nois
# one
enddef|BBBB
enddef|BBBB
enddef
# Compile all functions
defcompile

View File

@@ -195,14 +195,14 @@ endfunc
# CheckLegacyAndVim9Success()
export def CheckTransLegacySuccess(lines: list<string>)
var legacylines = lines->mapnew((_, v) =>
v->substitute('\<VAR\>', 'let', 'g')
->substitute('\<LET\>', 'let', 'g')
->substitute('\<LSTART\>', '{', 'g')
->substitute('\<LMIDDLE\>', '->', 'g')
v->substitute('\<VAR\>', 'let', 'g')
->substitute('\<LET\>', 'let', 'g')
->substitute('\<LSTART\>', '{', 'g')
->substitute('\<LMIDDLE\>', '->', 'g')
->substitute('\<LEND\>', '}', 'g')
->substitute('\<TRUE\>', '1', 'g')
->substitute('\<FALSE\>', '0', 'g')
->substitute('#"', ' "', 'g'))
->substitute('#"', ' "', 'g'))
CheckLegacySuccess(legacylines)
enddef
@@ -262,14 +262,14 @@ export def CheckLegacyAndVim9Failure(lines: list<string>, error: any)
endif
var legacylines = lines->mapnew((_, v) =>
v->substitute('\<VAR\>', 'let', 'g')
->substitute('\<LET\>', 'let', 'g')
->substitute('#"', ' "', 'g'))
v->substitute('\<VAR\>', 'let', 'g')
->substitute('\<LET\>', 'let', 'g')
->substitute('#"', ' "', 'g'))
CheckLegacyFailure(legacylines, legacyError)
var vim9lines = lines->mapnew((_, v) =>
v->substitute('\<VAR\>', 'var', 'g')
->substitute('\<LET ', '', 'g'))
v->substitute('\<VAR\>', 'var', 'g')
->substitute('\<LET ', '', 'g'))
CheckDefExecFailure(vim9lines, defError)
CheckScriptFailure(['vim9script'] + vim9lines, scriptError)
enddef

View File

@@ -695,6 +695,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1257,
/**/
1256,
/**/