mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.2.0503: Vim9: some code is not tested
Problem: Vim9: some code is not tested. Solution: Add tests. Fix uncovered problems.
This commit is contained in:
@@ -112,6 +112,8 @@ def Test_assignment()
|
|||||||
call CheckDefFailure(['¬ex += 3'], 'E113:')
|
call CheckDefFailure(['¬ex += 3'], 'E113:')
|
||||||
call CheckDefFailure(['&ts ..= "xxx"'], 'E1019:')
|
call CheckDefFailure(['&ts ..= "xxx"'], 'E1019:')
|
||||||
call CheckDefFailure(['&path += 3'], 'E1013:')
|
call CheckDefFailure(['&path += 3'], 'E1013:')
|
||||||
|
" test freeing ISN_STOREOPT
|
||||||
|
call CheckDefFailure(['&ts = 3', 'let asdf'], 'E1022:')
|
||||||
&ts = 8
|
&ts = 8
|
||||||
|
|
||||||
g:inc_counter += 1
|
g:inc_counter += 1
|
||||||
@@ -171,6 +173,9 @@ def Test_assignment()
|
|||||||
let thechannel: channel
|
let thechannel: channel
|
||||||
assert_equal(test_null_channel(), thechannel)
|
assert_equal(test_null_channel(), thechannel)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
let nr = 1234 | nr = 5678
|
||||||
|
assert_equal(5678, nr)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
func Test_assignment_failure()
|
func Test_assignment_failure()
|
||||||
@@ -253,8 +258,16 @@ enddef
|
|||||||
|
|
||||||
func Test_block_failure()
|
func Test_block_failure()
|
||||||
call CheckDefFailure(['{', 'let inner = 1', '}', 'echo inner'], 'E1001:')
|
call CheckDefFailure(['{', 'let inner = 1', '}', 'echo inner'], 'E1001:')
|
||||||
|
call CheckDefFailure(['}'], 'E1025:')
|
||||||
|
call CheckDefFailure(['{', 'echo 1'], 'E1026:')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
def Test_cmd_modifier()
|
||||||
|
tab echo '0'
|
||||||
|
call CheckDefFailure(['5tab echo 3'], 'E16:')
|
||||||
|
enddef
|
||||||
|
|
||||||
|
|
||||||
def ReturnString(): string
|
def ReturnString(): string
|
||||||
return 'string'
|
return 'string'
|
||||||
enddef
|
enddef
|
||||||
@@ -326,6 +339,8 @@ def Test_call_default_args()
|
|||||||
assert_equal('string', MyDefaultArgs())
|
assert_equal('string', MyDefaultArgs())
|
||||||
assert_equal('one', MyDefaultArgs('one'))
|
assert_equal('one', MyDefaultArgs('one'))
|
||||||
assert_fails('call MyDefaultArgs("one", "two")', 'E118:')
|
assert_fails('call MyDefaultArgs("one", "two")', 'E118:')
|
||||||
|
|
||||||
|
call CheckScriptFailure(['def Func(arg: number = asdf)', 'enddef'], 'E1001:')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
func Test_call_default_args_from_func()
|
func Test_call_default_args_from_func()
|
||||||
@@ -480,6 +495,16 @@ def Test_try_catch_fails()
|
|||||||
call CheckDefFailure(['catch'], 'E603:')
|
call CheckDefFailure(['catch'], 'E603:')
|
||||||
call CheckDefFailure(['try', 'echo 0', 'catch','catch'], 'E1033:')
|
call CheckDefFailure(['try', 'echo 0', 'catch','catch'], 'E1033:')
|
||||||
call CheckDefFailure(['try', 'echo 0', 'catch /pat'], 'E1067:')
|
call CheckDefFailure(['try', 'echo 0', 'catch /pat'], 'E1067:')
|
||||||
|
call CheckDefFailure(['finally'], 'E606:')
|
||||||
|
call CheckDefFailure(['try', 'echo 0', 'finally', 'echo 1', 'finally'], 'E607:')
|
||||||
|
call CheckDefFailure(['endtry'], 'E602:')
|
||||||
|
call CheckDefFailure(['while 1', 'endtry'], 'E170:')
|
||||||
|
call CheckDefFailure(['for i in range(5)', 'endtry'], 'E170:')
|
||||||
|
call CheckDefFailure(['if 2', 'endtry'], 'E171:')
|
||||||
|
call CheckDefFailure(['try', 'echo 1', 'endtry'], 'E1032:')
|
||||||
|
|
||||||
|
call CheckDefFailure(['throw'], 'E471:')
|
||||||
|
call CheckDefFailure(['throw xxx'], 'E1001:')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
let s:export_script_lines =<< trim END
|
let s:export_script_lines =<< trim END
|
||||||
@@ -939,6 +964,7 @@ def Test_if_elseif_else_fails()
|
|||||||
call CheckDefFailure(['else'], 'E581:')
|
call CheckDefFailure(['else'], 'E581:')
|
||||||
call CheckDefFailure(['endif'], 'E580:')
|
call CheckDefFailure(['endif'], 'E580:')
|
||||||
call CheckDefFailure(['if true', 'elseif xxx'], 'E1001:')
|
call CheckDefFailure(['if true', 'elseif xxx'], 'E1001:')
|
||||||
|
call CheckDefFailure(['if true', 'echo 1'], 'E171:')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
let g:bool_true = v:true
|
let g:bool_true = v:true
|
||||||
@@ -951,6 +977,16 @@ def Test_if_const_expr()
|
|||||||
endif
|
endif
|
||||||
assert_equal(true, res)
|
assert_equal(true, res)
|
||||||
|
|
||||||
|
g:glob = 2
|
||||||
|
if false
|
||||||
|
execute('let g:glob = 3')
|
||||||
|
endif
|
||||||
|
assert_equal(2, g:glob)
|
||||||
|
if true
|
||||||
|
execute('let g:glob = 3')
|
||||||
|
endif
|
||||||
|
assert_equal(3, g:glob)
|
||||||
|
|
||||||
res = false
|
res = false
|
||||||
if g:bool_true ? true : false
|
if g:bool_true ? true : false
|
||||||
res = true
|
res = true
|
||||||
@@ -1092,10 +1128,13 @@ def Test_execute_cmd()
|
|||||||
execute cmd_first .. cmd_last
|
execute cmd_first .. cmd_last
|
||||||
assert_equal('execute-var-var', getline(1))
|
assert_equal('execute-var-var', getline(1))
|
||||||
bwipe!
|
bwipe!
|
||||||
|
|
||||||
|
call CheckDefFailure(['execute xxx'], 'E1001:')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_echo_cmd()
|
def Test_echo_cmd()
|
||||||
echo 'something'
|
echo 'some'
|
||||||
|
echon 'thing'
|
||||||
assert_match('^something$', Screenline(&lines))
|
assert_match('^something$', Screenline(&lines))
|
||||||
|
|
||||||
let str1 = 'some'
|
let str1 = 'some'
|
||||||
@@ -1141,6 +1180,7 @@ def Test_for_loop_fails()
|
|||||||
call CheckDefFailure(['for i in "text"'], 'E1024:')
|
call CheckDefFailure(['for i in "text"'], 'E1024:')
|
||||||
call CheckDefFailure(['for i in xxx'], 'E1001:')
|
call CheckDefFailure(['for i in xxx'], 'E1001:')
|
||||||
call CheckDefFailure(['endfor'], 'E588:')
|
call CheckDefFailure(['endfor'], 'E588:')
|
||||||
|
call CheckDefFailure(['for i in range(3)', 'echo 3'], 'E170:')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_while_loop()
|
def Test_while_loop()
|
||||||
@@ -1166,6 +1206,7 @@ def Test_while_loop_fails()
|
|||||||
call CheckDefFailure(['if true', 'continue'], 'E586:')
|
call CheckDefFailure(['if true', 'continue'], 'E586:')
|
||||||
call CheckDefFailure(['break'], 'E587:')
|
call CheckDefFailure(['break'], 'E587:')
|
||||||
call CheckDefFailure(['if true', 'break'], 'E587:')
|
call CheckDefFailure(['if true', 'break'], 'E587:')
|
||||||
|
call CheckDefFailure(['while 1', 'echo 3'], 'E170:')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_interrupt_loop()
|
def Test_interrupt_loop()
|
||||||
@@ -1185,28 +1226,6 @@ def Test_interrupt_loop()
|
|||||||
assert_true(caught, 'should have caught an exception')
|
assert_true(caught, 'should have caught an exception')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_substitute_cmd()
|
|
||||||
new
|
|
||||||
setline(1, 'something')
|
|
||||||
:substitute(some(other(
|
|
||||||
assert_equal('otherthing', getline(1))
|
|
||||||
bwipe!
|
|
||||||
|
|
||||||
" also when the context is Vim9 script
|
|
||||||
let lines =<< trim END
|
|
||||||
vim9script
|
|
||||||
new
|
|
||||||
setline(1, 'something')
|
|
||||||
:substitute(some(other(
|
|
||||||
assert_equal('otherthing', getline(1))
|
|
||||||
bwipe!
|
|
||||||
END
|
|
||||||
writefile(lines, 'Xvim9lines')
|
|
||||||
source Xvim9lines
|
|
||||||
|
|
||||||
delete('Xvim9lines')
|
|
||||||
enddef
|
|
||||||
|
|
||||||
def Test_redef_failure()
|
def Test_redef_failure()
|
||||||
call writefile(['def Func0(): string', 'return "Func0"', 'enddef'], 'Xdef')
|
call writefile(['def Func0(): string', 'return "Func0"', 'enddef'], 'Xdef')
|
||||||
so Xdef
|
so Xdef
|
||||||
@@ -1285,4 +1304,27 @@ func Test_internalfunc_arg_error()
|
|||||||
call delete('Xinvalidarg')
|
call delete('Xinvalidarg')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Keep this last, it messes up highlighting.
|
||||||
|
def Test_substitute_cmd()
|
||||||
|
new
|
||||||
|
setline(1, 'something')
|
||||||
|
:substitute(some(other(
|
||||||
|
assert_equal('otherthing', getline(1))
|
||||||
|
bwipe!
|
||||||
|
|
||||||
|
" also when the context is Vim9 script
|
||||||
|
let lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
new
|
||||||
|
setline(1, 'something')
|
||||||
|
:substitute(some(other(
|
||||||
|
assert_equal('otherthing', getline(1))
|
||||||
|
bwipe!
|
||||||
|
END
|
||||||
|
writefile(lines, 'Xvim9lines')
|
||||||
|
source Xvim9lines
|
||||||
|
|
||||||
|
delete('Xvim9lines')
|
||||||
|
enddef
|
||||||
|
|
||||||
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
|
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
|
||||||
|
@@ -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 */
|
||||||
|
/**/
|
||||||
|
503,
|
||||||
/**/
|
/**/
|
||||||
502,
|
502,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -4972,6 +4972,7 @@ compile_finally(char_u *arg, cctx_T *cctx)
|
|||||||
// Fill in the "end" label in jumps at the end of the blocks.
|
// Fill in the "end" label in jumps at the end of the blocks.
|
||||||
compile_fill_jump_to_end(&scope->se_u.se_try.ts_end_label, cctx);
|
compile_fill_jump_to_end(&scope->se_u.se_try.ts_end_label, cctx);
|
||||||
|
|
||||||
|
isn->isn_arg.try.try_finally = instr->ga_len;
|
||||||
if (scope->se_u.se_try.ts_catch_label != 0)
|
if (scope->se_u.se_try.ts_catch_label != 0)
|
||||||
{
|
{
|
||||||
// Previous catch without match jumps here
|
// Previous catch without match jumps here
|
||||||
@@ -4979,7 +4980,6 @@ compile_finally(char_u *arg, cctx_T *cctx)
|
|||||||
isn->isn_arg.jump.jump_where = instr->ga_len;
|
isn->isn_arg.jump.jump_where = instr->ga_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
isn->isn_arg.try.try_finally = instr->ga_len;
|
|
||||||
// TODO: set index in ts_finally_label jumps
|
// TODO: set index in ts_finally_label jumps
|
||||||
|
|
||||||
return arg;
|
return arg;
|
||||||
@@ -5350,13 +5350,7 @@ compile_def_function(ufunc_T *ufunc, int set_return_type)
|
|||||||
line = p;
|
line = p;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (ea.cmdidx == CMD_let)
|
// CMD_let cannot happen, compile_assignment() above is used
|
||||||
{
|
|
||||||
line = compile_assignment(ea.cmd, &ea, CMD_SIZE, &cctx);
|
|
||||||
if (line == NULL)
|
|
||||||
goto erret;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
iemsg("Command from find_ex_command() not handled");
|
iemsg("Command from find_ex_command() not handled");
|
||||||
goto erret;
|
goto erret;
|
||||||
}
|
}
|
||||||
@@ -5464,6 +5458,7 @@ compile_def_function(ufunc_T *ufunc, int set_return_type)
|
|||||||
}
|
}
|
||||||
if (line == NULL)
|
if (line == NULL)
|
||||||
goto erret;
|
goto erret;
|
||||||
|
line = skipwhite(line);
|
||||||
|
|
||||||
if (cctx.ctx_type_stack.ga_len < 0)
|
if (cctx.ctx_type_stack.ga_len < 0)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user