forked from aniani/vim
patch 8.2.0218: several Vim9 instructions are not tested
Problem: Several Vim9 instructions are not tested. Solution: Add more tests.
This commit is contained in:
@@ -474,6 +474,24 @@ def s:ScriptFuncLoad(arg: string)
|
|||||||
echo @z
|
echo @z
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
def Test_disassembleLoad()
|
||||||
|
assert_fails('disass NoFunc', 'E1061:')
|
||||||
|
assert_fails('disass NotCompiled', 'E1062:')
|
||||||
|
|
||||||
|
let res = execute('disass s:ScriptFuncLoad')
|
||||||
|
assert_match('<SNR>\d*_ScriptFuncLoad.*'
|
||||||
|
\ .. 'buffers.*'
|
||||||
|
\ .. ' EXEC \+buffers.*'
|
||||||
|
\ .. ' LOAD arg\[-1\].*'
|
||||||
|
\ .. ' LOAD $0.*'
|
||||||
|
\ .. ' LOADV v:version.*'
|
||||||
|
\ .. ' LOADS s:scriptvar from .*test_vim9_script.vim.*'
|
||||||
|
\ .. ' LOADG g:globalvar.*'
|
||||||
|
\ .. ' LOADENV $ENVVAR.*'
|
||||||
|
\ .. ' LOADREG @z.*'
|
||||||
|
\, res)
|
||||||
|
enddef
|
||||||
|
|
||||||
def s:ScriptFuncPush()
|
def s:ScriptFuncPush()
|
||||||
let localbool = true
|
let localbool = true
|
||||||
let localspec = v:none
|
let localspec = v:none
|
||||||
@@ -483,6 +501,24 @@ def s:ScriptFuncPush()
|
|||||||
endif
|
endif
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
def Test_disassemblePush()
|
||||||
|
let res = execute('disass s:ScriptFuncPush')
|
||||||
|
assert_match('<SNR>\d*_ScriptFuncPush.*'
|
||||||
|
\ .. '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
|
||||||
|
enddef
|
||||||
|
|
||||||
def s:ScriptFuncStore()
|
def s:ScriptFuncStore()
|
||||||
let localnr = 1
|
let localnr = 1
|
||||||
localnr = 2
|
localnr = 2
|
||||||
@@ -496,50 +532,8 @@ def s:ScriptFuncStore()
|
|||||||
@z = 'rv'
|
@z = 'rv'
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def s:ScriptFuncTry()
|
def Test_disassembleStore()
|
||||||
try
|
let res = execute('disass s:ScriptFuncStore')
|
||||||
echo 'yes'
|
|
||||||
catch /fail/
|
|
||||||
echo 'no'
|
|
||||||
finally
|
|
||||||
echo 'end'
|
|
||||||
endtry
|
|
||||||
enddef
|
|
||||||
|
|
||||||
def Test_disassemble()
|
|
||||||
assert_fails('disass NoFunc', 'E1061:')
|
|
||||||
assert_fails('disass NotCompiled', 'E1062:')
|
|
||||||
|
|
||||||
let res = execute('disass s:ScriptFuncLoad')
|
|
||||||
assert_match('<SNR>\d*_ScriptFuncLoad.*'
|
|
||||||
\ .. 'buffers.*'
|
|
||||||
\ .. ' EXEC \+buffers.*'
|
|
||||||
\ .. ' LOAD arg\[-1\].*'
|
|
||||||
\ .. ' LOAD $0.*'
|
|
||||||
\ .. ' LOADV v:version.*'
|
|
||||||
\ .. ' LOADS s:scriptvar from .*test_vim9_script.vim.*'
|
|
||||||
\ .. ' LOADG g:globalvar.*'
|
|
||||||
\ .. ' LOADENV $ENVVAR.*'
|
|
||||||
\ .. ' LOADREG @z.*'
|
|
||||||
\, res)
|
|
||||||
|
|
||||||
res = execute('disass s:ScriptFuncPush')
|
|
||||||
assert_match('<SNR>\d*_ScriptFuncPush.*'
|
|
||||||
\ .. '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')
|
|
||||||
assert_match('<SNR>\d*_ScriptFuncStore.*'
|
assert_match('<SNR>\d*_ScriptFuncStore.*'
|
||||||
\ .. 'localnr = 2.*'
|
\ .. 'localnr = 2.*'
|
||||||
\ .. ' STORE 2 in $0.*'
|
\ .. ' STORE 2 in $0.*'
|
||||||
@@ -558,8 +552,20 @@ def Test_disassemble()
|
|||||||
\ .. '@z = ''rv''.*'
|
\ .. '@z = ''rv''.*'
|
||||||
\ .. ' STOREREG @z.*'
|
\ .. ' STOREREG @z.*'
|
||||||
\, res)
|
\, res)
|
||||||
|
enddef
|
||||||
|
|
||||||
res = execute('disass s:ScriptFuncTry')
|
def s:ScriptFuncTry()
|
||||||
|
try
|
||||||
|
echo 'yes'
|
||||||
|
catch /fail/
|
||||||
|
echo 'no'
|
||||||
|
finally
|
||||||
|
echo 'end'
|
||||||
|
endtry
|
||||||
|
enddef
|
||||||
|
|
||||||
|
def Test_disassembleTry()
|
||||||
|
let res = execute('disass s:ScriptFuncTry')
|
||||||
assert_match('<SNR>\d*_ScriptFuncTry.*'
|
assert_match('<SNR>\d*_ScriptFuncTry.*'
|
||||||
\ .. 'try.*'
|
\ .. 'try.*'
|
||||||
\ .. 'TRY catch -> \d\+, finally -> \d\+.*'
|
\ .. 'TRY catch -> \d\+, finally -> \d\+.*'
|
||||||
@@ -577,5 +583,86 @@ def Test_disassemble()
|
|||||||
\, res)
|
\, res)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
def s:ScriptFuncNew()
|
||||||
|
let ll = [1, "two", 333]
|
||||||
|
let dd = #{one: 1, two: "val"}
|
||||||
|
enddef
|
||||||
|
|
||||||
|
def Test_disassembleNew()
|
||||||
|
let res = execute('disass s:ScriptFuncNew')
|
||||||
|
assert_match('<SNR>\d*_ScriptFuncNew.*'
|
||||||
|
\ .. 'let ll = \[1, "two", 333].*'
|
||||||
|
\ .. 'PUSHNR 1.*'
|
||||||
|
\ .. 'PUSHS "two".*'
|
||||||
|
\ .. 'PUSHNR 333.*'
|
||||||
|
\ .. 'NEWLIST size 3.*'
|
||||||
|
\ .. 'let dd = #{one: 1, two: "val"}.*'
|
||||||
|
\ .. 'PUSHS "one".*'
|
||||||
|
\ .. 'PUSHNR 1.*'
|
||||||
|
\ .. 'PUSHS "two".*'
|
||||||
|
\ .. 'PUSHS "val".*'
|
||||||
|
\ .. 'NEWDICT size 2.*'
|
||||||
|
\, res)
|
||||||
|
enddef
|
||||||
|
|
||||||
|
def FuncWithArg(arg)
|
||||||
|
echo arg
|
||||||
|
enddef
|
||||||
|
|
||||||
|
func UserFunc()
|
||||||
|
echo 'nothing'
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func UserFuncWithArg(arg)
|
||||||
|
echo a:arg
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
def s:ScriptFuncCall(): string
|
||||||
|
changenr()
|
||||||
|
char2nr("abc")
|
||||||
|
Test_disassembleNew()
|
||||||
|
FuncWithArg(343)
|
||||||
|
UserFunc()
|
||||||
|
UserFuncWithArg("foo")
|
||||||
|
let FuncRef = function("UserFunc")
|
||||||
|
FuncRef()
|
||||||
|
let FuncRefWithArg = function("UserFuncWithArg")
|
||||||
|
FuncRefWithArg("bar")
|
||||||
|
return "yes"
|
||||||
|
enddef
|
||||||
|
|
||||||
|
def Test_disassembleCall()
|
||||||
|
let res = execute('disass s:ScriptFuncCall')
|
||||||
|
assert_match('<SNR>\d*_ScriptFuncCall.*'
|
||||||
|
\ .. 'changenr().*'
|
||||||
|
\ .. ' BCALL changenr(argc 0).*'
|
||||||
|
\ .. 'char2nr("abc").*'
|
||||||
|
\ .. ' PUSHS "abc".*'
|
||||||
|
\ .. ' BCALL char2nr(argc 1).*'
|
||||||
|
\ .. 'Test_disassembleNew().*'
|
||||||
|
\ .. ' DCALL Test_disassembleNew(argc 0).*'
|
||||||
|
\ .. 'FuncWithArg(343).*'
|
||||||
|
\ .. ' PUSHNR 343.*'
|
||||||
|
\ .. ' DCALL FuncWithArg(argc 1).*'
|
||||||
|
\ .. 'UserFunc().*'
|
||||||
|
\ .. ' UCALL UserFunc(argc 0).*'
|
||||||
|
\ .. 'UserFuncWithArg("foo").*'
|
||||||
|
\ .. ' PUSHS "foo".*'
|
||||||
|
\ .. ' UCALL UserFuncWithArg(argc 1).*'
|
||||||
|
\ .. 'let FuncRef = function("UserFunc").*'
|
||||||
|
\ .. 'FuncRef().*'
|
||||||
|
\ .. ' LOAD $\d.*'
|
||||||
|
\ .. ' PCALL (argc 0).*'
|
||||||
|
\ .. 'let FuncRefWithArg = function("UserFuncWithArg").*'
|
||||||
|
\ .. 'FuncRefWithArg("bar").*'
|
||||||
|
\ .. ' PUSHS "bar".*'
|
||||||
|
\ .. ' LOAD $\d.*'
|
||||||
|
\ .. ' PCALL (argc 1).*'
|
||||||
|
\ .. 'return "yes".*'
|
||||||
|
\ .. ' PUSHS "yes".*'
|
||||||
|
\ .. ' RETURN.*'
|
||||||
|
\, res)
|
||||||
|
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
|
||||||
|
@@ -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 */
|
||||||
|
/**/
|
||||||
|
218,
|
||||||
/**/
|
/**/
|
||||||
217,
|
217,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user