To: vim_dev@googlegroups.com Subject: Patch 8.2.0565 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0565 Problem: Vim9: tests contain superfluous line continuation. Solution: Remove line continuation no longer needed. Skip empty lines. Files: src/vim9compile.c, src/testdir/test_vim9_script.vim, src/testdir/test_vim9_disassemble.vim *** ../vim-8.2.0564/src/vim9compile.c 2020-04-12 21:52:56.875998374 +0200 --- src/vim9compile.c 2020-04-12 22:48:23.664511069 +0200 *************** *** 2065,2071 **** line = ((char_u **)cctx->ctx_ufunc->uf_lines.ga_data)[cctx->ctx_lnum]; SOURCING_LNUM = cctx->ctx_ufunc->uf_script_ctx.sc_lnum + cctx->ctx_lnum + 1; ! } while (line == NULL); return line; } --- 2065,2071 ---- line = ((char_u **)cctx->ctx_ufunc->uf_lines.ga_data)[cctx->ctx_lnum]; SOURCING_LNUM = cctx->ctx_ufunc->uf_script_ctx.sc_lnum + cctx->ctx_lnum + 1; ! } while (line == NULL || *skipwhite(line) == NUL); return line; } *** ../vim-8.2.0564/src/testdir/test_vim9_script.vim 2020-04-12 20:19:12.643818971 +0200 --- src/testdir/test_vim9_script.vim 2020-04-12 22:31:51.647099276 +0200 *************** *** 599,605 **** return valtwo enddef END ! writefile(lines + morelines, 'Xreload.vim') source Xreload.vim source Xreload.vim source Xreload.vim --- 599,606 ---- return valtwo enddef END ! writefile(lines + morelines, ! 'Xreload.vim') source Xreload.vim source Xreload.vim source Xreload.vim *************** *** 653,667 **** assert_equal(9876, g:imported_abs) assert_equal(8888, g:imported_after) ! assert_match('\d\+_UseExported.*' ! \ .. 'g:imported_abs = exported.*' ! \ .. '0 LOADSCRIPT exported from .*Xexport_abs.vim.*' ! \ .. '1 STOREG g:imported_abs.*' ! \ .. 'exported = 8888.*' ! \ .. '3 STORESCRIPT exported in .*Xexport_abs.vim.*' ! \ .. 'g:imported_after = exported.*' ! \ .. '4 LOADSCRIPT exported from .*Xexport_abs.vim.*' ! \ .. '5 STOREG g:imported_after.*', g:import_disassembled) unlet g:imported_abs unlet g:import_disassembled --- 654,668 ---- assert_equal(9876, g:imported_abs) assert_equal(8888, g:imported_after) ! assert_match('\d\+_UseExported.*' .. ! 'g:imported_abs = exported.*' .. ! '0 LOADSCRIPT exported from .*Xexport_abs.vim.*' .. ! '1 STOREG g:imported_abs.*' .. ! 'exported = 8888.*' .. ! '3 STORESCRIPT exported in .*Xexport_abs.vim.*' .. ! 'g:imported_after = exported.*' .. ! '4 LOADSCRIPT exported from .*Xexport_abs.vim.*' .. ! '5 STOREG g:imported_after.*', g:import_disassembled) unlet g:imported_abs unlet g:import_disassembled *************** *** 913,926 **** enddef def Test_for_loop_fails() ! call CheckDefFailure(['for # in range(5)'], 'E690:') ! call CheckDefFailure(['for i In range(5)'], 'E690:') ! call CheckDefFailure(['let x = 5', 'for x in range(5)'], 'E1023:') ! call CheckScriptFailure(['def Func(arg)', 'for arg in range(5)', 'enddef'], 'E1006:') ! call CheckDefFailure(['for i in "text"'], 'E1024:') ! call CheckDefFailure(['for i in xxx'], 'E1001:') ! call CheckDefFailure(['endfor'], 'E588:') ! call CheckDefFailure(['for i in range(3)', 'echo 3'], 'E170:') enddef def Test_while_loop() --- 914,927 ---- enddef def Test_for_loop_fails() ! CheckDefFailure(['for # in range(5)'], 'E690:') ! CheckDefFailure(['for i In range(5)'], 'E690:') ! CheckDefFailure(['let x = 5', 'for x in range(5)'], 'E1023:') ! CheckScriptFailure(['def Func(arg)', 'for arg in range(5)', 'enddef'], 'E1006:') ! CheckDefFailure(['for i in "text"'], 'E1024:') ! CheckDefFailure(['for i in xxx'], 'E1001:') ! CheckDefFailure(['endfor'], 'E588:') ! CheckDefFailure(['for i in range(3)', 'echo 3'], 'E170:') enddef def Test_while_loop() *************** *** 940,952 **** enddef def Test_while_loop_fails() ! call CheckDefFailure(['while xxx'], 'E1001:') ! call CheckDefFailure(['endwhile'], 'E588:') ! call CheckDefFailure(['continue'], 'E586:') ! call CheckDefFailure(['if true', 'continue'], 'E586:') ! call CheckDefFailure(['break'], 'E587:') ! call CheckDefFailure(['if true', 'break'], 'E587:') ! call CheckDefFailure(['while 1', 'echo 3'], 'E170:') enddef def Test_interrupt_loop() --- 941,953 ---- enddef def Test_while_loop_fails() ! CheckDefFailure(['while xxx'], 'E1001:') ! CheckDefFailure(['endwhile'], 'E588:') ! CheckDefFailure(['continue'], 'E586:') ! CheckDefFailure(['if true', 'continue'], 'E586:') ! CheckDefFailure(['break'], 'E587:') ! CheckDefFailure(['if true', 'break'], 'E587:') ! CheckDefFailure(['while 1', 'echo 3'], 'E170:') enddef def Test_interrupt_loop() *** ../vim-8.2.0564/src/testdir/test_vim9_disassemble.vim 2020-04-05 17:07:59.418556237 +0200 --- src/testdir/test_vim9_disassemble.vim 2020-04-12 22:52:17.375899612 +0200 *************** *** 31,47 **** assert_fails('disass foo', 'E475:') let res = execute('disass s:ScriptFuncLoad') ! assert_match('\d*_ScriptFuncLoad.*' ! \ .. 'buffers.*' ! \ .. ' EXEC \+buffers.*' ! \ .. ' LOAD arg\[-1\].*' ! \ .. ' LOAD $0.*' ! \ .. ' LOADV v:version.*' ! \ .. ' LOADS s:scriptvar from .*test_vim9_disassemble.vim.*' ! \ .. ' LOADG g:globalvar.*' ! \ .. ' LOADENV $ENVVAR.*' ! \ .. ' LOADREG @z.*' ! \, res) enddef def s:ScriptFuncPush() --- 31,47 ---- assert_fails('disass foo', 'E475:') let res = execute('disass s:ScriptFuncLoad') ! assert_match('\d*_ScriptFuncLoad.*' .. ! 'buffers.*' .. ! ' EXEC \+buffers.*' .. ! ' LOAD arg\[-1\].*' .. ! ' LOAD $0.*' .. ! ' LOADV v:version.*' .. ! ' LOADS s:scriptvar from .*test_vim9_disassemble.vim.*' .. ! ' LOADG g:globalvar.*' .. ! ' LOADENV $ENVVAR.*' .. ! ' LOADREG @z.*', ! res) enddef def s:ScriptFuncPush() *************** *** 55,73 **** def Test_disassemble_push() let res = execute('disass s:ScriptFuncPush') ! assert_match('\d*_ScriptFuncPush.*' ! \ .. 'localbool = true.*' ! \ .. ' PUSH v:true.*' ! \ .. 'localspec = v:none.*' ! \ .. ' PUSH v:none.*' ! \ .. 'localblob = 0z1234.*' ! \ .. ' PUSHBLOB 0z1234.*' ! \, res) if has('float') ! assert_match('\d*_ScriptFuncPush.*' ! \ .. 'localfloat = 1.234.*' ! \ .. ' PUSHF 1.234.*' ! \, res) endif enddef --- 55,73 ---- def Test_disassemble_push() let res = execute('disass s:ScriptFuncPush') ! assert_match('\d*_ScriptFuncPush.*' .. ! 'localbool = true.*' .. ! ' PUSH v:true.*' .. ! 'localspec = v:none.*' .. ! ' PUSH v:none.*' .. ! 'localblob = 0z1234.*' .. ! ' PUSHBLOB 0z1234.*', ! res) if has('float') ! assert_match('\d*_ScriptFuncPush.*' .. ! 'localfloat = 1.234.*' .. ! ' PUSHF 1.234.*', ! res) endif enddef *************** *** 86,111 **** def Test_disassemble_store() let res = execute('disass s:ScriptFuncStore') ! assert_match('\d*_ScriptFuncStore.*' ! \ .. 'let localnr = 1.*' ! \ .. 'localnr = 2.*' ! \ .. ' STORE 2 in $0.*' ! \ .. 'let localstr = ''abc''.*' ! \ .. 'localstr = ''xyz''.*' ! \ .. ' STORE $1.*' ! \ .. 'v:char = ''abc''.*' ! \ .. 'STOREV v:char.*' ! \ .. 's:scriptvar = ''sv''.*' ! \ .. ' STORES s:scriptvar in .*test_vim9_disassemble.vim.*' ! \ .. 'g:globalvar = ''gv''.*' ! \ .. ' STOREG g:globalvar.*' ! \ .. '&tabstop = 8.*' ! \ .. ' STOREOPT &tabstop.*' ! \ .. '$ENVVAR = ''ev''.*' ! \ .. ' STOREENV $ENVVAR.*' ! \ .. '@z = ''rv''.*' ! \ .. ' STOREREG @z.*' ! \, res) enddef def s:ScriptFuncTry() --- 86,111 ---- def Test_disassemble_store() let res = execute('disass s:ScriptFuncStore') ! assert_match('\d*_ScriptFuncStore.*' .. ! 'let localnr = 1.*' .. ! 'localnr = 2.*' .. ! ' STORE 2 in $0.*' .. ! 'let localstr = ''abc''.*' .. ! 'localstr = ''xyz''.*' .. ! ' STORE $1.*' .. ! 'v:char = ''abc''.*' .. ! 'STOREV v:char.*' .. ! 's:scriptvar = ''sv''.*' .. ! ' STORES s:scriptvar in .*test_vim9_disassemble.vim.*' .. ! 'g:globalvar = ''gv''.*' .. ! ' STOREG g:globalvar.*' .. ! '&tabstop = 8.*' .. ! ' STOREOPT &tabstop.*' .. ! '$ENVVAR = ''ev''.*' .. ! ' STOREENV $ENVVAR.*' .. ! '@z = ''rv''.*' .. ! ' STOREREG @z.*', ! res) enddef def s:ScriptFuncTry() *************** *** 120,141 **** def Test_disassemble_try() let res = execute('disass s:ScriptFuncTry') ! assert_match('\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".*' ! \ .. ' THROW.*' ! \ .. 'endtry.*' ! \ .. ' ENDTRY.*' ! \, res) enddef def s:ScriptFuncNew() --- 120,141 ---- def Test_disassemble_try() let res = execute('disass s:ScriptFuncTry') ! assert_match('\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".*' .. ! ' THROW.*' .. ! 'endtry.*' .. ! ' ENDTRY.*', ! res) enddef def s:ScriptFuncNew() *************** *** 145,163 **** def Test_disassemble_new() let res = execute('disass s:ScriptFuncNew') ! assert_match('\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) --- 145,163 ---- def Test_disassemble_new() let res = execute('disass s:ScriptFuncNew') ! assert_match('\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) *************** *** 190,228 **** def Test_disassemble_call() let res = execute('disass s:ScriptFuncCall') ! assert_match('\d\+_ScriptFuncCall.*' ! \ .. 'changenr().*' ! \ .. ' BCALL changenr(argc 0).*' ! \ .. 'char2nr("abc").*' ! \ .. ' PUSHS "abc".*' ! \ .. ' BCALL char2nr(argc 1).*' ! \ .. 'Test_disassemble_new().*' ! \ .. ' DCALL Test_disassemble_new(argc 0).*' ! \ .. 'FuncWithArg(343).*' ! \ .. ' PUSHNR 343.*' ! \ .. ' DCALL FuncWithArg(argc 1).*' ! \ .. 'ScriptFuncNew().*' ! \ .. ' DCALL \d\+_ScriptFuncNew(argc 0).*' ! \ .. 's:ScriptFuncNew().*' ! \ .. ' DCALL \d\+_ScriptFuncNew(argc 0).*' ! \ .. '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 --- 190,228 ---- def Test_disassemble_call() let res = execute('disass s:ScriptFuncCall') ! assert_match('\d\+_ScriptFuncCall.*' .. ! 'changenr().*' .. ! ' BCALL changenr(argc 0).*' .. ! 'char2nr("abc").*' .. ! ' PUSHS "abc".*' .. ! ' BCALL char2nr(argc 1).*' .. ! 'Test_disassemble_new().*' .. ! ' DCALL Test_disassemble_new(argc 0).*' .. ! 'FuncWithArg(343).*' .. ! ' PUSHNR 343.*' .. ! ' DCALL FuncWithArg(argc 1).*' .. ! 'ScriptFuncNew().*' .. ! ' DCALL \d\+_ScriptFuncNew(argc 0).*' .. ! 's:ScriptFuncNew().*' .. ! ' DCALL \d\+_ScriptFuncNew(argc 0).*' .. ! '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 *************** *** 238,253 **** def Test_disassemble_pcall() let res = execute('disass s:ScriptPCall') ! assert_match('\d\+_ScriptPCall.*' ! \ .. 'RefThis()("text").*' ! \ .. '\d DCALL RefThis(argc 0).*' ! \ .. '\d PUSHS "text".*' ! \ .. '\d PCALL top (argc 1).*' ! \ .. '\d PCALL end.*' ! \ .. '\d DROP.*' ! \ .. '\d PUSHNR 0.*' ! \ .. '\d RETURN.*' ! \, res) enddef --- 238,253 ---- def Test_disassemble_pcall() let res = execute('disass s:ScriptPCall') ! assert_match('\d\+_ScriptPCall.*' .. ! 'RefThis()("text").*' .. ! '\d DCALL RefThis(argc 0).*' .. ! '\d PUSHS "text".*' .. ! '\d PCALL top (argc 1).*' .. ! '\d PCALL end.*' .. ! '\d DROP.*' .. ! '\d PUSHNR 0.*' .. ! '\d RETURN.*', ! res) enddef *************** *** 261,285 **** def Test_disassemble_update_instr() let res = execute('disass FuncWithForwardCall') ! assert_match('FuncWithForwardCall.*' ! \ .. 'return DefinedLater("yes").*' ! \ .. '\d PUSHS "yes".*' ! \ .. '\d UCALL DefinedLater(argc 1).*' ! \ .. '\d CHECKTYPE string stack\[-1].*' ! \ .. '\d RETURN.*' ! \, res) " Calling the function will change UCALL into the faster DCALL assert_equal('yes', FuncWithForwardCall()) res = execute('disass FuncWithForwardCall') ! assert_match('FuncWithForwardCall.*' ! \ .. 'return DefinedLater("yes").*' ! \ .. '\d PUSHS "yes".*' ! \ .. '\d DCALL DefinedLater(argc 1).*' ! \ .. '\d CHECKTYPE string stack\[-1].*' ! \ .. '\d RETURN.*' ! \, res) enddef --- 261,285 ---- def Test_disassemble_update_instr() let res = execute('disass FuncWithForwardCall') ! assert_match('FuncWithForwardCall.*' .. ! 'return DefinedLater("yes").*' .. ! '\d PUSHS "yes".*' .. ! '\d UCALL DefinedLater(argc 1).*' .. ! '\d CHECKTYPE string stack\[-1].*' .. ! '\d RETURN.*', ! res) " Calling the function will change UCALL into the faster DCALL assert_equal('yes', FuncWithForwardCall()) res = execute('disass FuncWithForwardCall') ! assert_match('FuncWithForwardCall.*' .. ! 'return DefinedLater("yes").*' .. ! '\d PUSHS "yes".*' .. ! '\d DCALL DefinedLater(argc 1).*' .. ! '\d CHECKTYPE string stack\[-1].*' .. ! '\d RETURN.*', ! res) enddef *************** *** 289,301 **** def Test_disassemble_call_default() let res = execute('disass FuncWithDefault') ! assert_match('FuncWithDefault.*' ! \ .. '\d PUSHS "default".*' ! \ .. '\d STORE arg\[-1].*' ! \ .. 'return arg.*' ! \ .. '\d LOAD arg\[-1].*' ! \ .. '\d RETURN.*' ! \, res) enddef --- 289,301 ---- def Test_disassemble_call_default() let res = execute('disass FuncWithDefault') ! assert_match('FuncWithDefault.*' .. ! '\d PUSHS "default".*' .. ! '\d STORE arg\[-1].*' .. ! 'return arg.*' .. ! '\d LOAD arg\[-1].*' .. ! '\d RETURN.*', ! res) enddef *************** *** 330,360 **** def Test_disassemble_const_expr() assert_equal("\nyes", execute('call HasEval()')) let instr = execute('disassemble HasEval') ! assert_match('HasEval.*' ! \ .. 'if has("eval").*' ! \ .. ' PUSHS "yes".*' ! \, instr) assert_notmatch('JUMP', instr) assert_equal("\nno", execute('call HasNothing()')) instr = execute('disassemble HasNothing') ! assert_match('HasNothing.*' ! \ .. 'if has("nothing").*' ! \ .. 'else.*' ! \ .. ' PUSHS "no".*' ! \, instr) assert_notmatch('PUSHS "yes"', instr) assert_notmatch('JUMP', instr) assert_equal("\neval", execute('call HasSomething()')) instr = execute('disassemble HasSomething') ! assert_match('HasSomething.*' ! \ .. 'if has("nothing").*' ! \ .. 'elseif has("something").*' ! \ .. 'elseif has("eval").*' ! \ .. ' PUSHS "eval".*' ! \ .. 'elseif has("less").*' ! \, instr) assert_notmatch('PUSHS "nothing"', instr) assert_notmatch('PUSHS "something"', instr) assert_notmatch('PUSHS "less"', instr) --- 330,360 ---- def Test_disassemble_const_expr() assert_equal("\nyes", execute('call HasEval()')) let instr = execute('disassemble HasEval') ! assert_match('HasEval.*' .. ! 'if has("eval").*' .. ! ' PUSHS "yes".*', ! instr) assert_notmatch('JUMP', instr) assert_equal("\nno", execute('call HasNothing()')) instr = execute('disassemble HasNothing') ! assert_match('HasNothing.*' .. ! 'if has("nothing").*' .. ! 'else.*' .. ! ' PUSHS "no".*', ! instr) assert_notmatch('PUSHS "yes"', instr) assert_notmatch('JUMP', instr) assert_equal("\neval", execute('call HasSomething()')) instr = execute('disassemble HasSomething') ! assert_match('HasSomething.*' .. ! 'if has("nothing").*' .. ! 'elseif has("something").*' .. ! 'elseif has("eval").*' .. ! ' PUSHS "eval".*' .. ! 'elseif has("less").*', ! instr) assert_notmatch('PUSHS "nothing"', instr) assert_notmatch('PUSHS "something"', instr) assert_notmatch('PUSHS "less"', instr) *************** *** 369,389 **** def Test_disassemble_function() let instr = execute('disassemble WithFunc') ! assert_match('WithFunc.*' ! \ .. 'let Funky1: func.*' ! \ .. '0 PUSHFUNC "\[none]".*' ! \ .. '1 STORE $0.*' ! \ .. 'let Funky2: func = function("len").*' ! \ .. '2 PUSHS "len".*' ! \ .. '3 BCALL function(argc 1).*' ! \ .. '4 STORE $1.*' ! \ .. 'let Party2: func = funcref("UserFunc").*' ! \ .. '\d PUSHS "UserFunc".*' ! \ .. '\d BCALL funcref(argc 1).*' ! \ .. '\d STORE $2.*' ! \ .. '\d PUSHNR 0.*' ! \ .. '\d RETURN.*' ! \, instr) enddef if has('channel') --- 369,389 ---- def Test_disassemble_function() let instr = execute('disassemble WithFunc') ! assert_match('WithFunc.*' .. ! 'let Funky1: func.*' .. ! '0 PUSHFUNC "\[none]".*' .. ! '1 STORE $0.*' .. ! 'let Funky2: func = function("len").*' .. ! '2 PUSHS "len".*' .. ! '3 BCALL function(argc 1).*' .. ! '4 STORE $1.*' .. ! 'let Party2: func = funcref("UserFunc").*' .. ! '\d PUSHS "UserFunc".*' .. ! '\d BCALL funcref(argc 1).*' .. ! '\d STORE $2.*' .. ! '\d PUSHNR 0.*' .. ! '\d RETURN.*', ! instr) enddef if has('channel') *************** *** 398,417 **** CheckFeature channel let instr = execute('disassemble WithChannel') ! assert_match('WithChannel.*' ! \ .. 'let job1: job.*' ! \ .. '\d PUSHJOB "no process".*' ! \ .. '\d STORE $0.*' ! \ .. 'let job2: job = job_start("donothing").*' ! \ .. '\d PUSHS "donothing".*' ! \ .. '\d BCALL job_start(argc 1).*' ! \ .. '\d STORE $1.*' ! \ .. 'let chan1: channel.*' ! \ .. '\d PUSHCHANNEL 0.*' ! \ .. '\d STORE $2.*' ! \ .. '\d PUSHNR 0.*' ! \ .. '\d RETURN.*' ! \, instr) enddef def WithLambda(): string --- 398,417 ---- CheckFeature channel let instr = execute('disassemble WithChannel') ! assert_match('WithChannel.*' .. ! 'let job1: job.*' .. ! '\d PUSHJOB "no process".*' .. ! '\d STORE $0.*' .. ! 'let job2: job = job_start("donothing").*' .. ! '\d PUSHS "donothing".*' .. ! '\d BCALL job_start(argc 1).*' .. ! '\d STORE $1.*' .. ! 'let chan1: channel.*' .. ! '\d PUSHCHANNEL 0.*' .. ! '\d STORE $2.*' .. ! '\d PUSHNR 0.*' .. ! '\d RETURN.*', ! instr) enddef def WithLambda(): string *************** *** 422,435 **** def Test_disassemble_lambda() assert_equal("XxX", WithLambda()) let instr = execute('disassemble WithLambda') ! assert_match('WithLambda.*' ! \ .. 'let F = {a -> "X" .. a .. "X"}.*' ! \ .. ' FUNCREF \d\+.*' ! \ .. 'PUSHS "x".*' ! \ .. ' LOAD $0.*' ! \ .. ' PCALL (argc 1).*' ! \ .. ' CHECKTYPE string stack\[-1].*' ! \, instr) enddef def AndOr(arg): string --- 422,435 ---- def Test_disassemble_lambda() assert_equal("XxX", WithLambda()) let instr = execute('disassemble WithLambda') ! assert_match('WithLambda.*' .. ! 'let F = {a -> "X" .. a .. "X"}.*' .. ! ' FUNCREF \d\+.*' .. ! 'PUSHS "x".*' .. ! ' LOAD $0.*' .. ! ' PCALL (argc 1).*' .. ! ' CHECKTYPE string stack\[-1].*', ! instr) enddef def AndOr(arg): string *************** *** 444,464 **** assert_equal("no", AndOr(2)) assert_equal("yes", AndOr(4)) let instr = execute('disassemble AndOr') ! assert_match('AndOr.*' ! \ .. 'if arg == 1 && arg != 2 || arg == 4.*' ! \ .. '\d LOAD arg\[-1].*' ! \ .. '\d PUSHNR 1.*' ! \ .. '\d COMPAREANY ==.*' ! \ .. '\d JUMP_AND_KEEP_IF_FALSE -> \d\+.*' ! \ .. '\d LOAD arg\[-1].*' ! \ .. '\d PUSHNR 2.*' ! \ .. '\d COMPAREANY !=.*' ! \ .. '\d JUMP_AND_KEEP_IF_TRUE -> \d\+.*' ! \ .. '\d LOAD arg\[-1].*' ! \ .. '\d PUSHNR 4.*' ! \ .. '\d COMPAREANY ==.*' ! \ .. '\d JUMP_IF_FALSE -> \d\+.*' ! \, instr) enddef def ForLoop(): list --- 444,464 ---- assert_equal("no", AndOr(2)) assert_equal("yes", AndOr(4)) let instr = execute('disassemble AndOr') ! assert_match('AndOr.*' .. ! 'if arg == 1 && arg != 2 || arg == 4.*' .. ! '\d LOAD arg\[-1].*' .. ! '\d PUSHNR 1.*' .. ! '\d COMPAREANY ==.*' .. ! '\d JUMP_AND_KEEP_IF_FALSE -> \d\+.*' .. ! '\d LOAD arg\[-1].*' .. ! '\d PUSHNR 2.*' .. ! '\d COMPAREANY !=.*' .. ! '\d JUMP_AND_KEEP_IF_TRUE -> \d\+.*' .. ! '\d LOAD arg\[-1].*' .. ! '\d PUSHNR 4.*' .. ! '\d COMPAREANY ==.*' .. ! '\d JUMP_IF_FALSE -> \d\+.*', ! instr) enddef def ForLoop(): list *************** *** 472,496 **** def Test_disassemble_for_loop() assert_equal([0, 1, 2], ForLoop()) let instr = execute('disassemble ForLoop') ! assert_match('ForLoop.*' ! \ .. 'let res: list.*' ! \ .. ' NEWLIST size 0.*' ! \ .. '\d STORE $0.*' ! \ .. 'for i in range(3).*' ! \ .. '\d STORE -1 in $1.*' ! \ .. '\d PUSHNR 3.*' ! \ .. '\d BCALL range(argc 1).*' ! \ .. '\d FOR $1 -> \d\+.*' ! \ .. '\d STORE $2.*' ! \ .. 'res->add(i).*' ! \ .. '\d LOAD $0.*' ! \ .. '\d LOAD $2.*' ! \ .. '\d BCALL add(argc 2).*' ! \ .. '\d DROP.*' ! \ .. 'endfor.*' ! \ .. '\d JUMP -> \d\+.*' ! \ .. '\d DROP.*' ! \, instr) enddef let g:number = 42 --- 472,496 ---- def Test_disassemble_for_loop() assert_equal([0, 1, 2], ForLoop()) let instr = execute('disassemble ForLoop') ! assert_match('ForLoop.*' .. ! 'let res: list.*' .. ! ' NEWLIST size 0.*' .. ! '\d STORE $0.*' .. ! 'for i in range(3).*' .. ! '\d STORE -1 in $1.*' .. ! '\d PUSHNR 3.*' .. ! '\d BCALL range(argc 1).*' .. ! '\d FOR $1 -> \d\+.*' .. ! '\d STORE $2.*' .. ! 'res->add(i).*' .. ! '\d LOAD $0.*' .. ! '\d LOAD $2.*' .. ! '\d BCALL add(argc 2).*' .. ! '\d DROP.*' .. ! 'endfor.*' .. ! '\d JUMP -> \d\+.*' .. ! '\d DROP.*', ! instr) enddef let g:number = 42 *************** *** 520,572 **** def Test_disassemble_computing() let instr = execute('disassemble Computing') ! assert_match('Computing.*' ! \ .. 'let nr = 3.*' ! \ .. '\d STORE 3 in $0.*' ! \ .. 'let nrres = nr + 7.*' ! \ .. '\d LOAD $0.*' ! \ .. '\d PUSHNR 7.*' ! \ .. '\d OPNR +.*' ! \ .. '\d STORE $1.*' ! \ .. 'nrres = nr - 7.*' ! \ .. '\d OPNR -.*' ! \ .. 'nrres = nr \* 7.*' ! \ .. '\d OPNR \*.*' ! \ .. 'nrres = nr / 7.*' ! \ .. '\d OPNR /.*' ! \ .. 'nrres = nr % 7.*' ! \ .. '\d OPNR %.*' ! \ .. 'let anyres = g:number + 7.*' ! \ .. '\d LOADG g:number.*' ! \ .. '\d PUSHNR 7.*' ! \ .. '\d OPANY +.*' ! \ .. '\d STORE $2.*' ! \ .. 'anyres = g:number - 7.*' ! \ .. '\d OPANY -.*' ! \ .. 'anyres = g:number \* 7.*' ! \ .. '\d OPANY \*.*' ! \ .. 'anyres = g:number / 7.*' ! \ .. '\d OPANY /.*' ! \ .. 'anyres = g:number % 7.*' ! \ .. '\d OPANY %.*' ! \, instr) if has('float') ! assert_match('Computing.*' ! \ .. 'let fl = 3.0.*' ! \ .. '\d PUSHF 3.0.*' ! \ .. '\d STORE $3.*' ! \ .. 'let flres = fl + 7.0.*' ! \ .. '\d LOAD $3.*' ! \ .. '\d PUSHF 7.0.*' ! \ .. '\d OPFLOAT +.*' ! \ .. '\d STORE $4.*' ! \ .. 'flres = fl - 7.0.*' ! \ .. '\d OPFLOAT -.*' ! \ .. 'flres = fl \* 7.0.*' ! \ .. '\d OPFLOAT \*.*' ! \ .. 'flres = fl / 7.0.*' ! \ .. '\d OPFLOAT /.*' ! \, instr) endif enddef --- 520,572 ---- def Test_disassemble_computing() let instr = execute('disassemble Computing') ! assert_match('Computing.*' .. ! 'let nr = 3.*' .. ! '\d STORE 3 in $0.*' .. ! 'let nrres = nr + 7.*' .. ! '\d LOAD $0.*' .. ! '\d PUSHNR 7.*' .. ! '\d OPNR +.*' .. ! '\d STORE $1.*' .. ! 'nrres = nr - 7.*' .. ! '\d OPNR -.*' .. ! 'nrres = nr \* 7.*' .. ! '\d OPNR \*.*' .. ! 'nrres = nr / 7.*' .. ! '\d OPNR /.*' .. ! 'nrres = nr % 7.*' .. ! '\d OPNR %.*' .. ! 'let anyres = g:number + 7.*' .. ! '\d LOADG g:number.*' .. ! '\d PUSHNR 7.*' .. ! '\d OPANY +.*' .. ! '\d STORE $2.*' .. ! 'anyres = g:number - 7.*' .. ! '\d OPANY -.*' .. ! 'anyres = g:number \* 7.*' .. ! '\d OPANY \*.*' .. ! 'anyres = g:number / 7.*' .. ! '\d OPANY /.*' .. ! 'anyres = g:number % 7.*' .. ! '\d OPANY %.*', ! instr) if has('float') ! assert_match('Computing.*' .. ! 'let fl = 3.0.*' .. ! '\d PUSHF 3.0.*' .. ! '\d STORE $3.*' .. ! 'let flres = fl + 7.0.*' .. ! '\d LOAD $3.*' .. ! '\d PUSHF 7.0.*' .. ! '\d OPFLOAT +.*' .. ! '\d STORE $4.*' .. ! 'flres = fl - 7.0.*' .. ! '\d OPFLOAT -.*' .. ! 'flres = fl \* 7.0.*' .. ! '\d OPFLOAT \*.*' .. ! 'flres = fl / 7.0.*' .. ! '\d OPFLOAT /.*', ! instr) endif enddef *************** *** 577,598 **** def Test_disassemble_add_list_blob() let instr = execute('disassemble AddListBlob') ! assert_match('AddListBlob.*' ! \ .. 'let reslist = \[1, 2] + \[3, 4].*' ! \ .. '\d PUSHNR 1.*' ! \ .. '\d PUSHNR 2.*' ! \ .. '\d NEWLIST size 2.*' ! \ .. '\d PUSHNR 3.*' ! \ .. '\d PUSHNR 4.*' ! \ .. '\d NEWLIST size 2.*' ! \ .. '\d ADDLIST.*' ! \ .. '\d STORE $.*.*' ! \ .. 'let resblob = 0z1122 + 0z3344.*' ! \ .. '\d PUSHBLOB 0z1122.*' ! \ .. '\d PUSHBLOB 0z3344.*' ! \ .. '\d ADDBLOB.*' ! \ .. '\d STORE $.*' ! \, instr) enddef let g:aa = 'aa' --- 577,598 ---- def Test_disassemble_add_list_blob() let instr = execute('disassemble AddListBlob') ! assert_match('AddListBlob.*' .. ! 'let reslist = \[1, 2] + \[3, 4].*' .. ! '\d PUSHNR 1.*' .. ! '\d PUSHNR 2.*' .. ! '\d NEWLIST size 2.*' .. ! '\d PUSHNR 3.*' .. ! '\d PUSHNR 4.*' .. ! '\d NEWLIST size 2.*' .. ! '\d ADDLIST.*' .. ! '\d STORE $.*.*' .. ! 'let resblob = 0z1122 + 0z3344.*' .. ! '\d PUSHBLOB 0z1122.*' .. ! '\d PUSHBLOB 0z3344.*' .. ! '\d ADDBLOB.*' .. ! '\d STORE $.*', ! instr) enddef let g:aa = 'aa' *************** *** 603,616 **** def Test_disassemble_concat() let instr = execute('disassemble ConcatString') ! assert_match('ConcatString.*' ! \ .. 'let res = g:aa .. "bb".*' ! \ .. '\d LOADG g:aa.*' ! \ .. '\d PUSHS "bb".*' ! \ .. '\d 2STRING stack\[-2].*' ! \ .. '\d CONCAT.*' ! \ .. '\d STORE $.*' ! \, instr) assert_equal('aabb', ConcatString()) enddef --- 603,616 ---- def Test_disassemble_concat() let instr = execute('disassemble ConcatString') ! assert_match('ConcatString.*' .. ! 'let res = g:aa .. "bb".*' .. ! '\d LOADG g:aa.*' .. ! '\d PUSHS "bb".*' .. ! '\d 2STRING stack\[-2].*' .. ! '\d CONCAT.*' .. ! '\d STORE $.*', ! instr) assert_equal('aabb', ConcatString()) enddef *************** *** 622,640 **** def Test_disassemble_list_index() let instr = execute('disassemble ListIndex') ! assert_match('ListIndex.*' ! \ .. 'let l = \[1, 2, 3].*' ! \ .. '\d PUSHNR 1.*' ! \ .. '\d PUSHNR 2.*' ! \ .. '\d PUSHNR 3.*' ! \ .. '\d NEWLIST size 3.*' ! \ .. '\d STORE $0.*' ! \ .. 'let res = l\[1].*' ! \ .. '\d LOAD $0.*' ! \ .. '\d PUSHNR 1.*' ! \ .. '\d INDEX.*' ! \ .. '\d STORE $1.*' ! \, instr) assert_equal(2, ListIndex()) enddef --- 622,640 ---- def Test_disassemble_list_index() let instr = execute('disassemble ListIndex') ! assert_match('ListIndex.*' .. ! 'let l = \[1, 2, 3].*' .. ! '\d PUSHNR 1.*' .. ! '\d PUSHNR 2.*' .. ! '\d PUSHNR 3.*' .. ! '\d NEWLIST size 3.*' .. ! '\d STORE $0.*' .. ! 'let res = l\[1].*' .. ! '\d LOAD $0.*' .. ! '\d PUSHNR 1.*' .. ! '\d INDEX.*' .. ! '\d STORE $1.*', ! instr) assert_equal(2, ListIndex()) enddef *************** *** 646,662 **** def Test_disassemble_dict_member() let instr = execute('disassemble DictMember') ! assert_match('DictMember.*' ! \ .. 'let d = #{item: 1}.*' ! \ .. '\d PUSHS "item".*' ! \ .. '\d PUSHNR 1.*' ! \ .. '\d NEWDICT size 1.*' ! \ .. '\d STORE $0.*' ! \ .. 'let res = d.item.*' ! \ .. '\d LOAD $0.*' ! \ .. '\d MEMBER item.*' ! \ .. '\d STORE $1.*' ! \, instr) call assert_equal(1, DictMember()) enddef --- 646,662 ---- def Test_disassemble_dict_member() let instr = execute('disassemble DictMember') ! assert_match('DictMember.*' .. ! 'let d = #{item: 1}.*' .. ! '\d PUSHS "item".*' .. ! '\d PUSHNR 1.*' .. ! '\d NEWDICT size 1.*' .. ! '\d STORE $0.*' .. ! 'let res = d.item.*' .. ! '\d LOAD $0.*' .. ! '\d MEMBER item.*' .. ! '\d STORE $1.*', ! instr) call assert_equal(1, DictMember()) enddef *************** *** 669,686 **** def Test_disassemble_negate_number() let instr = execute('disassemble NegateNumber') ! assert_match('NegateNumber.*' ! \ .. 'let nr = 9.*' ! \ .. '\d STORE 9 in $0.*' ! \ .. 'let plus = +nr.*' ! \ .. '\d LOAD $0.*' ! \ .. '\d CHECKNR.*' ! \ .. '\d STORE $1.*' ! \ .. 'let res = -nr.*' ! \ .. '\d LOAD $0.*' ! \ .. '\d NEGATENR.*' ! \ .. '\d STORE $2.*' ! \, instr) call assert_equal(-9, NegateNumber()) enddef --- 669,686 ---- def Test_disassemble_negate_number() let instr = execute('disassemble NegateNumber') ! assert_match('NegateNumber.*' .. ! 'let nr = 9.*' .. ! '\d STORE 9 in $0.*' .. ! 'let plus = +nr.*' .. ! '\d LOAD $0.*' .. ! '\d CHECKNR.*' .. ! '\d STORE $1.*' .. ! 'let res = -nr.*' .. ! '\d LOAD $0.*' .. ! '\d NEGATENR.*' .. ! '\d STORE $2.*', ! instr) call assert_equal(-9, NegateNumber()) enddef *************** *** 693,801 **** def Test_disassemble_invert_bool() let instr = execute('disassemble InvertBool') ! assert_match('InvertBool.*' ! \ .. 'let flag = true.*' ! \ .. '\d PUSH v:true.*' ! \ .. '\d STORE $0.*' ! \ .. 'let invert = !flag.*' ! \ .. '\d LOAD $0.*' ! \ .. '\d INVERT (!val).*' ! \ .. '\d STORE $1.*' ! \ .. 'let res = !!flag.*' ! \ .. '\d LOAD $0.*' ! \ .. '\d 2BOOL (!!val).*' ! \ .. '\d STORE $2.*' ! \, instr) call assert_equal(true, InvertBool()) enddef def Test_disassemble_compare() " TODO: COMPAREFUNC let cases = [ ! \ ['true == false', 'COMPAREBOOL =='], ! \ ['true != false', 'COMPAREBOOL !='], ! \ ['v:none == v:null', 'COMPARESPECIAL =='], ! \ ['v:none != v:null', 'COMPARESPECIAL !='], ! \ ! \ ['111 == 222', 'COMPARENR =='], ! \ ['111 != 222', 'COMPARENR !='], ! \ ['111 > 222', 'COMPARENR >'], ! \ ['111 < 222', 'COMPARENR <'], ! \ ['111 >= 222', 'COMPARENR >='], ! \ ['111 <= 222', 'COMPARENR <='], ! \ ['111 =~ 222', 'COMPARENR =\~'], ! \ ['111 !~ 222', 'COMPARENR !\~'], ! \ ! \ ['"xx" != "yy"', 'COMPARESTRING !='], ! \ ['"xx" > "yy"', 'COMPARESTRING >'], ! \ ['"xx" < "yy"', 'COMPARESTRING <'], ! \ ['"xx" >= "yy"', 'COMPARESTRING >='], ! \ ['"xx" <= "yy"', 'COMPARESTRING <='], ! \ ['"xx" =~ "yy"', 'COMPARESTRING =\~'], ! \ ['"xx" !~ "yy"', 'COMPARESTRING !\~'], ! \ ['"xx" is "yy"', 'COMPARESTRING is'], ! \ ['"xx" isnot "yy"', 'COMPARESTRING isnot'], ! \ ! \ ['0z11 == 0z22', 'COMPAREBLOB =='], ! \ ['0z11 != 0z22', 'COMPAREBLOB !='], ! \ ['0z11 is 0z22', 'COMPAREBLOB is'], ! \ ['0z11 isnot 0z22', 'COMPAREBLOB isnot'], ! \ ! \ ['[1,2] == [3,4]', 'COMPARELIST =='], ! \ ['[1,2] != [3,4]', 'COMPARELIST !='], ! \ ['[1,2] is [3,4]', 'COMPARELIST is'], ! \ ['[1,2] isnot [3,4]', 'COMPARELIST isnot'], ! \ ! \ ['#{a:1} == #{x:2}', 'COMPAREDICT =='], ! \ ['#{a:1} != #{x:2}', 'COMPAREDICT !='], ! \ ['#{a:1} is #{x:2}', 'COMPAREDICT is'], ! \ ['#{a:1} isnot #{x:2}', 'COMPAREDICT isnot'], ! \ ! \ ['{->33} == {->44}', 'COMPAREFUNC =='], ! \ ['{->33} != {->44}', 'COMPAREFUNC !='], ! \ ['{->33} is {->44}', 'COMPAREFUNC is'], ! \ ['{->33} isnot {->44}', 'COMPAREFUNC isnot'], ! \ ! \ ['77 == g:xx', 'COMPAREANY =='], ! \ ['77 != g:xx', 'COMPAREANY !='], ! \ ['77 > g:xx', 'COMPAREANY >'], ! \ ['77 < g:xx', 'COMPAREANY <'], ! \ ['77 >= g:xx', 'COMPAREANY >='], ! \ ['77 <= g:xx', 'COMPAREANY <='], ! \ ['77 =~ g:xx', 'COMPAREANY =\~'], ! \ ['77 !~ g:xx', 'COMPAREANY !\~'], ! \ ['77 is g:xx', 'COMPAREANY is'], ! \ ['77 isnot g:xx', 'COMPAREANY isnot'], ! \ ] if has('float') cases->extend([ ! \ ['1.1 == 2.2', 'COMPAREFLOAT =='], ! \ ['1.1 != 2.2', 'COMPAREFLOAT !='], ! \ ['1.1 > 2.2', 'COMPAREFLOAT >'], ! \ ['1.1 < 2.2', 'COMPAREFLOAT <'], ! \ ['1.1 >= 2.2', 'COMPAREFLOAT >='], ! \ ['1.1 <= 2.2', 'COMPAREFLOAT <='], ! \ ['1.1 =~ 2.2', 'COMPAREFLOAT =\~'], ! \ ['1.1 !~ 2.2', 'COMPAREFLOAT !\~'], ! \ ]) endif let nr = 1 for case in cases writefile(['def TestCase' .. nr .. '()', ! \ ' if ' .. case[0], ! \ ' echo 42' ! \ ' endif', ! \ 'enddef'], 'Xdisassemble') source Xdisassemble let instr = execute('disassemble TestCase' .. nr) ! assert_match('TestCase' .. nr .. '.*' ! \ .. 'if ' .. substitute(case[0], '[[~]', '\\\0', 'g') .. '.*' ! \ .. '\d \(PUSH\|FUNCREF\).*' ! \ .. '\d \(PUSH\|FUNCREF\|LOADG\).*' ! \ .. '\d ' .. case[1] .. '.*' ! \ .. '\d JUMP_IF_FALSE -> \d\+.*' ! \, instr) nr += 1 endfor --- 693,801 ---- def Test_disassemble_invert_bool() let instr = execute('disassemble InvertBool') ! assert_match('InvertBool.*' .. ! 'let flag = true.*' .. ! '\d PUSH v:true.*' .. ! '\d STORE $0.*' .. ! 'let invert = !flag.*' .. ! '\d LOAD $0.*' .. ! '\d INVERT (!val).*' .. ! '\d STORE $1.*' .. ! 'let res = !!flag.*' .. ! '\d LOAD $0.*' .. ! '\d 2BOOL (!!val).*' .. ! '\d STORE $2.*', ! instr) call assert_equal(true, InvertBool()) enddef def Test_disassemble_compare() " TODO: COMPAREFUNC let cases = [ ! ['true == false', 'COMPAREBOOL =='], ! ['true != false', 'COMPAREBOOL !='], ! ['v:none == v:null', 'COMPARESPECIAL =='], ! ['v:none != v:null', 'COMPARESPECIAL !='], ! ! ['111 == 222', 'COMPARENR =='], ! ['111 != 222', 'COMPARENR !='], ! ['111 > 222', 'COMPARENR >'], ! ['111 < 222', 'COMPARENR <'], ! ['111 >= 222', 'COMPARENR >='], ! ['111 <= 222', 'COMPARENR <='], ! ['111 =~ 222', 'COMPARENR =\~'], ! ['111 !~ 222', 'COMPARENR !\~'], ! ! ['"xx" != "yy"', 'COMPARESTRING !='], ! ['"xx" > "yy"', 'COMPARESTRING >'], ! ['"xx" < "yy"', 'COMPARESTRING <'], ! ['"xx" >= "yy"', 'COMPARESTRING >='], ! ['"xx" <= "yy"', 'COMPARESTRING <='], ! ['"xx" =~ "yy"', 'COMPARESTRING =\~'], ! ['"xx" !~ "yy"', 'COMPARESTRING !\~'], ! ['"xx" is "yy"', 'COMPARESTRING is'], ! ['"xx" isnot "yy"', 'COMPARESTRING isnot'], ! ! ['0z11 == 0z22', 'COMPAREBLOB =='], ! ['0z11 != 0z22', 'COMPAREBLOB !='], ! ['0z11 is 0z22', 'COMPAREBLOB is'], ! ['0z11 isnot 0z22', 'COMPAREBLOB isnot'], ! ! ['[1,2] == [3,4]', 'COMPARELIST =='], ! ['[1,2] != [3,4]', 'COMPARELIST !='], ! ['[1,2] is [3,4]', 'COMPARELIST is'], ! ['[1,2] isnot [3,4]', 'COMPARELIST isnot'], ! ! ['#{a:1} == #{x:2}', 'COMPAREDICT =='], ! ['#{a:1} != #{x:2}', 'COMPAREDICT !='], ! ['#{a:1} is #{x:2}', 'COMPAREDICT is'], ! ['#{a:1} isnot #{x:2}', 'COMPAREDICT isnot'], ! ! ['{->33} == {->44}', 'COMPAREFUNC =='], ! ['{->33} != {->44}', 'COMPAREFUNC !='], ! ['{->33} is {->44}', 'COMPAREFUNC is'], ! ['{->33} isnot {->44}', 'COMPAREFUNC isnot'], ! ! ['77 == g:xx', 'COMPAREANY =='], ! ['77 != g:xx', 'COMPAREANY !='], ! ['77 > g:xx', 'COMPAREANY >'], ! ['77 < g:xx', 'COMPAREANY <'], ! ['77 >= g:xx', 'COMPAREANY >='], ! ['77 <= g:xx', 'COMPAREANY <='], ! ['77 =~ g:xx', 'COMPAREANY =\~'], ! ['77 !~ g:xx', 'COMPAREANY !\~'], ! ['77 is g:xx', 'COMPAREANY is'], ! ['77 isnot g:xx', 'COMPAREANY isnot'], ! ] if has('float') cases->extend([ ! ['1.1 == 2.2', 'COMPAREFLOAT =='], ! ['1.1 != 2.2', 'COMPAREFLOAT !='], ! ['1.1 > 2.2', 'COMPAREFLOAT >'], ! ['1.1 < 2.2', 'COMPAREFLOAT <'], ! ['1.1 >= 2.2', 'COMPAREFLOAT >='], ! ['1.1 <= 2.2', 'COMPAREFLOAT <='], ! ['1.1 =~ 2.2', 'COMPAREFLOAT =\~'], ! ['1.1 !~ 2.2', 'COMPAREFLOAT !\~'], ! ]) endif let nr = 1 for case in cases writefile(['def TestCase' .. nr .. '()', ! ' if ' .. case[0], ! ' echo 42' ! ' endif', ! 'enddef'], 'Xdisassemble') source Xdisassemble let instr = execute('disassemble TestCase' .. nr) ! assert_match('TestCase' .. nr .. '.*' .. ! 'if ' .. substitute(case[0], '[[~]', '\\\0', 'g') .. '.*' .. ! '\d \(PUSH\|FUNCREF\).*' .. ! '\d \(PUSH\|FUNCREF\|LOADG\).*' .. ! '\d ' .. case[1] .. '.*' .. ! '\d JUMP_IF_FALSE -> \d\+.*', ! instr) nr += 1 endfor *************** *** 805,843 **** def Test_disassemble_compare_const() let cases = [ ! \ ['"xx" == "yy"', false], ! \ ['"aa" == "aa"', true], ! \ ['has("eval") ? true : false', true], ! \ ['has("asdf") ? true : false', false], ! \ ] let nr = 1 for case in cases writefile(['def TestCase' .. nr .. '()', ! \ ' if ' .. case[0], ! \ ' echo 42' ! \ ' endif', ! \ 'enddef'], 'Xdisassemble') source Xdisassemble let instr = execute('disassemble TestCase' .. nr) if case[1] " condition true, "echo 42" executed ! assert_match('TestCase' .. nr .. '.*' ! \ .. 'if ' .. substitute(case[0], '[[~]', '\\\0', 'g') .. '.*' ! \ .. '\d PUSHNR 42.*' ! \ .. '\d ECHO 1.*' ! \ .. '\d PUSHNR 0.*' ! \ .. '\d RETURN.*' ! \, instr) else " condition false, function just returns ! assert_match('TestCase' .. nr .. '.*' ! \ .. 'if ' .. substitute(case[0], '[[~]', '\\\0', 'g') .. '[ \n]*' ! \ .. 'echo 42[ \n]*' ! \ .. 'endif[ \n]*' ! \ .. '\s*\d PUSHNR 0.*' ! \ .. '\d RETURN.*' ! \, instr) endif nr += 1 --- 805,843 ---- def Test_disassemble_compare_const() let cases = [ ! ['"xx" == "yy"', false], ! ['"aa" == "aa"', true], ! ['has("eval") ? true : false', true], ! ['has("asdf") ? true : false', false], ! ] let nr = 1 for case in cases writefile(['def TestCase' .. nr .. '()', ! ' if ' .. case[0], ! ' echo 42' ! ' endif', ! 'enddef'], 'Xdisassemble') source Xdisassemble let instr = execute('disassemble TestCase' .. nr) if case[1] " condition true, "echo 42" executed ! assert_match('TestCase' .. nr .. '.*' .. ! 'if ' .. substitute(case[0], '[[~]', '\\\0', 'g') .. '.*' .. ! '\d PUSHNR 42.*' .. ! '\d ECHO 1.*' .. ! '\d PUSHNR 0.*' .. ! '\d RETURN.*', ! instr) else " condition false, function just returns ! assert_match('TestCase' .. nr .. '.*' .. ! 'if ' .. substitute(case[0], '[[~]', '\\\0', 'g') .. '[ \n]*' .. ! 'echo 42[ \n]*' .. ! 'endif[ \n]*' .. ! '\s*\d PUSHNR 0.*' .. ! '\d RETURN.*', ! instr) endif nr += 1 *************** *** 856,882 **** def Test_disassemble_execute() let res = execute('disass s:Execute') ! assert_match('\\d*_Execute.*' ! \ .. "execute 'help vim9.txt'.*" ! \ .. '\d PUSHS "help vim9.txt".*' ! \ .. '\d EXECUTE 1.*' ! \ .. "let cmd = 'help vim9.txt'.*" ! \ .. '\d PUSHS "help vim9.txt".*' ! \ .. '\d STORE $0.*' ! \ .. 'execute cmd.*' ! \ .. '\d LOAD $0.*' ! \ .. '\d EXECUTE 1.*' ! \ .. "let tag = 'vim9.txt'.*" ! \ .. '\d PUSHS "vim9.txt".*' ! \ .. '\d STORE $1.*' ! \ .. "execute 'help ' .. tag.*" ! \ .. '\d PUSHS "help ".*' ! \ .. '\d LOAD $1.*' ! \ .. '\d CONCAT.*' ! \ .. '\d EXECUTE 1.*' ! \ .. '\d PUSHNR 0.*' ! \ .. '\d RETURN' ! \, res) enddef def SomeStringArg(arg: string) --- 856,882 ---- def Test_disassemble_execute() let res = execute('disass s:Execute') ! assert_match('\\d*_Execute.*' .. ! "execute 'help vim9.txt'.*" .. ! '\d PUSHS "help vim9.txt".*' .. ! '\d EXECUTE 1.*' .. ! "let cmd = 'help vim9.txt'.*" .. ! '\d PUSHS "help vim9.txt".*' .. ! '\d STORE $0.*' .. ! 'execute cmd.*' .. ! '\d LOAD $0.*' .. ! '\d EXECUTE 1.*' .. ! "let tag = 'vim9.txt'.*" .. ! '\d PUSHS "vim9.txt".*' .. ! '\d STORE $1.*' .. ! "execute 'help ' .. tag.*" .. ! '\d PUSHS "help ".*' .. ! '\d LOAD $1.*' .. ! '\d CONCAT.*' .. ! '\d EXECUTE 1.*' .. ! '\d PUSHNR 0.*' .. ! '\d RETURN', ! res) enddef def SomeStringArg(arg: string) *************** *** 893,914 **** def Test_display_func() let res1 = execute('function SomeStringArg') ! assert_match('.* def SomeStringArg(arg: string).*' ! \ .. ' echo arg.*' ! \ .. ' enddef' ! \, res1) let res2 = execute('function SomeAnyArg') ! assert_match('.* def SomeAnyArg(arg: any).*' ! \ .. ' echo arg.*' ! \ .. ' enddef' ! \, res2) let res3 = execute('function SomeStringArgAndReturn') ! assert_match('.* def SomeStringArgAndReturn(arg: string): string.*' ! \ .. ' return arg.*' ! \ .. ' enddef' ! \, res3) enddef " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker --- 893,914 ---- def Test_display_func() let res1 = execute('function SomeStringArg') ! assert_match('.* def SomeStringArg(arg: string).*' .. ! ' echo arg.*' .. ! ' enddef', ! res1) let res2 = execute('function SomeAnyArg') ! assert_match('.* def SomeAnyArg(arg: any).*' .. ! ' echo arg.*' .. ! ' enddef', ! res2) let res3 = execute('function SomeStringArgAndReturn') ! assert_match('.* def SomeStringArgAndReturn(arg: string): string.*' .. ! ' return arg.*' .. ! ' enddef', ! res3) enddef " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker *** ../vim-8.2.0564/src/version.c 2020-04-12 22:22:27.060446273 +0200 --- src/version.c 2020-04-12 22:53:22.311730304 +0200 *************** *** 740,741 **** --- 740,743 ---- { /* Add new patch number below this line */ + /**/ + 565, /**/ -- System administrators are just like women: You can't live with them and you can't live without them. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///