mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 8.2.0216: several Vim9 instructions are not tested
Problem: Several Vim9 instructions are not tested. Solution: Add more tests. Fix :disassamble output. Make catch with pattern work.
This commit is contained in:
parent
a78e9c61a0
commit
ff80cb6807
@ -474,6 +474,15 @@ def s:ScriptFuncLoad(arg: string)
|
|||||||
echo @z
|
echo @z
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
def s:ScriptFuncPush()
|
||||||
|
let localbool = true
|
||||||
|
let localspec = v:none
|
||||||
|
let localblob = 0z1234
|
||||||
|
if has('float')
|
||||||
|
let localfloat = 1.234
|
||||||
|
endif
|
||||||
|
enddef
|
||||||
|
|
||||||
def s:ScriptFuncStore()
|
def s:ScriptFuncStore()
|
||||||
let localnr = 1
|
let localnr = 1
|
||||||
localnr = 2
|
localnr = 2
|
||||||
@ -487,6 +496,16 @@ def s:ScriptFuncStore()
|
|||||||
@z = 'rv'
|
@z = 'rv'
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
def s:ScriptFuncTry()
|
||||||
|
try
|
||||||
|
echo 'yes'
|
||||||
|
catch /fail/
|
||||||
|
echo 'no'
|
||||||
|
finally
|
||||||
|
echo 'end'
|
||||||
|
endtry
|
||||||
|
enddef
|
||||||
|
|
||||||
def Test_disassemble()
|
def Test_disassemble()
|
||||||
assert_fails('disass NoFunc', 'E1061:')
|
assert_fails('disass NoFunc', 'E1061:')
|
||||||
assert_fails('disass NotCompiled', 'E1062:')
|
assert_fails('disass NotCompiled', 'E1062:')
|
||||||
@ -504,9 +523,22 @@ def Test_disassemble()
|
|||||||
\ .. ' LOADREG @z.*'
|
\ .. ' LOADREG @z.*'
|
||||||
\, res)
|
\, res)
|
||||||
|
|
||||||
" TODO:
|
res = execute('disass s:ScriptFuncPush')
|
||||||
" v:char =
|
assert_match('<SNR>\d*_ScriptFuncPush.*'
|
||||||
" s:scriptvar =
|
\ .. 'localbool = true.*'
|
||||||
|
\ .. ' PUSH v:true.*'
|
||||||
|
\ .. 'localspec = v:none.*'
|
||||||
|
\ .. ' PUSH v:none.*'
|
||||||
|
\ .. 'localblob = 0z1234.*'
|
||||||
|
\ .. ' PUSHBLOB 0z1234.*'
|
||||||
|
\, res)
|
||||||
|
if has('float')
|
||||||
|
assert_match('<SNR>\d*_ScriptFuncPush.*'
|
||||||
|
\ .. 'localfloat = 1.234.*'
|
||||||
|
\ .. ' PUSHF 1.234.*'
|
||||||
|
\, res)
|
||||||
|
endif
|
||||||
|
|
||||||
res = execute('disass s:ScriptFuncStore')
|
res = execute('disass s:ScriptFuncStore')
|
||||||
assert_match('<SNR>\d*_ScriptFuncStore.*'
|
assert_match('<SNR>\d*_ScriptFuncStore.*'
|
||||||
\ .. 'localnr = 2.*'
|
\ .. 'localnr = 2.*'
|
||||||
@ -526,6 +558,23 @@ def Test_disassemble()
|
|||||||
\ .. '@z = ''rv''.*'
|
\ .. '@z = ''rv''.*'
|
||||||
\ .. ' STOREREG @z.*'
|
\ .. ' STOREREG @z.*'
|
||||||
\, res)
|
\, res)
|
||||||
|
|
||||||
|
res = execute('disass s:ScriptFuncTry')
|
||||||
|
assert_match('<SNR>\d*_ScriptFuncTry.*'
|
||||||
|
\ .. 'try.*'
|
||||||
|
\ .. 'TRY catch -> \d\+, finally -> \d\+.*'
|
||||||
|
\ .. 'catch /fail/.*'
|
||||||
|
\ .. ' JUMP -> \d\+.*'
|
||||||
|
\ .. ' PUSH v:exception.*'
|
||||||
|
\ .. ' PUSHS "fail".*'
|
||||||
|
\ .. ' COMPARESTRING =\~.*'
|
||||||
|
\ .. ' JUMP_IF_FALSE -> \d\+.*'
|
||||||
|
\ .. ' CATCH.*'
|
||||||
|
\ .. 'finally.*'
|
||||||
|
\ .. ' PUSHS "end".*'
|
||||||
|
\ .. 'endtry.*'
|
||||||
|
\ .. ' ENDTRY.*'
|
||||||
|
\, res)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
|
||||||
|
@ -742,6 +742,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 */
|
||||||
|
/**/
|
||||||
|
216,
|
||||||
/**/
|
/**/
|
||||||
215,
|
215,
|
||||||
/**/
|
/**/
|
||||||
|
@ -4369,13 +4369,33 @@ compile_catch(char_u *arg, cctx_T *cctx UNUSED)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
char_u *end;
|
||||||
|
char_u *pat;
|
||||||
|
char_u *tofree = NULL;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
// Push v:exception, push {expr} and MATCH
|
// Push v:exception, push {expr} and MATCH
|
||||||
generate_instr_type(cctx, ISN_PUSHEXC, &t_string);
|
generate_instr_type(cctx, ISN_PUSHEXC, &t_string);
|
||||||
|
|
||||||
if (compile_expr1(&p, cctx) == FAIL)
|
end = skip_regexp(p + 1, *p, TRUE, &tofree);
|
||||||
return NULL;
|
if (*end != *p)
|
||||||
|
{
|
||||||
|
semsg(_("E1067: Separator mismatch: %s"), p);
|
||||||
|
vim_free(tofree);
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
if (tofree == NULL)
|
||||||
|
len = end - (p + 1);
|
||||||
|
else
|
||||||
|
len = end - (tofree + 1);
|
||||||
|
pat = vim_strnsave(p + 1, len);
|
||||||
|
vim_free(tofree);
|
||||||
|
p += len + 2;
|
||||||
|
if (pat == NULL)
|
||||||
|
return FAIL;
|
||||||
|
if (generate_PUSHS(cctx, pat) == FAIL)
|
||||||
|
return FAIL;
|
||||||
|
|
||||||
// TODO: check for strings?
|
|
||||||
if (generate_COMPARE(cctx, EXPR_MATCH, FALSE) == FAIL)
|
if (generate_COMPARE(cctx, EXPR_MATCH, FALSE) == FAIL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -1726,7 +1726,7 @@ ex_disassemble(exarg_T *eap)
|
|||||||
char_u *tofree;
|
char_u *tofree;
|
||||||
|
|
||||||
r = blob2string(iptr->isn_arg.blob, &tofree, numbuf);
|
r = blob2string(iptr->isn_arg.blob, &tofree, numbuf);
|
||||||
smsg("%4d PUSHBLOB \"%s\"", current, r);
|
smsg("%4d PUSHBLOB %s", current, r);
|
||||||
vim_free(tofree);
|
vim_free(tofree);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user