To: vim_dev@googlegroups.com Subject: Patch 8.2.0757 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0757 Problem: Vim9: no test for MEMBER instruction. Solution: Add a test. Make matches stricter. Files: src/testdir/test_vim9_disassemble.vim *** ../vim-8.2.0756/src/testdir/test_vim9_disassemble.vim 2020-05-14 22:41:10.229637563 +0200 --- src/testdir/test_vim9_disassemble.vim 2020-05-15 19:15:37.946728516 +0200 *************** *** 726,743 **** 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 --- 726,743 ---- def Test_disassemble_list_index() let instr = execute('disassemble ListIndex') ! assert_match('ListIndex\_s*' .. ! 'let l = \[1, 2, 3]\_s*' .. ! '\d PUSHNR 1\_s*' .. ! '\d PUSHNR 2\_s*' .. ! '\d PUSHNR 3\_s*' .. ! '\d NEWLIST size 3\_s*' .. ! '\d STORE $0\_s*' .. ! 'let res = l\[1]\_s*' .. ! '\d LOAD $0\_s*' .. ! '\d PUSHNR 1\_s*' .. ! '\d INDEX\_s*' .. ! '\d STORE $1\_s*', instr) assert_equal(2, ListIndex()) enddef *************** *** 745,765 **** def DictMember(): number let d = #{item: 1} let res = d.item return res enddef 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 --- 745,771 ---- def DictMember(): number let d = #{item: 1} let res = d.item + res = d["item"] return res enddef def Test_disassemble_dict_member() let instr = execute('disassemble DictMember') ! assert_match('DictMember\_s*' .. ! 'let d = #{item: 1}\_s*' .. ! '\d PUSHS "item"\_s*' .. ! '\d PUSHNR 1\_s*' .. ! '\d NEWDICT size 1\_s*' .. ! '\d STORE $0\_s*' .. ! 'let res = d.item\_s*' .. ! '\d\+ LOAD $0\_s*' .. ! '\d\+ MEMBER item\_s*' .. ! '\d\+ STORE $1\_s*' .. ! 'res = d\["item"\]\_s*' .. ! '\d\+ LOAD $0\_s*' .. ! '\d\+ PUSHS "item"\_s*' .. ! '\d\+ MEMBER\_s*' .. ! '\d\+ STORE $1\_s*', instr) call assert_equal(1, DictMember()) enddef *************** *** 773,789 **** 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 --- 779,795 ---- def Test_disassemble_negate_number() let instr = execute('disassemble NegateNumber') ! assert_match('NegateNumber\_s*' .. ! 'let nr = 9\_s*' .. ! '\d STORE 9 in $0\_s*' .. ! 'let plus = +nr\_s*' .. ! '\d LOAD $0\_s*' .. ! '\d CHECKNR\_s*' .. ! '\d STORE $1\_s*' .. ! 'let res = -nr\_s*' .. ! '\d LOAD $0\_s*' .. ! '\d NEGATENR\_s*' .. ! '\d STORE $2\_s*', instr) call assert_equal(-9, NegateNumber()) enddef *************** *** 797,814 **** 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 --- 803,820 ---- def Test_disassemble_invert_bool() let instr = execute('disassemble InvertBool') ! assert_match('InvertBool\_s*' .. ! 'let flag = true\_s*' .. ! '\d PUSH v:true\_s*' .. ! '\d STORE $0\_s*' .. ! 'let invert = !flag\_s*' .. ! '\d LOAD $0\_s*' .. ! '\d INVERT (!val)\_s*' .. ! '\d STORE $1\_s*' .. ! 'let res = !!flag\_s*' .. ! '\d LOAD $0\_s*' .. ! '\d 2BOOL (!!val)\_s*' .. ! '\d STORE $2\_s*', instr) call assert_equal(true, InvertBool()) enddef *************** *** 970,995 **** 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 --- 976,1001 ---- def Test_disassemble_execute() let res = execute('disass s:Execute') ! assert_match('\\d*_Execute\_s*' .. ! "execute 'help vim9.txt'\\_s*" .. ! '\d PUSHS "help vim9.txt"\_s*' .. ! '\d EXECUTE 1\_s*' .. ! "let cmd = 'help vim9.txt'\\_s*" .. ! '\d PUSHS "help vim9.txt"\_s*' .. ! '\d STORE $0\_s*' .. ! 'execute cmd\_s*' .. ! '\d LOAD $0\_s*' .. ! '\d EXECUTE 1\_s*' .. ! "let tag = 'vim9.txt'\\_s*" .. ! '\d PUSHS "vim9.txt"\_s*' .. ! '\d STORE $1\_s*' .. ! "execute 'help ' .. tag\\_s*" .. ! '\d\+ PUSHS "help "\_s*' .. ! '\d\+ LOAD $1\_s*' .. ! '\d\+ CONCAT\_s*' .. ! '\d\+ EXECUTE 1\_s*' .. ! '\d\+ PUSHNR 0\_s*' .. ! '\d\+ RETURN', res) enddef *************** *** 1000,1014 **** def Test_disassemble_echomsg() let res = execute('disass s:Echomsg') ! assert_match('\\d*_Echomsg.*' .. ! "echomsg 'some' 'message'.*" .. ! '\d PUSHS "some".*' .. ! '\d PUSHS "message".*' .. ! '\d ECHOMSG 2.*' .. ! "echoerr 'went' .. 'wrong'.*" .. ! '\d PUSHS "wentwrong".*' .. ! '\d ECHOERR 1.*' .. ! '\d PUSHNR 0.*' .. '\d RETURN', res) enddef --- 1006,1020 ---- def Test_disassemble_echomsg() let res = execute('disass s:Echomsg') ! assert_match('\\d*_Echomsg\_s*' .. ! "echomsg 'some' 'message'\\_s*" .. ! '\d PUSHS "some"\_s*' .. ! '\d PUSHS "message"\_s*' .. ! '\d ECHOMSG 2\_s*' .. ! "echoerr 'went' .. 'wrong'\\_s*" .. ! '\d PUSHS "wentwrong"\_s*' .. ! '\d ECHOERR 1\_s*' .. ! '\d PUSHNR 0\_s*' .. '\d RETURN', res) enddef *************** *** 1027,1047 **** 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 --- 1033,1053 ---- def Test_display_func() let res1 = execute('function SomeStringArg') ! assert_match('.* def SomeStringArg(arg: string)\_s*' .. ! '\d *echo arg.*' .. ! ' *enddef', res1) let res2 = execute('function SomeAnyArg') ! assert_match('.* def SomeAnyArg(arg: any)\_s*' .. ! '\d *echo arg\_s*' .. ! ' *enddef', res2) let res3 = execute('function SomeStringArgAndReturn') ! assert_match('.* def SomeStringArgAndReturn(arg: string): string\_s*' .. ! '\d *return arg\_s*' .. ! ' *enddef', res3) enddef *************** *** 1060,1068 **** source Xdisassemble " check that the first function calls the second with DCALL ! assert_match('\\d*_FuncOne.*' .. ! 'return FuncTwo().*' .. ! '\d DCALL \d\+_FuncTwo(argc 0).*' .. '\d RETURN', g:res_FuncOne) --- 1066,1074 ---- source Xdisassemble " check that the first function calls the second with DCALL ! assert_match('\\d*_FuncOne\_s*' .. ! 'return FuncTwo()\_s*' .. ! '\d DCALL \d\+_FuncTwo(argc 0)\_s*' .. '\d RETURN', g:res_FuncOne) *************** *** 1084,1103 **** def Test_simplify_const_expr() let res = execute('disass s:ConcatStrings') ! assert_match('\\d*_ConcatStrings.*' .. ! '\d PUSHS "onetwothree".*' .. '\d RETURN', res) res = execute('disass s:ComputeConst') ! assert_match('\\d*_ComputeConst.*' .. ! '\d PUSHNR 11.*' .. '\d RETURN', res) res = execute('disass s:ComputeConstParen') ! assert_match('\\d*_ComputeConstParen.*' .. ! '\d PUSHNR 3\>.*' .. '\d RETURN', res) enddef --- 1090,1112 ---- def Test_simplify_const_expr() let res = execute('disass s:ConcatStrings') ! assert_match('\d*_ConcatStrings\_s*' .. ! "return 'one' .. 'two' .. 'three'\\_s*" .. ! '\d PUSHS "onetwothree"\_s*' .. '\d RETURN', res) res = execute('disass s:ComputeConst') ! assert_match('\d*_ComputeConst\_s*' .. ! 'return 2 + 3 \* 4 / 6 + 7\_s*' .. ! '\d PUSHNR 11\_s*' .. '\d RETURN', res) res = execute('disass s:ComputeConstParen') ! assert_match('\d*_ComputeConstParen\_s*' .. ! 'return ((2 + 4) \* (8 / 2)) / (3 + 4)\_s*' .. ! '\d PUSHNR 3\>\_s*' .. '\d RETURN', res) enddef *** ../vim-8.2.0756/src/version.c 2020-05-15 18:21:47.286058929 +0200 --- src/version.c 2020-05-15 18:56:35.418739737 +0200 *************** *** 748,749 **** --- 748,751 ---- { /* Add new patch number below this line */ + /**/ + 757, /**/ -- hundred-and-one symptoms of being an internet addict: 94. Now admit it... How many of you have made "modem noises" into the phone just to see if it was possible? :-) /// 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 ///