Skip to content

Commit 0de5086

Browse files
committed
patch 8.2.0218: several Vim9 instructions are not tested
Problem: Several Vim9 instructions are not tested. Solution: Add more tests.
1 parent adbc11c commit 0de5086

2 files changed

Lines changed: 125 additions & 36 deletions

File tree

src/testdir/test_vim9_script.vim

Lines changed: 123 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -474,39 +474,7 @@ def s:ScriptFuncLoad(arg: string)
474474
echo @z
475475
enddef
476476

477-
def s:ScriptFuncPush()
478-
let localbool = true
479-
let localspec = v:none
480-
let localblob = 0z1234
481-
if has('float')
482-
let localfloat = 1.234
483-
endif
484-
enddef
485-
486-
def s:ScriptFuncStore()
487-
let localnr = 1
488-
localnr = 2
489-
let localstr = 'abc'
490-
localstr = 'xyz'
491-
v:char = 'abc'
492-
s:scriptvar = 'sv'
493-
g:globalvar = 'gv'
494-
&tabstop = 8
495-
$ENVVAR = 'ev'
496-
@z = 'rv'
497-
enddef
498-
499-
def s:ScriptFuncTry()
500-
try
501-
echo 'yes'
502-
catch /fail/
503-
echo 'no'
504-
finally
505-
echo 'end'
506-
endtry
507-
enddef
508-
509-
def Test_disassemble()
477+
def Test_disassembleLoad()
510478
assert_fails('disass NoFunc', 'E1061:')
511479
assert_fails('disass NotCompiled', 'E1062:')
512480

@@ -522,8 +490,19 @@ def Test_disassemble()
522490
\ .. ' LOADENV $ENVVAR.*'
523491
\ .. ' LOADREG @z.*'
524492
\, res)
493+
enddef
494+
495+
def s:ScriptFuncPush()
496+
let localbool = true
497+
let localspec = v:none
498+
let localblob = 0z1234
499+
if has('float')
500+
let localfloat = 1.234
501+
endif
502+
enddef
525503

526-
res = execute('disass s:ScriptFuncPush')
504+
def Test_disassemblePush()
505+
let res = execute('disass s:ScriptFuncPush')
527506
assert_match('<SNR>\d*_ScriptFuncPush.*'
528507
\ .. 'localbool = true.*'
529508
\ .. ' PUSH v:true.*'
@@ -538,8 +517,23 @@ def Test_disassemble()
538517
\ .. ' PUSHF 1.234.*'
539518
\, res)
540519
endif
520+
enddef
541521

542-
res = execute('disass s:ScriptFuncStore')
522+
def s:ScriptFuncStore()
523+
let localnr = 1
524+
localnr = 2
525+
let localstr = 'abc'
526+
localstr = 'xyz'
527+
v:char = 'abc'
528+
s:scriptvar = 'sv'
529+
g:globalvar = 'gv'
530+
&tabstop = 8
531+
$ENVVAR = 'ev'
532+
@z = 'rv'
533+
enddef
534+
535+
def Test_disassembleStore()
536+
let res = execute('disass s:ScriptFuncStore')
543537
assert_match('<SNR>\d*_ScriptFuncStore.*'
544538
\ .. 'localnr = 2.*'
545539
\ .. ' STORE 2 in $0.*'
@@ -558,8 +552,20 @@ def Test_disassemble()
558552
\ .. '@z = ''rv''.*'
559553
\ .. ' STOREREG @z.*'
560554
\, res)
555+
enddef
556+
557+
def s:ScriptFuncTry()
558+
try
559+
echo 'yes'
560+
catch /fail/
561+
echo 'no'
562+
finally
563+
echo 'end'
564+
endtry
565+
enddef
561566

562-
res = execute('disass s:ScriptFuncTry')
567+
def Test_disassembleTry()
568+
let res = execute('disass s:ScriptFuncTry')
563569
assert_match('<SNR>\d*_ScriptFuncTry.*'
564570
\ .. 'try.*'
565571
\ .. 'TRY catch -> \d\+, finally -> \d\+.*'
@@ -577,5 +583,86 @@ def Test_disassemble()
577583
\, res)
578584
enddef
579585

586+
def s:ScriptFuncNew()
587+
let ll = [1, "two", 333]
588+
let dd = #{one: 1, two: "val"}
589+
enddef
590+
591+
def Test_disassembleNew()
592+
let res = execute('disass s:ScriptFuncNew')
593+
assert_match('<SNR>\d*_ScriptFuncNew.*'
594+
\ .. 'let ll = \[1, "two", 333].*'
595+
\ .. 'PUSHNR 1.*'
596+
\ .. 'PUSHS "two".*'
597+
\ .. 'PUSHNR 333.*'
598+
\ .. 'NEWLIST size 3.*'
599+
\ .. 'let dd = #{one: 1, two: "val"}.*'
600+
\ .. 'PUSHS "one".*'
601+
\ .. 'PUSHNR 1.*'
602+
\ .. 'PUSHS "two".*'
603+
\ .. 'PUSHS "val".*'
604+
\ .. 'NEWDICT size 2.*'
605+
\, res)
606+
enddef
607+
608+
def FuncWithArg(arg)
609+
echo arg
610+
enddef
611+
612+
func UserFunc()
613+
echo 'nothing'
614+
endfunc
615+
616+
func UserFuncWithArg(arg)
617+
echo a:arg
618+
endfunc
619+
620+
def s:ScriptFuncCall(): string
621+
changenr()
622+
char2nr("abc")
623+
Test_disassembleNew()
624+
FuncWithArg(343)
625+
UserFunc()
626+
UserFuncWithArg("foo")
627+
let FuncRef = function("UserFunc")
628+
FuncRef()
629+
let FuncRefWithArg = function("UserFuncWithArg")
630+
FuncRefWithArg("bar")
631+
return "yes"
632+
enddef
633+
634+
def Test_disassembleCall()
635+
let res = execute('disass s:ScriptFuncCall')
636+
assert_match('<SNR>\d*_ScriptFuncCall.*'
637+
\ .. 'changenr().*'
638+
\ .. ' BCALL changenr(argc 0).*'
639+
\ .. 'char2nr("abc").*'
640+
\ .. ' PUSHS "abc".*'
641+
\ .. ' BCALL char2nr(argc 1).*'
642+
\ .. 'Test_disassembleNew().*'
643+
\ .. ' DCALL Test_disassembleNew(argc 0).*'
644+
\ .. 'FuncWithArg(343).*'
645+
\ .. ' PUSHNR 343.*'
646+
\ .. ' DCALL FuncWithArg(argc 1).*'
647+
\ .. 'UserFunc().*'
648+
\ .. ' UCALL UserFunc(argc 0).*'
649+
\ .. 'UserFuncWithArg("foo").*'
650+
\ .. ' PUSHS "foo".*'
651+
\ .. ' UCALL UserFuncWithArg(argc 1).*'
652+
\ .. 'let FuncRef = function("UserFunc").*'
653+
\ .. 'FuncRef().*'
654+
\ .. ' LOAD $\d.*'
655+
\ .. ' PCALL (argc 0).*'
656+
\ .. 'let FuncRefWithArg = function("UserFuncWithArg").*'
657+
\ .. 'FuncRefWithArg("bar").*'
658+
\ .. ' PUSHS "bar".*'
659+
\ .. ' LOAD $\d.*'
660+
\ .. ' PCALL (argc 1).*'
661+
\ .. 'return "yes".*'
662+
\ .. ' PUSHS "yes".*'
663+
\ .. ' RETURN.*'
664+
\, res)
665+
enddef
666+
580667

581668
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,8 @@ static char *(features[]) =
742742

743743
static int included_patches[] =
744744
{ /* Add new patch number below this line */
745+
/**/
746+
218,
745747
/**/
746748
217,
747749
/**/

0 commit comments

Comments
 (0)